// File: /workspace/github_c_makefile_star2_O2/guszejnovdavid[P]MISFIT/fft.c
// Function: cooley_tukey(complex*, int, int, int)
void cooley_tukey(complex x[], int n, int flag, int n2)
{
   complex c;
   int i, j, k, m, p, n1;
   int Ls, ks, ms, jm, dk;
   real wr, wi, tr, ti;

   n1 = n/n2;                               /* do bit reversal permutation */
   for(k = 0; k < n1; ++k) {        /* This is algorithms 1.5.1 and 1.5.2. */
      j = 0; 
      m = k;
      p = 1;                               /* p = 2^q,  q used in the book */
      while(p < n1) {
         j = 2*j + (m&1);
         m >>= 1;
         p <<= 1;
      }
      assert(p == n1);                   /* make sure n1 is a power of two */
      if(j > k) {
         for(i = 0; i < n2; ++i) {                     /* swap k <-> j row */
            c = x[k*n2+i];                              /* for all columns */
            x[k*n2+i] = x[j*n2+i];
            x[j*n2+i] = c;
         }
      }
   }
                                              /* This is (3.1.7), page 124 */
   p = 1;
   while(p < n1) {
      Ls = p;
      p <<= 1;
      jm = 0;                                                /* jm is j*n2 */
      dk = p*n2;
      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 */
         for(k = jm; k < n; k += dk) {                      /* "butterfly" */
            ks = k + Ls*n2;
            for(i = 0; i < n2; ++i) {                      /* for each row */
               m = k + i;
               ms = ks + i;
               tr =  wr*x[ms].Re - wi*x[ms].Im;
               ti =  wr*x[ms].Im + wi*x[ms].Re;
               x[ms].Re = x[m].Re - tr;
               x[ms].Im = x[m].Im - ti;
               x[m].Re += tr;
               x[m].Im += ti;
            }
         }
         jm += n2;
      } 
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %r15d
movq %rdi, %r10
movl %esi, %eax
cltd
idivl %ecx
xorl %edx, %edx
testl %ecx, %ecx
movl $0x0, %r12d
cmovgl %ecx, %r12d
movl %ecx, 0x8(%rsp)
movslq %ecx, %rcx
testl %eax, %eax
movl $0x0, %edi
cmovgl %eax, %edi
movq %rcx, 0x30(%rsp)
shlq $0x4, %rcx
movq %rcx, 0x20(%rsp)
movq %r12, %r8
shlq $0x4, %r8
pushq $0x1
popq %r9
movq %r10, 0x18(%rsp)
cmpq %rdi, %rdx
je 0x7f48
xorl %r11d, %r11d
movl %r9d, %ebx
movl %edx, %ebp
cmpl %eax, %ebx
jge 0x7ef3
movl %ebp, %r14d
andl $0x1, %r14d
leal (%r14,%r11,2), %r11d
shrl %ebp
addl %ebx, %ebx
jmp 0x7ede
jne 0x80bd
movslq %r11d, %rbx
cmpq %rbx, %rdx
jge 0x7f3e
imull 0x8(%rsp), %r11d
movslq %r11d, %r11
shlq $0x4, %r11
addq 0x18(%rsp), %r11
xorl %ebx, %ebx
cmpq %rbx, %r8
je 0x7f3e
movups (%r10,%rbx), %xmm0
movaps %xmm0, 0x70(%rsp)
movups (%r11,%rbx), %xmm0
movups %xmm0, (%r10,%rbx)
movaps 0x70(%rsp), %xmm0
movups %xmm0, (%r11,%rbx)
addq $0x10, %rbx
jmp 0x7f15
incq %rdx
addq 0x20(%rsp), %r10
jmp 0x7ed1
negl %r15d
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x28(%rsp)
movslq %esi, %r13
movl %r12d, %r14d
shlq $0x4, %r14
pushq $0x1
popq %rsi
movl %eax, 0xc(%rsp)
cmpl %eax, %esi
jge 0x80ab
leal (%rsi,%rsi), %eax
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %edx
imull %edx, %eax
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x38(%rsp)
movl %esi, %ecx
imull %edx, %ecx
movslq %eax, %rbx
movslq %ecx, %rbp
xorl %edi, %edi
testl %esi, %esi
cmovlel %edi, %esi
movq %rbx, %r15
shlq $0x4, %r15
shlq $0x4, %rbp
xorpd %xmm0, %xmm0
movq 0x18(%rsp), %r12
xorl %eax, %eax
movq %rsi, 0x40(%rsp)
cmpl %esi, %eax
je 0x809c
movl %eax, 0x14(%rsp)
movsd %xmm0, 0x58(%rsp)
mulsd 0x36e2(%rip), %xmm0     # 0xb6b0
divsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movq %rdi, 0x50(%rsp)
callq 0x23a0
movapd %xmm0, 0x60(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x2080
movapd 0x60(%rsp), %xmm3
movq 0x50(%rsp), %rdi
mulsd 0x28(%rsp), %xmm0
movapd %xmm0, %xmm1
xorpd 0x347e(%rip), %xmm1     # 0xb490
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movq %r12, %rax
movq %rdi, %rcx
cmpq %r13, %rcx
jge 0x8074
leaq (%rax,%rbp), %rdx
xorl %esi, %esi
cmpq %rsi, %r14
je 0x806c
movupd (%rdx,%rsi), %xmm1
movapd %xmm1, %xmm2
mulpd %xmm0, %xmm2
shufpd $0x1, %xmm2, %xmm2      # xmm2 = xmm2[1,0]
mulpd %xmm3, %xmm1
addpd %xmm2, %xmm1
movupd (%rax,%rsi), %xmm2
subpd %xmm1, %xmm2
movupd %xmm2, (%rdx,%rsi)
movupd (%rax,%rsi), %xmm2
addpd %xmm1, %xmm2
movupd %xmm2, (%rax,%rsi)
addq $0x10, %rsi
jmp 0x802b
addq %rbx, %rcx
addq %r15, %rax
jmp 0x8020
addq 0x30(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
addsd 0x2fc9(%rip), %xmm0     # 0xb050
movl 0x14(%rsp), %eax
incl %eax
addq 0x20(%rsp), %r12
movq 0x40(%rsp), %rsi
jmp 0x7fb4
movl 0x10(%rsp), %eax
movl %eax, %esi
movl 0xc(%rsp), %eax
jmp 0x7f67
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x364a(%rip), %rdi      # 0xb70e
leaq 0x35f8(%rip), %rsi      # 0xb6c3
leaq 0x3644(%rip), %rcx      # 0xb716
movl $0x8c, %edx
callq 0x20e0