title: FPU operations generated by GCC during casting integer to float
body: <p>I want to perform division on an FPU in C (using integer values):</p>
  
  <pre><code>float foo;
  uint32_t *ptr1, *ptr2;
  foo = (float)*(ptr1) / (float)*(ptr2);
  </code></pre>
  
  <p>And in <em>NASM</em> (from object compiled via <em>GCC</em>) it has following representation:</p>
  
  <pre><code>    mov     rax, QWORD [ptr1]
      mov     eax, DWORD [rax]
      mov     eax, eax
      test    rax, rax
      js      ?_001
      pxor    xmm0, xmm0
      cvtsi2ss xmm0, rax
      jmp     ?_002
  
  ?_001:
      mov     rdx, rax
      shr     rdx, 1
      and     eax, 01H
      or      rdx, rax
      pxor    xmm0, xmm0
      cvtsi2ss xmm0, rdx
      addss   xmm0, xmm0
  ?_002:
      mov     rax, QWORD [ptr2]
  
  ; ... for ptr2 pattern repeats
  </code></pre>
  
  <p>What does this "black magic" under <em>?_001</em> mean? Isn't only <em>cvtsi2ss</em> enough for conversion from integer to float?</p>