// File: /workspace/github_c_makefile_star2_O2/diaxen[P]fft-garden/sr_dit_bi_G_L_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, is = 0; is < N; is += 2)
    {
      unsigned i0 = sr_input_lut[is / 2];

      if (sr_sched_off[j] * 2 > is)
        {
          out[is    ] = in[i0];
          out[is + 1] = in[i0 + N / 2];
        }
      else
        {
          ct_dit_bf2_0(1, N / 2, out + is, in + i0);
          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;
          sr_dit_bf4_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;

          sr_dit_bf4_0(2, out + o);
          sr_dit_bf4_pi4(2, out + o + 1);
        }
    }

  /* stage >= 3 */
  if (log2_N > 3)
    for (unsigned k = 3; k < log2_N; k++)
      {
        unsigned t = log2_N - k - 1;
        unsigned n2 = 1 << (k - 1);
        unsigned n4 = 1 << (k - 2);

        unsigned c = sr_sched_cnt[k];
        for (unsigned i = 0; i < c; i++)
          {
            unsigned o = sr_sched_off[i] << (k + 1);

            sr_dit_bf4_0(n2, out + o);
            sr_dit_bf4_pi4(n2, out + o + n4);
          }

        for (unsigned j0 = 1; j0 < n4; j0++)
          {
            complex double w1 = get_twiddle(j0 << t, log2_N);
            complex double w3 = get_twiddle_sr(j0 << t, log2_N);

            unsigned c = sr_sched_cnt[k];
            for (unsigned i = 0; i < c; i++)
              {
                unsigned o = sr_sched_off[i] << (k + 1);

                sr_dit_bf4(n2, out + o + j0, w1, w3);
                sr_dit_bf4(n2, out + o + n2 - j0, conj(w1 * I), -conj(w3 * I));
              }
          }
      }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
