// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
sarl %esi
movl %ecx, (%rsp)
cmpl %ecx, %esi
movq %r8, 0x20(%rsp)
jge 0x832c
xorl %r15d, %r15d
movl $0x1, %ebx
movq %r8, %rdx
jmp 0x84b2
negl %edx
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, %ebx
movq %rdi, %rax
movq %r8, %rdx
movl %esi, %ebp
movl %esi, 0x4(%rsp)
movq %rdx, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movl %esi, %r15d
testl %ebx, %ebx
jle 0x8494
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 %r13d, %r13d
xorl %r12d, %r12d
movl 0x4(%rsp), %r15d
xorl %r14d, %r14d
movsd %xmm0, 0x48(%rsp)
mulsd 0x336f(%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 0x8475
movl %r13d, %eax
shlq $0x4, %rax
addq 0x10(%rsp), %rax
movl %r12d, %ecx
imull 0x8(%rsp), %ecx
addl %ebp, %ecx
mulsd 0x28(%rsp), %xmm0
movapd %xmm0, %xmm1
xorpd 0x30ed(%rip), %xmm1     # 0xb4e0
movslq %r15d, %rdx
movslq %r14d, %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 0x18(%rsp), %r8
addq %r8, %rsi
shlq $0x4, %rdx
addq %r8, %rdx
movl %r13d, %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 %r14d
incl %r15d
cmpl %r8d, %ecx
jg 0x8428
movsd 0x48(%rsp), %xmm0
addsd 0x2bcd(%rip), %xmm0     # 0xb050
incl %r12d
addl 0x8(%rsp), %r13d
cmpl %ebx, %r12d
jne 0x8393
sarl %ebp
addl %ebx, %ebx
movq 0x18(%rsp), %rdi
movq %rdi, %rax
cmpl (%rsp), %ebp
movq 0x10(%rsp), %rdx
movl 0x4(%rsp), %esi
jge 0x8349
cmpq 0x20(%rsp), %rdx
sete %al
movl 0xc(%rsp), %esi
testl %esi, %esi
setle %cl
orb %al, %cl
jne 0x84e2
movl %esi, %eax
shlq $0x4, %rax
xorl %ecx, %ecx
movupd (%rdi,%rcx), %xmm0
movupd %xmm0, (%rdx,%rcx)
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x84cf
movl %esi, %eax
cltd
idivl (%rsp)
cmpl %eax, %ebx
jne 0x8505
cmpl $0x1, %esi
je 0x84f6
cmpl %esi, %r15d
jne 0x8524
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x320c(%rip), %rdi      # 0xb718
leaq 0x3210(%rip), %rsi      # 0xb723
leaq 0x320f(%rip), %rcx      # 0xb729
movl $0x72, %edx
callq 0x2100
leaq 0x3231(%rip), %rdi      # 0xb75c
leaq 0x31f1(%rip), %rsi      # 0xb723
leaq 0x31f0(%rip), %rcx      # 0xb729
movl $0x73, %edx
callq 0x2100