// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl -0x4(%rbp), %eax
bsrl %eax, %ecx
xorl $0x1f, %ecx
movl $0x1f, %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl $0x20, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x4(%rbp), %eax
jae 0x2222
movl -0x30(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
xorl -0x2c(%rbp), %eax
bsrl %eax, %ecx
xorl $0x1f, %ecx
movl $0x1e, %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x24(%rbp), %eax
subl -0x28(%rbp), %eax
movl -0x20(%rbp), %ecx
shrl %cl, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl -0x4(%rbp), %ecx
shrl %ecx
xorl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1f70
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rsi
movl -0x30(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
addq $-0x20, %rsi
movl $0x1, %edi
callq 0x2230
jmp 0x201d
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm0
movsd %xmm1, -0x50(%rbp)
movsd %xmm0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm0
movsd %xmm1, -0x60(%rbp)
movsd %xmm0, -0x58(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
movsd -0x60(%rbp), %xmm3
movsd -0x58(%rbp), %xmm2
addsd %xmm3, %xmm1
addsd %xmm2, %xmm0
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
movsd -0x60(%rbp), %xmm3
movsd -0x58(%rbp), %xmm2
subsd %xmm3, %xmm1
subsd %xmm2, %xmm0
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm1, (%rax)
movsd %xmm0, 0x8(%rax)
movl -0x34(%rbp), %eax
andl $0x1, %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x21bb
movl -0x64(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x68(%rbp)
movl -0x30(%rbp), %eax
addl $0x2, %eax
movl -0x68(%rbp), %ecx
shll $0x2, %ecx
subl %ecx, %eax
movl %eax, -0x6c(%rbp)
movl -0x1c(%rbp), %eax
subl -0x64(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x70(%rbp)
cmpl $0x1, -0x68(%rbp)
jbe 0x2173
movl $0x1, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl -0x68(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x20eb
movl -0x68(%rbp), %eax
movl %eax, -0xb4(%rbp)
movq -0x10(%rbp), %rax
movl -0x6c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl -0x74(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movl -0x74(%rbp), %edi
movl -0x70(%rbp), %ecx
shll %cl, %edi
movl -0x1c(%rbp), %esi
callq 0x2f70
movl -0xb4(%rbp), %edi
movq -0xb0(%rbp), %rsi
movsd %xmm0, -0x88(%rbp)
movsd %xmm1, -0x80(%rbp)
movsd -0x88(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x2420
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2070
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x68(%rbp), %eax
jae 0x2171
movl -0x68(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq -0x10(%rbp), %rax
movl -0x6c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl -0x74(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movl -0x74(%rbp), %edi
movl -0x70(%rbp), %ecx
shll %cl, %edi
movl -0x1c(%rbp), %esi
callq 0x2f70
movl -0xc4(%rbp), %edi
movq -0xc0(%rbp), %rsi
movsd %xmm0, -0x98(%rbp)
movsd %xmm1, -0x90(%rbp)
movsd -0x98(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
callq 0x2420
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x20f4
jmp 0x2173
movl -0x68(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x6c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x68(%rbp), %eax
shrl %eax
movl %eax, %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x2fb0
movl -0x68(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x6c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x2230
movl -0x64(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x64(%rbp)
jmp 0x2029
movl -0x34(%rbp), %ecx
movl $0x20000000, %eax       # imm = 0x20000000
sarl %cl, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xa0(%rbp)
movl -0x24(%rbp), %eax
andl -0x9c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x28(%rbp), %eax
andl -0xa0(%rbp), %eax
orl -0xa4(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
andl -0xa0(%rbp), %eax
movl -0xa4(%rbp), %ecx
xorl -0x9c(%rbp), %ecx
shll %ecx
orl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x1e99
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)