bsrl %edi, %ebp
xorl $0x1f, %ebp
leaq 0x36d6(%rip), %rax      # 0x5098
movq (%rax), %rax
leaq 0x36dc(%rip), %rcx      # 0x50a8
movq (%rcx), %r15
movl %edi, %ecx
shrl %edi
movq %rsi, 0x10(%rsp)
addq $0x10, %rsi
xorl %r8d, %r8d
movq %rdi, %r9
shlq $0x4, %r9
xorl %r10d, %r10d
cmpq %rcx, %r8
jae 0x1a58
movl (%rax,%r8,2), %r11d
movl %r10d, %ebx
movl (%r15,%rbx,4), %ebx
addl %ebx, %ebx
cmpq %rbx, %r8
jae 0x1a22
movq %r11, %rbx
shlq $0x4, %rbx
movups (%rdx,%rbx), %xmm0
movups %xmm0, -0x10(%rsi)
addl %edi, %r11d
shlq $0x4, %r11
movupd (%rdx,%r11), %xmm0
movupd %xmm0, (%rsi)
jmp 0x1a4e
shlq $0x4, %r11
leaq (%rdx,%r11), %rbx
movupd (%rdx,%r11), %xmm0
movupd (%r9,%rbx), %xmm1
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movupd %xmm2, -0x10(%rsi)
subpd %xmm1, %xmm0
movupd %xmm0, (%rsi)
incl %r10d
addq $0x2, %r8
addq $0x20, %rsi
jmp 0x19e9
movl %ebp, %eax
xorl $0x1f, %eax
movl %eax, 0x8(%rsp)
cmpl $0x1, %eax
jbe 0x1dd0
leaq 0x362f(%rip), %rax      # 0x50a0
movq (%rax), %rbx
movl 0x4(%rbx), %r14d
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x1a9d
movl (%r15,%r12,4), %esi
shll $0x2, %esi
shlq $0x4, %rsi
addq 0x10(%rsp), %rsi
pushq $0x1
popq %rdi
callq 0x1de2
incq %r12
jmp 0x1a7b
cmpl $0x1d, %ebp
je 0x1dd0
movl 0x8(%rbx), %ebx
xorl %r12d, %r12d
pushq $0x2
popq %r14
movq 0x10(%rsp), %rbp
cmpq %r12, %rbx
je 0x1aec
movl (%r15,%r12,4), %r13d
shll $0x3, %r13d
shlq $0x4, %r13
movq %rbp, %rsi
addq %r13, %rsi
movl %r14d, %edi
callq 0x1de2
leaq 0x10(,%r13), %rsi
addq %rbp, %rsi
movl %r14d, %edi
callq 0x1e53
incq %r12
jmp 0x1ab5
cmpl $0x4, 0x8(%rsp)
jb 0x1dd0
movl 0x8(%rsp), %eax
movq %rax, 0x68(%rsp)
pushq $0x3
popq %rdx
cmpq 0x68(%rsp), %rdx
je 0x1dd0
leal -0x1(%rdx), %ecx
pushq $0x1
popq %rax
movl %eax, %r14d
shll %cl, %r14d
movl %edx, %esi
leal -0x2(%rdx), %ecx
movl %eax, %r12d
shll %cl, %r12d
notl %esi
movl %esi, 0xc(%rsp)
leaq 0x356e(%rip), %rax      # 0x50a0
movq (%rax), %rax
movl (%rax,%rdx,4), %ebx
leaq 0x3569(%rip), %rax      # 0x50a8
movq (%rax), %r15
movq %rdx, 0x78(%rsp)
leaq 0x1(%rdx), %rax
movq %rax, 0x18(%rsp)
movq %r12, 0x80(%rsp)
shlq $0x4, %r12
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x1b96
movl (%r15,%rbp,4), %r13d
movq 0x18(%rsp), %rcx
shll %cl, %r13d
shlq $0x4, %r13
addq 0x10(%rsp), %r13
movl %r14d, %edi
movq %r13, %rsi
callq 0x1de2
addq %r12, %r13
movl %r14d, %edi
movq %r13, %rsi
callq 0x1e53
incq %rbp
jmp 0x1b5e
movl 0xc(%rsp), %eax
addl 0x8(%rsp), %eax
movl %eax, 0xc(%rsp)
movl %r14d, %eax
shlq $0x4, %rax
movq %rax, 0x70(%rsp)
pushq $0x1
popq %rbx
cmpq 0x80(%rsp), %rbx
jae 0x1dc6
movl %ebx, %eax
movl 0xc(%rsp), %ecx
shll %cl, %eax
leaq 0x34b2(%rip), %rcx      # 0x5080
movq (%rcx), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm1
movsd 0x8(%rcx,%rax), %xmm2
leaq 0x34a1(%rip), %rcx      # 0x5088
movq (%rcx), %rcx
movsd (%rcx,%rax), %xmm3
movsd 0x8(%rcx,%rax), %xmm4
leaq 0x34a4(%rip), %rax      # 0x50a0
movq (%rax), %rax
movq 0x78(%rsp), %rcx
movl (%rax,%rcx,4), %r15d
movq %rbx, %rbp
negq %rbp
movapd %xmm1, %xmm5
xorpd %xmm0, %xmm0
mulsd %xmm0, %xmm5
movapd %xmm2, %xmm6
mulsd %xmm0, %xmm6
movsd %xmm2, 0x30(%rsp)
subsd %xmm2, %xmm5
movsd %xmm5, 0x58(%rsp)
movsd %xmm1, 0x38(%rsp)
addsd %xmm1, %xmm6
movsd %xmm6, 0x50(%rsp)
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm4, %xmm2
mulsd %xmm0, %xmm2
movsd %xmm4, 0x20(%rsp)
subsd %xmm4, %xmm1
movsd %xmm1, 0x48(%rsp)
movsd %xmm3, 0x28(%rsp)
addsd %xmm3, %xmm2
movsd %xmm2, 0x40(%rsp)
movq %rbx, 0x88(%rsp)
shlq $0x4, %rbx
shlq $0x4, %rbp
addq 0x70(%rsp), %rbp
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x1db6
leaq 0x340e(%rip), %rax      # 0x50a8
movq (%rax), %rax
movl (%rax,%r12,4), %r13d
movq 0x18(%rsp), %rcx
shll %cl, %r13d
shlq $0x4, %r13
addq 0x10(%rsp), %r13
leaq (%rbx,%r13), %rsi
movl %r14d, %edi
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x20(%rsp), %xmm3
callq 0x1f45
movsd 0x58(%rsp), %xmm4
ucomisd %xmm4, %xmm4
movsd 0x50(%rsp), %xmm1
jp 0x1d24
movsd 0x48(%rsp), %xmm2
ucomisd %xmm2, %xmm2
movsd 0x40(%rsp), %xmm3
jp 0x1d5c
addq %rbp, %r13
movapd 0x132b(%rip), %xmm0     # 0x3030
xorpd %xmm0, %xmm1
xorpd %xmm0, %xmm2
movl %r14d, %edi
movq %r13, %rsi
movapd %xmm4, %xmm0
callq 0x1f45
incq %r12
jmp 0x1c8a
movsd 0x50(%rsp), %xmm0
ucomisd %xmm0, %xmm0
movsd 0x58(%rsp), %xmm4
movapd %xmm0, %xmm1
jnp 0x1ce8
xorps %xmm2, %xmm2
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x14ff(%rip), %xmm3     # 0x3250
callq 0x2980
movapd %xmm0, %xmm4
jmp 0x1ce8
movsd 0x40(%rsp), %xmm3
ucomisd %xmm3, %xmm3
movsd 0x48(%rsp), %xmm2
jnp 0x1cfa
xorpd %xmm2, %xmm2
movsd 0x28(%rsp), %xmm0
movapd %xmm1, 0x90(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x14c1(%rip), %xmm3     # 0x3250
movsd %xmm4, 0x60(%rsp)
callq 0x2980
movsd 0x60(%rsp), %xmm4
movapd %xmm0, %xmm2
movapd %xmm1, %xmm3
movapd 0x90(%rsp), %xmm1
jmp 0x1cfa
movq 0x88(%rsp), %rbx
incq %rbx
jmp 0x1bb1
movq 0x18(%rsp), %rdx
jmp 0x1b03
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq