title: Calling printf from inline ASM (X64)
body: <p>I have this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  
  int main(void){
      char *fmt = "%s";
      char *s = "Hello world!\n";
  
  //gcc -m32 test.c
  #ifdef __i386__
      int32_t ret;
      __asm__ __volatile__ (
          "push %1\n\t"
          "push %2\n\t"
          "movl $2, %%eax\n\t"
          "call printf\n\t"
          "movl %0, %%eax"
          : "=r" (ret)
          : "r" (s), "r" (fmt)
          :
      );
  #endif
  
  //gcc -m64 test.c
  #ifdef __x86_64__
      int64_t ret;
      __asm__ __volatile__ (
          "push %1\n\t"
          "push %2\n\t"
          "movq $2, %%rax\n\t"
          "call printf\n\t"
          "movq %0, %%rax"
          : "=r" (ret)
          : "r" (s), "r" (fmt)
          :
      );
  #endif
  
      return ret;
  }
  </code></pre>
  
  <p>The x86 version works as expected, but the x64 version segfaults. Why is it segfault-ing?</p>