// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movl %esi, 0x7c(%rsp)
movl %edx, 0x78(%rsp)
movl %ecx, 0x74(%rsp)
movq %r8, 0x68(%rsp)
movl $0x0, 0x30(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x7c(%rsp), %eax
sarl %eax
movl %eax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movl $0x1, 0x44(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x74(%rsp), %eax
jl 0x17bd8
movq 0x80(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x30(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x44(%rsp), %eax
jge 0x17bbf
cvtsi2sdl 0x50(%rsp), %xmm1
movsd 0x4e2a(%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 0x50(%rsp), %xmm1
movsd 0x4df3(%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 0x50(%rsp), %eax
movl 0x40(%rsp), %ecx
addl 0x40(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl 0x3c(%rsp), %ecx
addl 0x40(%rsp), %ecx
cmpl %ecx, %eax
jge 0x17bad
movl 0x4c(%rsp), %eax
addl 0x40(%rsp), %eax
movl %eax, 0x48(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movsd 0x20(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x48(%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 0x68(%rsp), %rax
movslq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
movsd 0x20(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
addsd 0x18(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x34(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
addsd 0x10(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x34(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
subsd 0x10(%rsp), %xmm0
movq 0x80(%rsp), %rax
movslq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x179f6
jmp 0x17baf
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x17962
movl 0x40(%rsp), %eax
sarl %eax
movl %eax, 0x40(%rsp)
movl 0x44(%rsp), %eax
shll %eax
movl %eax, 0x44(%rsp)
jmp 0x17918
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0x17c38
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x7c(%rsp), %eax
jge 0x17c36
movq 0x80(%rsp), %rcx
movslq 0x54(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rcx
movq 0x68(%rsp), %rax
movslq 0x54(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x17bec
jmp 0x17c38
movl 0x44(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x7c(%rsp), %eax
cltd
idivl 0x74(%rsp)
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jne 0x17c55
jmp 0x17c74
leaq 0x4b54(%rip), %rdi      # 0x1c7b0
leaq 0x4b58(%rip), %rsi      # 0x1c7bb
movl $0x72, %edx
leaq 0x4b52(%rip), %rcx      # 0x1c7c1
callq 0x83a0
movb $0x1, %al
movl $0x1, %ecx
cmpl 0x7c(%rsp), %ecx
movb %al, 0x3(%rsp)
je 0x17c94
movl 0x30(%rsp), %eax
cmpl 0x7c(%rsp), %eax
sete %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
testb $0x1, %al
jne 0x17c9e
jmp 0x17ca0
jmp 0x17cbf
leaq 0x4b4d(%rip), %rdi      # 0x1c7f4
leaq 0x4b0d(%rip), %rsi      # 0x1c7bb
movl $0x73, %edx
leaq 0x4b07(%rip), %rcx      # 0x1c7c1
callq 0x83a0
addq $0x88, %rsp
retq
nopw (%rax,%rax)