// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movl %esi, 0x7c(%rsp)
movl %edx, 0x78(%rsp)
movl %ecx, 0x74(%rsp)
movl 0x7c(%rsp), %eax
cltd
idivl 0x74(%rsp)
movl %eax, 0x48(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x17e77
movl $0x0, 0x58(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0x50(%rsp)
movl $0x1, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x17d59
movl 0x58(%rsp), %eax
shll %eax
movl 0x50(%rsp), %ecx
andl $0x1, %ecx
addl %ecx, %eax
movl %eax, 0x58(%rsp)
movl 0x50(%rsp), %eax
sarl %eax
movl %eax, 0x50(%rsp)
movl 0x4c(%rsp), %eax
shll %eax
movl %eax, 0x4c(%rsp)
jmp 0x17d26
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jne 0x17d65
jmp 0x17d84
leaq 0x4a9a(%rip), %rdi      # 0x1c806
leaq 0x4a48(%rip), %rsi      # 0x1c7bb
movl $0x8c, %edx
leaq 0x4a8f(%rip), %rcx      # 0x1c80e
callq 0x83a0
movl 0x58(%rsp), %eax
cmpl 0x54(%rsp), %eax
jle 0x17e65
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x74(%rsp), %eax
jge 0x17e63
movq 0x80(%rsp), %rax
movl 0x54(%rsp), %ecx
imull 0x74(%rsp), %ecx
addl 0x5c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, 0x60(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x80(%rsp), %rcx
movl 0x58(%rsp), %eax
imull 0x74(%rsp), %eax
addl 0x5c(%rsp), %eax
cltq
shlq $0x4, %rax
addq %rax, %rcx
movq 0x80(%rsp), %rax
movl 0x54(%rsp), %edx
imull 0x74(%rsp), %edx
addl 0x5c(%rsp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq 0x80(%rsp), %rax
movl 0x58(%rsp), %ecx
imull 0x74(%rsp), %ecx
addl 0x5c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x60(%rsp), %rcx
movq %rcx, (%rax)
movq 0x68(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x17d9a
jmp 0x17e65
jmp 0x17e67
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x17d00
movl $0x1, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x18131
movl 0x4c(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x4c(%rsp), %eax
shll %eax
movl %eax, 0x4c(%rsp)
movl $0x0, 0x38(%rsp)
movl 0x4c(%rsp), %eax
imull 0x74(%rsp), %eax
movl %eax, 0x34(%rsp)
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0x1812c
cvtsi2sdl 0x58(%rsp), %xmm1
movsd 0x48d0(%rip), %xmm0     # 0x1c7a8
mulsd %xmm1, %xmm0
cvtsi2sdl 0x44(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x8ca0
movsd %xmm0, 0x28(%rsp)
xorl %eax, %eax
subl 0x78(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sdl 0x58(%rsp), %xmm1
movsd 0x4899(%rip), %xmm0     # 0x1c7a8
mulsd %xmm1, %xmm0
cvtsi2sdl 0x44(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x8150
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x7c(%rsp), %eax
jge 0x18110
movl 0x54(%rsp), %eax
movl 0x44(%rsp), %ecx
imull 0x74(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x40(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x74(%rsp), %eax
jge 0x180fd
movl 0x54(%rsp), %eax
addl 0x5c(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x40(%rsp), %eax
addl 0x5c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movsd 0x20(%rsp), %xmm1
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
movsd 0x20(%rsp), %xmm1
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x80(%rsp), %rax
movslq 0x50(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x80(%rsp), %rax
movslq 0x50(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
subsd 0x10(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x3c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movsd 0x18(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x50(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x50(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x17f66
jmp 0x180ff
movl 0x34(%rsp), %eax
addl 0x54(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x17f3d
movl 0x74(%rsp), %eax
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x17ebc
jmp 0x17e7f
addq $0x88, %rsp
retq
nopl (%rax)