title: x86-64 assembly: why offset 25 bytes?
body: <p>I started learning x86 assembly today by analyzing the assembly code corresponding to this c++ example (I know there exists something like <code>atoi</code> but I wanted to keep the example minimal):</p>
  
  <pre><code>#include &lt;vector&gt;
  
  std::vector&lt;int&gt; range(int N) {
      std::vector&lt;int&gt; v(N);
      for (unsigned int i = 0; i &lt; N; ++i)
          v[i] = i;
      return v;
  }
  
  int main() {
      return range(100).back();
  }
  </code></pre>
  
  <p>If compiled with <code>g++ -O0 -S -fno-stack-protector return_by_value.cpp</code>, this results in this excerpt:</p>
  
  <pre><code>... &lt;snip&gt;
  _Z5rangei:
  .LFB509:
      .cfi_startproc
      .cfi_personality 0x3,__gxx_personality_v0
      .cfi_lsda 0x3,.LLSDA509
      pushq   %rbp
      .cfi_def_cfa_offset 16
      .cfi_offset 6, -16
      movq    %rsp, %rbp
      .cfi_def_cfa_register 6
      pushq   %rbx
      subq    $40, %rsp
      .cfi_offset 3, -24
      movq    %rdi, -40(%rbp)
      movl    %esi, -44(%rbp)
      leaq    -25(%rbp), %rax
      movq    %rax, %rdi
      call    _ZNSaIiEC1Ev
      movl    $0, -24(%rbp)
      movl    -44(%rbp), %eax
      movslq  %eax, %rsi
      leaq    -25(%rbp), %rcx
      leaq    -24(%rbp), %rdx
      ... &lt;snip&gt;
  </code></pre>
  
  <p>I was surprised to see an odd (i.e. not multiple of 8) offset: <code>leaq -25(%rbp), %rax</code>, especially since it is a <code>q</code> instruction and further we have also <code>-24(%rbp)</code>. <strong>For what reason is the compiler reading across 8 byte boundaries?</strong></p>