title: How does "call __isoc99_sscanf" work
body: <p>I'm pretty sure the input argument on the command line is supposed to be a string, but when I get to "call __isoc99_sscanf", the eax register holds a value of 0. I don't really know how "call __isoc99_sscanf" is supposed to work, but I do know that the stack pointers are sorted like so:</p>
  
  <p>.LC1
     |
     V
  eax</p>
  
  <p>.LC1 is "Input: %s" and eax before the "call __isoc99_sscanf" is 33 and holds a string in the memory. In any case, when does the call __isoc99_sscanf result in 1?</p>
  
  <pre><code>  .code32
  .file   "mystery.c"
  .text
  .LCO:
  .string "Incorrect number of command line arguments given"
  .LC1:
  .string "Input:%s"
  .align 4
  .LC2:
  .string "Incorrect format for command line argument"
  .LC3:
  .string "Output: \"%s\"\n"
  .text
   .globl main
  .type   main, @function
   main:
  pushl   %ebp
  movl    %esp, %ebp
  andl    $-16, %esp
  subl    $32, %esp
  cmpl    $2, 8(%ebp)
  je  .L18
  movl    $.LC0, (%esp)
  call    puts
  movl    $1, %eax
  jmp .L19
  .L18:
  movl    12(%ebp), %eax
  addl    $4, %eax
  movl    (%eax), %eax
  movl    %eax, (%esp)
  call    strlen
  movl    %eax, %edx
  movl    %edx, %eax
  sall    $2, %eax
  addl    %edx, %eax
  movl    %eax, (%esp)
  call    malloc
  movl    %eax, 28(%esp)
  movl    $.LC1, %edx
  movl    12(%ebp), %eax
  addl    $4, %eax
  movl    (%eax), %eax
  movl    28(%esp), %ecx
  movl    %ecx, 8(%esp)
  movl    %edx, 4(%esp)
  movl    %eax, (%esp)
  call    __isoc99_sscanf
  cmpl    $1, %eax
  je  .L20
  movl    $.LC2, (%esp)
  call    puts
  movl    $1, %eax
  jmp .L19
  
   .L20:
  movl    28(%esp), %eax
  movl    %eax, (%esp)
  call    foo
  movl    $.LC3, %eax
  movl    28(%esp), %edx
  movl    %edx, 4(%esp)
  movl    %eax, (%esp)
  call    printf
  movl    28(%esp), %eax
  movl    %eax, (%esp)
  call    free
  jmp .L17
  .L19:
  .L17:
  leave
  ret
  .size   main, .-main
  .ident  "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-4)"
  .section    .note.GNU-stack,"",@progbits
  </code></pre>