// File: /workspace/github_c_makefile_star2_O2/diaxen[P]fft-garden/sr_dit_bi_G_L_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);
              }

            unsigned j1 = j0 + n4;
            w1 = get_twiddle(j1 << t, log2_N);
	    w3 = get_twiddle_sr(j1 << t, log2_N);

            for (unsigned i = 0; i < c; i++)
              {
                unsigned o = sr_sched_off[i] << (k + 1);
                sr_dit_bf4(n2, out + o + j1, w1, w3);
              }
	  }
      }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
bsrl %edi, %ebp
xorl $0x1f, %ebp
leaq 0x37dd(%rip), %rax      # 0x5098
movq (%rax), %rax
leaq 0x37e3(%rip), %rbx      # 0x50a8
movq (%rbx), %r14
movl %edi, %ecx
shrl %edi
movq %rsi, 0x18(%rsp)
addq $0x10, %rsi
xorl %r8d, %r8d
movq %rdi, %r9
shlq $0x4, %r9
xorl %r10d, %r10d
cmpq %rcx, %r8
jae 0x1953
movl (%rax,%r8,2), %r11d
movl %r10d, %r15d
movl (%r14,%r15,4), %r15d
addl %r15d, %r15d
cmpq %r15, %r8
jae 0x191d
movq %r11, %r15
shlq $0x4, %r15
movups (%rdx,%r15), %xmm0
movups %xmm0, -0x10(%rsi)
addl %edi, %r11d
shlq $0x4, %r11
movupd (%rdx,%r11), %xmm0
movupd %xmm0, (%rsi)
jmp 0x1949
shlq $0x4, %r11
leaq (%rdx,%r11), %r15
movupd (%rdx,%r11), %xmm0
movupd (%r9,%r15), %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 0x18e2
movl %ebp, %eax
xorl $0x1f, %eax
movl %eax, 0x8(%rsp)
cmpl $0x1, %eax
jbe 0x1beb
leaq 0x3734(%rip), %rax      # 0x50a0
movq (%rax), %r15
movl 0x4(%r15), %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x1998
movl (%r14,%r13,4), %esi
shll $0x2, %esi
shlq $0x4, %rsi
addq 0x18(%rsp), %rsi
pushq $0x1
popq %rdi
callq 0x1bfa
incq %r13
jmp 0x1976
cmpl $0x1d, %ebp
je 0x1beb
movl 0x8(%r15), %eax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
pushq $0x2
popq %r15
movq 0x18(%rsp), %r12
cmpq %r13, 0x10(%rsp)
je 0x19e9
movl (%r14,%r13,4), %ebp
shll $0x3, %ebp
shlq $0x4, %rbp
leaq (%r12,%rbp), %rsi
movl %r15d, %edi
callq 0x1bfa
leaq (%r12,%rbp), %rsi
addq $0x10, %rsi
movl %r15d, %edi
callq 0x1c6b
incq %r13
jmp 0x19b6
cmpl $0x4, 0x8(%rsp)
jb 0x1beb
movl 0x8(%rsp), %eax
movq %rax, 0x48(%rsp)
pushq $0x3
popq %r13
cmpq 0x48(%rsp), %r13
je 0x1beb
movl %r13d, %edx
leal -0x1(%r13), %ecx
pushq $0x1
popq %rax
movl %eax, %r12d
shll %cl, %r12d
notl %edx
movl %edx, 0xc(%rsp)
leal -0x2(%r13), %ecx
shll %cl, %eax
movq %rax, 0x20(%rsp)
leaq 0x366c(%rip), %rax      # 0x50a0
movq (%rax), %rax
movl (%rax,%r13,4), %r15d
movq (%rbx), %rax
movq %rax, 0x10(%rsp)
movq %r13, 0x50(%rsp)
incq %r13
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x1a8e
movq 0x10(%rsp), %rax
movl (%rax,%rbp,4), %r14d
movl %r13d, %ecx
shll %cl, %r14d
shlq $0x4, %r14
addq 0x18(%rsp), %r14
movl %r12d, %edi
movq %r14, %rsi
callq 0x1bfa
movq 0x20(%rsp), %rsi
shlq $0x4, %rsi
addq %r14, %rsi
movl %r12d, %edi
callq 0x1c6b
incq %rbp
jmp 0x1a4d
movl 0xc(%rsp), %eax
addl 0x8(%rsp), %eax
movl %eax, 0xc(%rsp)
pushq $0x1
popq %rax
cmpq 0x20(%rsp), %rax
jae 0x1a01
movq %rax, 0x28(%rsp)
movl %eax, %r14d
movl 0xc(%rsp), %ecx
shll %cl, %r14d
movl %r14d, %edi
movl 0x8(%rsp), %ebp
movl %ebp, %esi
callq 0x1d5d
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x40(%rsp)
movl %r14d, %edi
movl %ebp, %esi
callq 0x1db2
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x30(%rsp)
leaq 0x35b2(%rip), %rax      # 0x50a0
movq (%rax), %rax
movq 0x50(%rsp), %rcx
movl (%rax,%rcx,4), %r15d
movq 0x28(%rsp), %r14
shlq $0x4, %r14
addq 0x18(%rsp), %r14
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x1b46
movq (%rbx), %rax
movl (%rax,%rbp,4), %esi
movl %r13d, %ecx
shll %cl, %esi
shlq $0x4, %rsi
addq %r14, %rsi
movl %r12d, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
callq 0x1ddf
incq %rbp
jmp 0x1b0a
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax), %rbp
movl %ebp, %r14d
movl 0xc(%rsp), %ecx
shll %cl, %r14d
movl %r14d, %edi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x1d5d
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x40(%rsp)
movl %r14d, %edi
movl %ebx, %esi
leaq 0x3524(%rip), %rbx      # 0x50a8
callq 0x1db2
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x30(%rsp)
shlq $0x4, %rbp
addq 0x18(%rsp), %rbp
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x1bde
movq (%rbx), %rax
movl (%rax,%r14,4), %esi
movl %r13d, %ecx
shll %cl, %esi
shlq $0x4, %rsi
addq %rbp, %rsi
movl %r12d, %edi
movsd 0x10(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
callq 0x1ddf
incq %r14
jmp 0x1ba1
movq 0x28(%rsp), %rax
incq %rax
jmp 0x1a9d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq