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

  for (uint32_t hn, h = 0; h < N; h = hn) {

    /* eval binary carry sequence */
    hn = h + 2;
    unsigned c = 30 - clz32(h ^ hn);

    /* input indices */
    unsigned i0 = (p - q) >> r;
    unsigned i1 = i0 ^ (N >> 1);

    if (c & 1) {                /* stage 1 */
      out[h    ] = in[i0];
      out[h + 1] = in[i1];
      cp_dit_bf_0(1, out + h - 2);
    } else {			/* stage 0 */
      complex double a = in[i0];
      complex double b = in[i1];
      out[h    ] = a + b;
      out[h + 1] = a - b;
    }

    /* higher stages */
    for (unsigned j = 1 + (c & 1); j < c; j += 2)
      {
        unsigned s = 1 << j;
        unsigned r = h + 2 - 4 * s;
        unsigned t = log2_N - j - 2;

        if (s > 1)
          {
	    unsigned b;
            for (b = 1; b < s / 2; b++)
              cp_dit_bf(s, out + r + b, get_twiddle(b << t, log2_N));
            for (b++; b < s; b++)
              cp_dit_bf(s, out + r + b, get_twiddle(b << t, log2_N));
          }

        cp_dit_bf_pi4(s, out + r + s / 2);
        cp_dit_bf_0(s, out + r);
      }

    /* advance to next input index */
    uint32_t m2 = 0x20000000 >> c;
    uint32_t m1 = m2 - 1;
    uint32_t m  = p & m2;
    q = (q & m1) | m;
    p = (p & m1) | ((m ^ m2) << 1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, 0x20(%rsp)
movl %edi, 0x8(%rsp)
testl %edi, %edi
je 0x1e16
movl 0x8(%rsp), %eax
bsrl %eax, %ecx
movl $0x20, %esi
movl %ecx, 0x3c(%rsp)
subl %ecx, %esi
movl %esi, 0x30(%rsp)
shrl %eax
movl %eax, 0x2c(%rsp)
movq 0x20(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x40(%rsp)
xorl %edi, %edi
movl $0x2, %eax
movq %rax, 0x18(%rsp)
xorl %r8d, %r8d
xorl %eax, %eax
movq %rdx, 0x48(%rsp)
leal 0x2(%rax), %ecx
movl %ecx, 0xc(%rsp)
xorl %eax, %ecx
bsrl %ecx, %r9d
xorl $-0x20, %r9d
addl $0x1f, %r9d
movl %edi, %esi
subl %r8d, %esi
movl 0x30(%rsp), %ecx
shrl %cl, %esi
movl %esi, %r10d
xorl 0x2c(%rsp), %r10d
shlq $0x4, %rsi
movl %r9d, 0x4(%rsp)
movl %r9d, %ecx
movupd (%rdx,%rsi), %xmm0
movl %r10d, %esi
movl %eax, %r9d
andl $0x1, %ecx
movl %edi, 0x38(%rsp)
movl %r8d, 0x34(%rsp)
jne 0x1aea
shlq $0x4, %rsi
shlq $0x4, %r9
movupd (%rdx,%rsi), %xmm1
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movq 0x20(%rsp), %rdx
movupd %xmm2, (%rdx,%r9)
orl $0x1, %eax
shlq $0x4, %rax
subpd %xmm1, %xmm0
movupd %xmm0, (%rdx,%rax)
jmp 0x1b5b
shlq $0x4, %r9
shlq $0x4, %rsi
movupd (%rdx,%rsi), %xmm1
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movq 0x20(%rsp), %rax
movupd -0x20(%rax,%r9), %xmm3
movupd -0x10(%rax,%r9), %xmm4
movapd %xmm3, %xmm5
addpd %xmm2, %xmm5
movupd %xmm5, -0x20(%rax,%r9)
subpd %xmm1, %xmm0
shufpd $0x1, %xmm0, %xmm0      # xmm0 = xmm0[1,0]
movapd %xmm4, %xmm1
addpd %xmm0, %xmm1
subpd %xmm0, %xmm4
movapd %xmm4, %xmm0
movsd %xmm1, %xmm0            # xmm0 = xmm1[0],xmm0[1]
movupd %xmm0, -0x10(%rax,%r9)
subpd %xmm2, %xmm3
movupd %xmm3, (%rax,%r9)
shufpd $0x2, %xmm1, %xmm4      # xmm4 = xmm4[0],xmm1[1]
movupd %xmm4, 0x10(%rax,%r9)
incl %ecx
cmpl 0x4(%rsp), %ecx
jae 0x1dc9
movl $0x1, %r15d
shll %cl, %r15d
movl $0xfffffffc, %edx       # imm = 0xFFFFFFFC
shll %cl, %edx
testl %ecx, %ecx
je 0x1c79
movl 0x3c(%rsp), %ebp
subl %ecx, %ebp
addl $-0x2, %ebp
movl %r15d, %edi
shrl %edi
movl $0x1, %r12d
cmpl $0x1, %ecx
movl %ecx, 0x14(%rsp)
movl %edi, 0x10(%rsp)
je 0x1c0d
cmpl $0x3, %edi
movl $0x2, %r12d
cmovael %edi, %r12d
movq 0x18(%rsp), %rax
movq %rdx, 0x50(%rsp)
leal (%rax,%rdx), %ebx
shlq $0x4, %rbx
addq 0x40(%rsp), %rbx
movl $0x1, %r13d
leaq 0x34b0(%rip), %r14      # 0x5080
movl %r13d, %eax
movl %ebp, %ecx
shll %cl, %eax
movq (%r14), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movl %r15d, %edi
movq %rbx, %rsi
callq 0x1e25
incq %r13
addq $0x10, %rbx
cmpq %r13, %r12
jne 0x1bd0
movl 0x14(%rsp), %ecx
movq 0x50(%rsp), %rdx
movl 0x10(%rsp), %edi
leal 0x1(%r12), %r13d
cmpl %r15d, %r13d
jae 0x1c7b
movl %r12d, %eax
shlq $0x4, %rax
movq 0x18(%rsp), %rcx
movq %rdx, %r12
leal (%rcx,%rdx), %ebx
shlq $0x4, %rbx
addq %rax, %rbx
addq 0x40(%rsp), %rbx
leaq 0x3444(%rip), %r14      # 0x5080
movl %r13d, %eax
movl %ebp, %ecx
shll %cl, %eax
movq (%r14), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movl %r15d, %edi
movq %rbx, %rsi
callq 0x1e25
addq $0x10, %rbx
incl %r13d
cmpl %r13d, %r15d
jne 0x1c3c
movl 0x14(%rsp), %ecx
movq %r12, %rdx
movl 0x10(%rsp), %edi
jmp 0x1c7b
xorl %edi, %edi
addl 0xc(%rsp), %edx
movl %edx, %esi
shlq $0x4, %rsi
movq 0x20(%rsp), %r11
leaq (%r11,%rsi), %rax
movl %edi, %r10d
shlq $0x4, %r10
leaq (%rax,%r10), %r9
movl %r15d, %edx
shlq $0x4, %rdx
movl $0x2, %edi
shll %cl, %edi
movl $0x3, %r8d
shll %cl, %r8d
shlq $0x4, %rdi
shlq $0x4, %r8
movupd (%r10,%rax), %xmm0
movsd (%rdi,%r9), %xmm1
movsd 0x8(%rdi,%r9), %xmm2
movhpd (%r8,%r9), %xmm1        # xmm1 = xmm1[0],mem[0]
movapd 0x1577(%rip), %xmm3     # 0x3250
mulpd %xmm3, %xmm1
movhpd 0x8(%r8,%r9), %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, (%r10,%rax)
movupd (%rdx,%r9), %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, (%rdx,%r9)
subpd %xmm1, %xmm0
movupd %xmm0, (%rdi,%r9)
shufpd $0x2, %xmm2, %xmm4      # xmm4 = xmm4[0],xmm2[1]
movupd %xmm4, (%r8,%r9)
movupd (%r11,%rsi), %xmm0
movupd (%rdi,%rax), %xmm1
movupd (%r8,%rax), %xmm2
movapd %xmm1, %xmm3
addpd %xmm2, %xmm3
movapd %xmm0, %xmm4
addpd %xmm3, %xmm4
movupd %xmm4, (%r11,%rsi)
movupd (%rdx,%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, (%rdx,%rax)
subpd %xmm3, %xmm0
movupd %xmm0, (%rdi,%rax)
shufpd $0x2, %xmm2, %xmm4      # xmm4 = xmm4[0],xmm2[1]
movupd %xmm4, (%r8,%rax)
addl $0x2, %ecx
jmp 0x1b5d
movl $0x20000000, %eax       # imm = 0x20000000
movl 0x4(%rsp), %ecx
shrl %cl, %eax
leal -0x1(%rax), %ecx
movl %eax, %edx
movl 0x38(%rsp), %esi
andl %esi, %edx
movl 0x34(%rsp), %r8d
andl %ecx, %r8d
orl %edx, %r8d
andl %esi, %ecx
xorl %eax, %edx
addl %edx, %edx
orl %ecx, %edx
movq 0x18(%rsp), %rax
addl $0x2, %eax
movq %rax, 0x18(%rsp)
movl %edx, %edi
movl 0xc(%rsp), %ecx
movl %ecx, %eax
cmpl 0x8(%rsp), %ecx
movq 0x48(%rsp), %rdx
jb 0x1a6b
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq