title: Trouble figuring out assembly loop
body: <p>Could someone help me decipher lines 49 - 72? I know it's a loop from 1 to 6 but my answers seems to differ with varying outputs. For example, if I input 0 1 2 3 4 5, I don't explode the bomb at 0. However, if I input 0 2 4 6 8 10, the bomb explodes at 0? I'm confused on why.</p>
  
  <pre><code>   0x0000000000400f49 &lt;+0&gt;:     push   %rbp
     0x0000000000400f4a &lt;+1&gt;:     push   %rbx
     0x0000000000400f4b &lt;+2&gt;:     sub    $0x28,%rsp
     0x0000000000400f4f &lt;+6&gt;:     mov    %fs:0x28,%rax
     0x0000000000400f58 &lt;+15&gt;:    mov    %rax,0x18(%rsp)
     0x0000000000400f5d &lt;+20&gt;:    xor    %eax,%eax
     0x0000000000400f5f &lt;+22&gt;:    mov    %rsp,%rsi
     0x0000000000400f62 &lt;+25&gt;:    callq  0x4016c6 &lt;read_six_numbers&gt;
     0x0000000000400f67 &lt;+30&gt;:    cmpl   $0x0,(%rsp)
     0x0000000000400f6b &lt;+34&gt;:    jns    0x400f72 &lt;phase_2+41&gt;
     0x0000000000400f6d &lt;+36&gt;:    callq  0x401690 &lt;explode_bomb&gt;
     0x0000000000400f72 &lt;+41&gt;:    mov    %rsp,%rbp
     0x0000000000400f75 &lt;+44&gt;:    mov    $0x1,%ebx
     0x0000000000400f7a &lt;+49&gt;:    mov    %ebx,%eax
     0x0000000000400f7c &lt;+51&gt;:    add    0x0(%rbp),%eax
     0x0000000000400f7f &lt;+54&gt;:    cmp    %eax,0x4(%rbp)
     0x0000000000400f82 &lt;+57&gt;:    je     0x400f89 &lt;phase_2+64&gt;
     0x0000000000400f84 &lt;+59&gt;:    callq  0x401690 &lt;explode_bomb&gt;
     0x0000000000400f89 &lt;+64&gt;:    add    $0x1,%ebx
     0x0000000000400f8c &lt;+67&gt;:    add    $0x4,%rbp
     0x0000000000400f90 &lt;+71&gt;:    cmp    $0x6,%ebx
     0x0000000000400f93 &lt;+74&gt;:    jne    0x400f7a &lt;phase_2+49&gt;
     0x0000000000400f95 &lt;+76&gt;:    mov    0x18(%rsp),%rax
     0x0000000000400f9a &lt;+81&gt;:    xor    %fs:0x28,%rax
     0x0000000000400fa3 &lt;+90&gt;:    je     0x400faa &lt;phase_2+97&gt;
     0x0000000000400fa5 &lt;+92&gt;:    callq  0x400b90 &lt;__stack_chk_fail@plt&gt;
     0x0000000000400faa &lt;+97&gt;:    add    $0x28,%rsp
     0x0000000000400fae &lt;+101&gt;:   pop    %rbx
     0x0000000000400faf &lt;+102&gt;:   pop    %rbp
     0x0000000000400fb0 &lt;+103&gt;:   retq
  </code></pre>