title: OS X calling convention return value
body: <p>I've seen a gdb disassembly output of a main function that does nothing particular and it looks like this:</p>
  
  <pre><code>1  push    %rbp
  2  mov     %rsp, %rbp
  3  sub     $0x10,%rsp
  4  movl    $0x0, -0x8(%rbp)    ;
  5  mov     -0x8(%rbp), %eax    ;
  6  mov     %eax, -0x4(%rbp)    ;
  7  mov     -0x4(%rbp), %eax    ;
  8  add     $0x10, %rsp
  9  pop     %rbp
  10 retq
  </code></pre>
  
  <p>I'm not a Mac user, but I'm curious, what are exactly the lines from 4 to 7 doing? .Shouldn't be something like this:</p>
  
  <pre><code>push    %rbp
  mov     %rsp, %rbp
  sub     $0x10, %rsp
  xor     %eax, %eax
  add     $0x10, %rsp
  pop     %rbp
  retq
  </code></pre>
  
  <p><em><strong>Note</em></strong>: please feel free to improve the question title, I couldn't find a better one.</p>