title: C to assembly - leaq instruction
body: <p>As far as I understood:</p>
  
  <ul>
  <li>%rdi = 1st argument = x</li>
  <li>%rsi = 2nd argument = y </li>
  <li>%rdx = 3rd argument = z</li>
  <li>The others manipulate these registers... and store in a return value register</li>
  </ul>
  
  <p>The 3rd line on the assembly code <code>leaq (%rsi, %rsi, 2), %rdx</code>, which as I translate it: <code>z = y + 2*y</code>.</p>
  
  <p>I'm confused, is this code wrong, or is it an assembly magic?</p>
  
  <p><a href="https://i.stack.imgur.com/Eg4xA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eg4xA.png" alt="enter image description here"></a></p>