// File: /workspace/github_c_makefile_star2_O3/diaxen[P]fft-garden/cp_dit_bi_S_P.c
// Function: fft
void
fft(unsigned N, complex double * restrict out,
    const complex double * restrict in)
{
  unsigned log2_N = 31 - clz32(N);

  /* stage 0 */
  for (unsigned j = 0, i = 0; i < N; i += 2)
    {
      unsigned i0 = cp_input_lut[i / 2];
      unsigned i1 = i0 ^ (N >> 1);

      if (sr_sched_off[j] * 2 > i)
        {
          out[i    ] = in[i0];
          out[i + 1] = in[i1];
        }
      else
        {
          complex double a = in[i0];
          complex double b = in[i1];
          out[i    ] = a + b;
          out[i + 1] = a - b;
          j++;
        }
    }

  /* stage 1 */
  if (log2_N > 1)
    {
      unsigned c = sr_sched_cnt[1];
      for (unsigned i = 0; i < c; i++)
        {
          unsigned o = sr_sched_off[i] << 2;
          cp_dit_bf_0(1, out + o);
        }
    }

  /* stage 2 */
  if (log2_N > 2)
    {
      unsigned c = sr_sched_cnt[2];
      for (unsigned i = 0; i < c; i++)
        {
          unsigned o = sr_sched_off[i] << 3;

          cp_dit_bf_pi4(2, out + o + 1);
          cp_dit_bf_0(2, out + o);
        }
    }

  /* stage >= 3 */
  if (log2_N > 3)
    for (unsigned s = 3; s < log2_N; s++)
      {
        unsigned c = sr_sched_cnt[s];
        for (unsigned i = 0; i < c; i++)
          {
            unsigned o = sr_sched_off[i] << (s + 1);
            unsigned t = log2_N - s - 1;
            unsigned os = 1 << (s - 1);
            unsigned k;

            unsigned m = os / 2;
            cp_dit_bf_0(os, out + o);
            cp_dit_bf_pi4(os, out + o + m);
            for (k = 1; k < m; k++)
              {
                complex double w = get_twiddle(k << t, log2_N);
                cp_dit_bf(os, out + o + k, w);
                cp_dit_bf(os, out + o + os - k, -I * conj(w));
              }
          }
      }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
bsrl %edi, %eax
movl %eax, 0x4(%rsp)
je 0x1aba
leaq 0x365f(%rip), %rax      # 0x5090
movq (%rax), %rax
leaq 0x366d(%rip), %rcx      # 0x50a8
movq (%rcx), %rcx
movl %edi, %r15d
shrl %edi
leaq 0x10(%rsi), %r8
xorl %r9d, %r9d
xorl %r10d, %r10d
movl (%rax,%r9,2), %r11d
movl %r11d, %ebx
xorl %edi, %ebx
movl %r10d, %r14d
movl (%rcx,%r14,4), %r14d
addl %r14d, %r14d
shlq $0x4, %r11
movupd (%rdx,%r11), %xmm0
movl %ebx, %r11d
cmpq %r14, %r9
jae 0x1a89
movupd %xmm0, -0x10(%r8)
shlq $0x4, %r11
movupd (%rdx,%r11), %xmm0
movupd %xmm0, (%r8)
jmp 0x1aad
shlq $0x4, %r11
movupd (%rdx,%r11), %xmm1
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movupd %xmm2, -0x10(%r8)
subpd %xmm1, %xmm0
movupd %xmm0, (%r8)
incl %r10d
addq $0x2, %r9
addq $0x20, %r8
cmpq %r15, %r9
jb 0x1a4d
cmpl $0x1, 0x4(%rsp)
jbe 0x1f9c
movl 0x4(%rsp), %ecx
xorl $0x1f, %ecx
leaq 0x35cd(%rip), %rax      # 0x50a0
movq (%rax), %rax
movl 0x4(%rax), %edx
testq %rdx, %rdx
je 0x1b6e
leaq 0x35bf(%rip), %rdi      # 0x50a8
movq (%rdi), %r9
xorl %edi, %edi
movl (%r9,%rdi,4), %r8d
shll $0x2, %r8d
shlq $0x4, %r8
movupd (%rsi,%r8), %xmm0
movupd 0x10(%rsi,%r8), %xmm1
movupd 0x20(%rsi,%r8), %xmm2
movupd 0x30(%rsi,%r8), %xmm3
movapd %xmm2, %xmm4
addpd %xmm3, %xmm4
movapd %xmm0, %xmm5
addpd %xmm4, %xmm5
movupd %xmm5, (%rsi,%r8)
subpd %xmm3, %xmm2
shufpd $0x1, %xmm2, %xmm2      # xmm2 = xmm2[1,0]
movapd %xmm1, %xmm3
addpd %xmm2, %xmm3
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
movsd %xmm3, %xmm2            # xmm2 = xmm3[0],xmm2[1]
movupd %xmm2, 0x10(%rsi,%r8)
subpd %xmm4, %xmm0
movupd %xmm0, 0x20(%rsi,%r8)
shufpd $0x2, %xmm3, %xmm1      # xmm1 = xmm1[0],xmm3[1]
movupd %xmm1, 0x30(%rsi,%r8)
incq %rdi
cmpq %rdi, %rdx
jne 0x1aee
cmpl $0x1d, %ecx
je 0x1f9c
movl 0x8(%rax), %eax
testq %rax, %rax
je 0x1cb3
leaq 0x351e(%rip), %rcx      # 0x50a8
movq (%rcx), %rcx
xorl %edx, %edx
movapd 0x16b9(%rip), %xmm0     # 0x3250
movl (%rcx,%rdx,4), %edi
shll $0x3, %edi
shlq $0x4, %rdi
movsd 0x50(%rsi,%rdi), %xmm1
movhpd 0x70(%rsi,%rdi), %xmm1  # xmm1 = xmm1[0],mem[0]
movsd 0x58(%rsi,%rdi), %xmm3
movhpd 0x78(%rsi,%rdi), %xmm3  # xmm3 = xmm3[0],mem[0]
mulpd %xmm0, %xmm1
mulpd %xmm0, %xmm3
movapd %xmm1, %xmm4
shufpd $0x1, %xmm3, %xmm4      # xmm4 = xmm4[1],xmm3[0]
movapd %xmm3, %xmm2
shufpd $0x1, %xmm1, %xmm2      # xmm2 = xmm2[1],xmm1[0]
subpd %xmm2, %xmm4
addpd %xmm1, %xmm3
movapd %xmm3, %xmm5
movupd (%rsi,%rdi), %xmm1
movupd 0x10(%rsi,%rdi), %xmm6
addpd %xmm4, %xmm5
movupd 0x20(%rsi,%rdi), %xmm2
movupd 0x30(%rsi,%rdi), %xmm7
movapd %xmm4, %xmm8
shufpd $0x1, %xmm3, %xmm8      # xmm8 = xmm8[1],xmm3[0]
shufpd $0x1, %xmm4, %xmm3      # xmm3 = xmm3[1],xmm4[0]
movapd %xmm6, %xmm4
subpd %xmm3, %xmm8
addpd %xmm5, %xmm4
movapd %xmm7, %xmm3
addpd %xmm8, %xmm3
subpd %xmm8, %xmm7
movupd %xmm4, 0x10(%rsi,%rdi)
movapd %xmm7, %xmm4
movsd %xmm3, %xmm4            # xmm4 = xmm3[0],xmm4[1]
subpd %xmm5, %xmm6
movupd %xmm4, 0x30(%rsi,%rdi)
movupd %xmm6, 0x50(%rsi,%rdi)
shufpd $0x2, %xmm3, %xmm7      # xmm7 = xmm7[0],xmm3[1]
movupd %xmm7, 0x70(%rsi,%rdi)
movupd 0x40(%rsi,%rdi), %xmm3
movupd 0x60(%rsi,%rdi), %xmm4
movapd %xmm3, %xmm5
movapd %xmm1, %xmm6
addpd %xmm4, %xmm5
addpd %xmm5, %xmm6
subpd %xmm4, %xmm3
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
movupd %xmm6, (%rsi,%rdi)
movapd %xmm2, %xmm4
addpd %xmm3, %xmm4
subpd %xmm3, %xmm2
movapd %xmm2, %xmm3
movsd %xmm4, %xmm3            # xmm3 = xmm4[0],xmm3[1]
movupd %xmm3, 0x20(%rsi,%rdi)
subpd %xmm5, %xmm1
movupd %xmm1, 0x40(%rsi,%rdi)
shufpd $0x2, %xmm4, %xmm2      # xmm2 = xmm2[0],xmm4[1]
movupd %xmm2, 0x60(%rsi,%rdi)
incq %rdx
cmpq %rdx, %rax
jne 0x1b97
cmpl $0x4, 0x4(%rsp)
jb 0x1f9c
movl 0x4(%rsp), %eax
movq %rax, 0x18(%rsp)
leaq 0x10(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq -0x10(%rsi), %rax
movq %rax, 0x10(%rsp)
movl $0x3, %ecx
movq %rsi, 0x28(%rsp)
leaq 0x33b6(%rip), %rax      # 0x50a0
movq (%rax), %rax
movl (%rax,%rcx,4), %edx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rsp)
movq %rdx, 0x58(%rsp)
testq %rdx, %rdx
je 0x1f89
movl %ecx, %ebp
notl %ebp
addl 0x4(%rsp), %ebp
decb %cl
movl $0x1, %r15d
shll %cl, %r15d
movl %r15d, %edx
shrl %edx
movl $0x2, %edi
shll %cl, %edi
movl $0x3, %r8d
shll %cl, %r8d
cmpl $0x3, %edx
movl %edx, %ebx
movl $0x2, %eax
cmovbl %eax, %ebx
movq %r15, %rcx
shlq $0x4, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x38(%rsp)
addq %rcx, %rax
movq %rax, 0x30(%rsp)
shlq $0x4, %rdi
movq %rdi, 0x48(%rsp)
shlq $0x4, %r8
movq %r8, 0x40(%rsp)
shlq $0x4, %rdx
movq %rdx, 0x50(%rsp)
xorl %ecx, %ecx
leaq 0x332f(%rip), %rax      # 0x50a8
movq (%rax), %rax
movq %rcx, 0x60(%rsp)
movl (%rax,%rcx,4), %r12d
movq 0x8(%rsp), %rcx
shll %cl, %r12d
shlq $0x4, %r12
leaq (%rsi,%r12), %rax
movupd (%rsi,%r12), %xmm0
movq 0x48(%rsp), %rdi
movupd (%rdi,%rax), %xmm1
movq 0x40(%rsp), %r8
movupd (%r8,%rax), %xmm2
movapd %xmm1, %xmm3
addpd %xmm2, %xmm3
movapd %xmm0, %xmm4
addpd %xmm3, %xmm4
movupd %xmm4, (%rsi,%r12)
movq 0x38(%rsp), %rsi
movupd (%rsi,%rax), %xmm4
subpd %xmm2, %xmm1
shufpd $0x1, %xmm1, %xmm1      # xmm1 = xmm1[1,0]
movapd %xmm4, %xmm2
addpd %xmm1, %xmm2
subpd %xmm1, %xmm4
movapd %xmm4, %xmm1
movsd %xmm2, %xmm1            # xmm1 = xmm2[0],xmm1[1]
movupd %xmm1, (%rsi,%rax)
subpd %xmm3, %xmm0
movupd %xmm0, (%rdi,%rax)
shufpd $0x2, %xmm2, %xmm4      # xmm4 = xmm4[0],xmm2[1]
movupd %xmm4, (%r8,%rax)
movq 0x50(%rsp), %rdx
leaq (%rax,%rdx), %rcx
movupd (%rdx,%rax), %xmm0
movsd (%rdi,%rcx), %xmm1
movsd 0x8(%rdi,%rcx), %xmm2
movhpd (%r8,%rcx), %xmm1       # xmm1 = xmm1[0],mem[0]
movapd 0x1423(%rip), %xmm3     # 0x3250
mulpd %xmm3, %xmm1
movhpd 0x8(%r8,%rcx), %xmm2    # xmm2 = xmm2[0],mem[0]
mulpd %xmm3, %xmm2
movapd %xmm1, %xmm3
shufpd $0x1, %xmm2, %xmm3      # xmm3 = xmm3[1],xmm2[0]
movapd %xmm2, %xmm4
shufpd $0x1, %xmm1, %xmm4      # xmm4 = xmm4[1],xmm1[0]
subpd %xmm4, %xmm3
addpd %xmm1, %xmm2
movapd %xmm2, %xmm1
addpd %xmm3, %xmm1
movapd %xmm0, %xmm4
addpd %xmm1, %xmm4
movupd %xmm4, (%rdx,%rax)
movupd (%rsi,%rcx), %xmm4
movapd %xmm3, %xmm5
shufpd $0x1, %xmm2, %xmm5      # xmm5 = xmm5[1],xmm2[0]
shufpd $0x1, %xmm3, %xmm2      # xmm2 = xmm2[1],xmm3[0]
subpd %xmm2, %xmm5
movapd %xmm4, %xmm2
addpd %xmm5, %xmm2
subpd %xmm5, %xmm4
movapd %xmm4, %xmm3
movsd %xmm2, %xmm3            # xmm3 = xmm2[0],xmm3[1]
movupd %xmm3, (%rsi,%rcx)
subpd %xmm1, %xmm0
movupd %xmm0, (%rdi,%rcx)
shufpd $0x2, %xmm2, %xmm4      # xmm4 = xmm4[0],xmm2[1]
movupd %xmm4, (%r8,%rcx)
movq 0x20(%rsp), %rax
leaq (%rax,%r12), %r13
addq 0x30(%rsp), %r12
movl $0x1, %r14d
movl %r14d, %eax
movl %ebp, %ecx
shll %cl, %eax
leaq 0x31af(%rip), %rcx      # 0x5080
movq (%rcx), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x8(%rcx,%rax), %xmm1
movaps %xmm1, 0x70(%rsp)
movl %r15d, %edi
movq %r13, %rsi
callq 0x1fae
movapd 0x70(%rsp), %xmm3
movsd 0x68(%rsp), %xmm2
movapd %xmm2, %xmm0
mulsd 0x115f(%rip), %xmm0     # 0x3070
movapd %xmm3, %xmm1
mulsd 0x10fb(%rip), %xmm1     # 0x3018
subsd %xmm3, %xmm0
subsd %xmm2, %xmm1
ucomisd %xmm0, %xmm0
jp 0x1f4c
movl %r15d, %edi
movq %r12, %rsi
callq 0x1fae
incq %r14
addq $0x10, %r13
addq $-0x10, %r12
cmpq %r14, %rbx
jne 0x1ec3
jmp 0x1f71
ucomisd %xmm1, %xmm1
jnp 0x1f2b
xorpd 0x10d6(%rip), %xmm3     # 0x3030
movsd 0x110e(%rip), %xmm0     # 0x3070
movsd 0x12f6(%rip), %xmm1     # 0x3260
callq 0x2940
jmp 0x1f2b
movq 0x60(%rsp), %rcx
incq %rcx
cmpq 0x58(%rsp), %rcx
movq 0x28(%rsp), %rsi
jne 0x1d72
movq 0x8(%rsp), %rax
movq %rax, %rcx
cmpq 0x18(%rsp), %rax
jne 0x1ce3
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq