title: Why do we use sub $0x18, %rsp?
body: <p>I studied 32 bit machine, and I know sub $12, %esp as same as three time on pop %eax and mov $0, %eax.</p>
  
  <p>But I don't know why we use add $18, %rsp with start procedure call or sub $18, %rsp start with procedure call at x86-64 machine.</p>
  
  <p>Why does compiler use this rule for procedure call? Argument rule?</p>
  
  <pre><code>0x0000000000400df3 &lt;main+191&gt;:  mov    $0x402227,%edi
  0x0000000000400df8 &lt;main+196&gt;:  callq  0x400ab8 &lt;puts@plt&gt;
  0x0000000000400dfd &lt;main+201&gt;:  callq  0x4014c0 &lt;read_line&gt;
  0x0000000000400e02 &lt;main+206&gt;:  mov    %rax,%rdi
  0x0000000000400e05 &lt;main+209&gt;:  callq  0x401139 &lt;phase_3&gt;
  
  -----------------------------------------------------------------------
  example:
  
  0x0000000000401139 &lt;example+0&gt;: sub    $0x18,%rsp
  0x000000000040113d &lt;example+4&gt;: lea    0x8(%rsp),%rcx
  0x0000000000401142 &lt;example+9&gt;: lea    0xc(%rsp),%rdx
  0x0000000000401147 &lt;example+14&gt;:        mov    $0x40248a,%esi
  0x000000000040114c &lt;example+19&gt;:        mov    $0x0,%eax
  0x0000000000401151 &lt;example+24&gt;:        callq  0x400ac8 &lt;__isoc99_sscanf@plt&gt;
  0x0000000000401156 &lt;example+29&gt;:        cmp    $0x1,%eax
  </code></pre>