// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rsi, 0x18(%rsp)
movl %edi, 0x4(%rsp)
testl %edi, %edi
je 0x1f2c
movl 0x4(%rsp), %eax
bsrl %eax, %ecx
movl $0x20, %esi
movl %ecx, 0x34(%rsp)
subl %ecx, %esi
movl %esi, 0x28(%rsp)
shrl %eax
movl %eax, 0x24(%rsp)
movq 0x18(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x38(%rsp)
xorl %esi, %esi
leaq 0x361a(%rip), %r11      # 0x5080
movl $0x2, %eax
movq %rax, 0x10(%rsp)
xorl %edi, %edi
xorl %eax, %eax
movq %rdx, 0x40(%rsp)
leal 0x2(%rax), %ecx
movl %ecx, 0x8(%rsp)
xorl %eax, %ecx
bsrl %ecx, %r8d
xorl $-0x20, %r8d
addl $0x1f, %r8d
movl %esi, 0x30(%rsp)
movl %edi, 0x2c(%rsp)
subl %edi, %esi
movl 0x28(%rsp), %ecx
shrl %cl, %esi
movl %esi, %edi
xorl 0x24(%rsp), %edi
shlq $0x4, %rsi
movl %r8d, (%rsp)
movl %r8d, %ecx
movsd (%rdx,%rsi), %xmm1
movsd 0x8(%rdx,%rsi), %xmm0
movl %edi, %esi
movl %eax, %r8d
andl $0x1, %ecx
jne 0x1b18
shlq $0x4, %rsi
movsd (%rdx,%rsi), %xmm2
movsd 0x8(%rdx,%rsi), %xmm3
movapd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm0, %xmm5
addsd %xmm3, %xmm5
shlq $0x4, %r8
movq 0x18(%rsp), %rdx
movsd %xmm4, (%rdx,%r8)
movsd %xmm5, 0x8(%rdx,%r8)
subsd %xmm2, %xmm1
subsd %xmm3, %xmm0
orl $0x1, %eax
shlq $0x4, %rax
movsd %xmm1, (%rdx,%rax)
movsd %xmm0, 0x8(%rdx,%rax)
jmp 0x1bff
shlq $0x4, %r8
movq 0x18(%rsp), %rdi
movsd %xmm1, (%rdi,%r8)
movsd %xmm0, 0x8(%rdi,%r8)
shlq $0x4, %rsi
movups (%rdx,%rsi), %xmm0
orl $0x1, %eax
shlq $0x4, %rax
movups %xmm0, (%rdi,%rax)
movsd -0x20(%rdi,%r8), %xmm3
movsd -0x18(%rdi,%r8), %xmm4
movsd -0x10(%rdi,%r8), %xmm0
movsd -0x8(%rdi,%r8), %xmm2
movsd (%rdi,%r8), %xmm1
movsd 0x8(%rdi,%r8), %xmm5
movsd 0x10(%rdi,%r8), %xmm6
movsd 0x18(%rdi,%r8), %xmm7
movapd %xmm1, %xmm8
addsd %xmm6, %xmm8
subsd %xmm6, %xmm1
movapd %xmm5, %xmm6
addsd %xmm7, %xmm6
subsd %xmm7, %xmm5
movapd %xmm3, %xmm7
addsd %xmm8, %xmm7
movapd %xmm4, %xmm9
addsd %xmm6, %xmm9
movsd %xmm7, -0x20(%rdi,%r8)
movsd %xmm9, -0x18(%rdi,%r8)
movapd %xmm0, %xmm7
addsd %xmm5, %xmm7
movapd %xmm2, %xmm9
subsd %xmm1, %xmm9
movsd %xmm7, -0x10(%rdi,%r8)
movsd %xmm9, -0x8(%rdi,%r8)
subsd %xmm8, %xmm3
subsd %xmm6, %xmm4
movsd %xmm3, (%rdi,%r8)
movsd %xmm4, 0x8(%rdi,%r8)
subsd %xmm5, %xmm0
addsd %xmm2, %xmm1
movsd %xmm0, 0x10(%rdi,%r8)
movsd %xmm1, 0x18(%rdi,%r8)
incl %ecx
cmpl (%rsp), %ecx
jae 0x1ee3
movl $0x1, %r15d
shll %cl, %r15d
movl $0xfffffffc, %r14d      # imm = 0xFFFFFFFC
shll %cl, %r14d
movl %ecx, 0xc(%rsp)
testl %ecx, %ecx
je 0x1cfa
movl 0x34(%rsp), %ebp
movl 0xc(%rsp), %eax
subl %eax, %ebp
addl $-0x2, %ebp
movl %eax, %r13d
cmpl $0x1, %eax
je 0x1c9f
movl %r15d, %r12d
shrl %r12d
cmpl $0x3, %r12d
movl $0x2, %eax
cmovbl %eax, %r12d
movq 0x10(%rsp), %rax
leal (%rax,%r14), %ebx
shlq $0x4, %rbx
addq 0x38(%rsp), %rbx
movl $0x1, %r13d
movl %r13d, %eax
movl %ebp, %ecx
shll %cl, %eax
movq (%r11), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movl %r15d, %edi
movq %rbx, %rsi
callq 0x1f3b
leaq 0x33ed(%rip), %r11      # 0x5080
incq %r13
addq $0x10, %rbx
cmpq %r13, %r12
jne 0x1c68
leal 0x1(%r13), %r12d
cmpl %r15d, %r12d
jae 0x1cfa
movl %r13d, %ebx
shlq $0x4, %rbx
movq 0x10(%rsp), %rax
addl %r14d, %eax
shlq $0x4, %rax
addq 0x38(%rsp), %rbx
addq %rax, %rbx
movl %r12d, %eax
movl %ebp, %ecx
shll %cl, %eax
movq (%r11), %rcx
shlq $0x4, %rax
movsd (%rcx,%rax), %xmm0
movsd 0x8(%rcx,%rax), %xmm1
movl %r15d, %edi
movq %rbx, %rsi
callq 0x1f3b
leaq 0x3392(%rip), %r11      # 0x5080
addq $0x10, %rbx
incl %r12d
cmpl %r12d, %r15d
jne 0x1cc3
addl 0x8(%rsp), %r14d
movl %r14d, %esi
shlq $0x4, %rsi
movq 0x18(%rsp), %r10
leaq (%r10,%rsi), %rax
movl %r15d, %edx
shrl %r15d
shlq $0x4, %r15
leaq (%rax,%r15), %r9
movsd (%r15,%rax), %xmm1
movsd 0x8(%r15,%rax), %xmm2
shlq $0x4, %rdx
movsd (%rdx,%r9), %xmm0
movl $0x2, %edi
movl 0xc(%rsp), %ecx
shll %cl, %edi
movsd 0x8(%rdx,%r9), %xmm3
shlq $0x4, %rdi
movl $0x3, %r8d
shll %cl, %r8d
shlq $0x4, %r8
movsd (%rdi,%r9), %xmm6
movsd 0x14eb(%rip), %xmm5     # 0x3250
mulsd %xmm5, %xmm6
movsd (%r8,%r9), %xmm7
mulsd %xmm5, %xmm7
movsd 0x8(%rdi,%r9), %xmm4
mulsd %xmm5, %xmm4
movsd 0x8(%r8,%r9), %xmm8
mulsd %xmm5, %xmm8
movapd %xmm6, %xmm5
addsd %xmm4, %xmm5
subsd %xmm6, %xmm4
movapd %xmm7, %xmm6
subsd %xmm8, %xmm6
addsd %xmm7, %xmm8
movapd %xmm5, %xmm7
addsd %xmm6, %xmm7
subsd %xmm6, %xmm5
movapd %xmm4, %xmm6
addsd %xmm8, %xmm6
subsd %xmm8, %xmm4
movapd %xmm1, %xmm8
addsd %xmm7, %xmm8
movapd %xmm2, %xmm9
addsd %xmm6, %xmm9
movsd %xmm8, (%r15,%rax)
movsd %xmm9, 0x8(%r15,%rax)
movapd %xmm0, %xmm8
addsd %xmm4, %xmm8
movapd %xmm3, %xmm9
subsd %xmm5, %xmm9
movsd %xmm8, (%rdx,%r9)
movsd %xmm9, 0x8(%rdx,%r9)
subsd %xmm7, %xmm1
subsd %xmm6, %xmm2
movsd %xmm1, (%rdi,%r9)
movsd %xmm2, 0x8(%rdi,%r9)
subsd %xmm4, %xmm0
addsd %xmm3, %xmm5
movsd %xmm0, (%r8,%r9)
movsd %xmm5, 0x8(%r8,%r9)
movsd (%r10,%rsi), %xmm3
movsd 0x8(%r10,%rsi), %xmm4
movsd (%rdx,%rax), %xmm0
movsd 0x8(%rdx,%rax), %xmm2
movsd (%rdi,%rax), %xmm1
movsd 0x8(%rdi,%rax), %xmm5
movsd (%r8,%rax), %xmm6
movsd 0x8(%r8,%rax), %xmm7
movapd %xmm1, %xmm8
addsd %xmm6, %xmm8
subsd %xmm6, %xmm1
movapd %xmm5, %xmm6
addsd %xmm7, %xmm6
subsd %xmm7, %xmm5
movapd %xmm3, %xmm7
addsd %xmm8, %xmm7
movapd %xmm4, %xmm9
addsd %xmm6, %xmm9
movsd %xmm7, (%r10,%rsi)
movsd %xmm9, 0x8(%r10,%rsi)
movapd %xmm0, %xmm7
addsd %xmm5, %xmm7
movapd %xmm2, %xmm9
subsd %xmm1, %xmm9
movsd %xmm7, (%rdx,%rax)
movsd %xmm9, 0x8(%rdx,%rax)
subsd %xmm8, %xmm3
subsd %xmm6, %xmm4
movsd %xmm3, (%rdi,%rax)
movsd %xmm4, 0x8(%rdi,%rax)
subsd %xmm5, %xmm0
addsd %xmm2, %xmm1
movsd %xmm0, (%r8,%rax)
movsd %xmm1, 0x8(%r8,%rax)
addl $0x2, %ecx
jmp 0x1c01
movl $0x20000000, %eax       # imm = 0x20000000
movl (%rsp), %ecx
shrl %cl, %eax
leal -0x1(%rax), %ecx
movl %eax, %edx
movl 0x30(%rsp), %esi
andl %esi, %edx
movl 0x2c(%rsp), %edi
andl %ecx, %edi
orl %edx, %edi
andl %esi, %ecx
xorl %eax, %edx
addl %edx, %edx
orl %ecx, %edx
movq 0x10(%rsp), %rax
addl $0x2, %eax
movq %rax, 0x10(%rsp)
movl %edx, %esi
movl 0x8(%rsp), %ecx
movl %ecx, %eax
cmpl 0x4(%rsp), %ecx
movq 0x40(%rsp), %rdx
jb 0x1a79
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq