// File: /workspace/github_c_makefile_star2_O3/guszejnovdavid[P]MISFIT/fft.c
// Function: stockham(complex*, int, int, int, complex*)
void stockham(complex x[], int n, int flag, int n2, complex y[])
{
   complex  *y_orig, *tmp;
   int  i, j, k, k2, Ls, r, jrs;
   int  half, m, m2=0;
   real  wr, wi, tr, ti;
   
   y_orig = y;
   r = half = n >> 1;
   Ls = 1;                                         /* Ls=L/2 is the L star */
  
   while(r >= n2) {                              /* loops log2(n/n2) times */
      tmp = x;                           /* swap pointers, y is always old */
      x = y;                                   /* x is always for new data */
      y = tmp;
      m = 0;                        /* m runs over first half of the array */
      m2 = half;                             /* m2 for second half, n2=n/2 */
      for(j = 0; j < Ls; ++j) {
         wr = cos(M_PI*j/Ls);                   /* real and imaginary part */
         wi = -flag * sin(M_PI*j/Ls);                      /* of the omega */
         jrs = j*(r+r);
         for(k = jrs; k < jrs+r; ++k) {           /* "butterfly" operation */
            k2 = k + r;
            tr =  wr*y[k2].Re - wi*y[k2].Im;      /* complex multiply, w*y */
            ti =  wr*y[k2].Im + wi*y[k2].Re;
            x[m].Re = y[k].Re + tr;
            x[m].Im = y[k].Im + ti;
            x[m2].Re = y[k].Re - tr;
            x[m2].Im = y[k].Im - ti;
            ++m;
            ++m2;
         }
      } 
      r  >>= 1;
      Ls <<= 1;
   };

   if (y != y_orig) {                     /* copy back to permanent memory */
      for(i = 0; i < n; ++i) {               /* if it is not already there */
         y[i] = x[i];               /* performed only if log2(n/n2) is odd */
      }
   }
   
   assert(Ls == n/n2);                        /* ensure n is a power of 2  */
   assert(1 == n || m2 == n);           /* check array index within bound  */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %eax
sarl %eax
movl %ecx, (%rsp)
cmpl %ecx, %eax
jge 0x829a
movl $0x1, %ebx
xorl %r12d, %r12d
jmp 0x8457
movl %esi, 0xc(%rsp)
negl %edx
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, %ebx
movq %r8, 0x20(%rsp)
movq %r8, %rdx
movl %eax, %ebp
movl %eax, 0x4(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
movl %eax, %r12d
testl %ebx, %ebx
jle 0x8408
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x38(%rsp)
leal (,%rbp,2), %eax
movl %eax, 0x8(%rsp)
movl %ebp, %eax
shlq $0x4, %rax
movq %rax, 0x30(%rsp)
xorpd %xmm0, %xmm0
xorl %r14d, %r14d
xorl %r15d, %r15d
movl 0x4(%rsp), %r12d
xorl %r13d, %r13d
movsd %xmm0, 0x48(%rsp)
mulsd 0x33fb(%rip), %xmm0     # 0xb710
divsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
callq 0x23e0
movapd %xmm0, 0x50(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x2080
testl %ebp, %ebp
jle 0x83e9
movl %r14d, %eax
shlq $0x4, %rax
addq 0x18(%rsp), %rax
movl %r15d, %ecx
imull 0x8(%rsp), %ecx
addl %ebp, %ecx
mulsd 0x28(%rsp), %xmm0
movapd %xmm0, %xmm1
xorpd 0x3179(%rip), %xmm1     # 0xb4e0
movslq %r12d, %rdx
movslq %r13d, %rsi
movapd 0x50(%rsp), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movq 0x30(%rsp), %rdi
addq %rax, %rdi
shlq $0x4, %rsi
movq 0x10(%rsp), %r8
addq %r8, %rsi
shlq $0x4, %rdx
addq %r8, %rdx
movl %r14d, %r8d
xorl %r9d, %r9d
movupd (%rdi,%r9), %xmm1
movapd %xmm1, %xmm2
mulpd %xmm0, %xmm2
shufpd $0x1, %xmm2, %xmm2      # xmm2 = xmm2[1,0]
mulpd %xmm3, %xmm1
addpd %xmm2, %xmm1
movupd (%rax,%r9), %xmm2
addpd %xmm1, %xmm2
movupd %xmm2, (%rsi,%r9)
movupd (%rax,%r9), %xmm2
subpd %xmm1, %xmm2
movupd %xmm2, (%rdx,%r9)
addq $0x10, %r9
incl %r8d
incl %r13d
incl %r12d
cmpl %r8d, %ecx
jg 0x839c
movsd 0x48(%rsp), %xmm0
addsd 0x2c59(%rip), %xmm0     # 0xb050
incl %r15d
addl 0x8(%rsp), %r14d
cmpl %ebx, %r15d
jne 0x8307
sarl %ebp
addl %ebx, %ebx
movq 0x10(%rsp), %r8
movq %r8, %rdi
cmpl (%rsp), %ebp
movq 0x18(%rsp), %rdx
movl 0x4(%rsp), %eax
jge 0x82bd
cmpq 0x20(%rsp), %rdx
sete %al
movl 0xc(%rsp), %esi
testl %esi, %esi
setle %cl
orb %al, %cl
jne 0x8457
movl %esi, %eax
shlq $0x4, %rax
xorl %ecx, %ecx
movupd (%r8,%rcx), %xmm0
movupd %xmm0, (%rdx,%rcx)
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x8443
movl %esi, %eax
cltd
idivl (%rsp)
cmpl %eax, %ebx
jne 0x847a
cmpl $0x1, %esi
je 0x846b
cmpl %esi, %r12d
jne 0x8499
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3297(%rip), %rdi      # 0xb718
leaq 0x329b(%rip), %rsi      # 0xb723
leaq 0x329a(%rip), %rcx      # 0xb729
movl $0x72, %edx
callq 0x2100
leaq 0x32bc(%rip), %rdi      # 0xb75c
leaq 0x327c(%rip), %rsi      # 0xb723
leaq 0x327b(%rip), %rcx      # 0xb729
movl $0x73, %edx
callq 0x2100