// File: dfrodriguezp[P]PiCM-cpp/functions.cc
// Function: fft(std::valarray<std::complex<double>>&)
void fft(CArray &x)
{
    const Int N = x.size();
    if (N <= 1)
        return;

    // divide
    CArray even = x[std::slice(0, N / 2, 2)];
    CArray odd = x[std::slice(1, N / 2, 2)];

    // conquer
    fft(even);
    fft(odd);

    // combine
    for (Int k = 0; k < N / 2; ++k)
    {
        Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k] = even[k] + t;
        x[k + N / 2] = even[k] - t;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10570
movl %eax, -0xc(%rbp)
cmpl $0x1, -0xc(%rbp)
ja 0xd556
jmp 0xd8b8
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0xc(%rbp), %eax
shrl %eax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
movl $0x2, %ecx
movq %rcx, -0x100(%rbp)
callq 0x105e0
movq -0x110(%rbp), %rsi
movq -0x40(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movups -0x50(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x10590
movq -0x108(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x10620
movq -0x100(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0xc(%rbp), %eax
shrl %eax
movl %eax, %edx
leaq -0x90(%rbp), %rdi
movl $0x1, %esi
callq 0x105e0
jmp 0xd5e6
movq -0xf8(%rbp), %rsi
movq -0x80(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movups -0x90(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x78(%rbp), %rdi
callq 0x10590
jmp 0xd60d
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x10620
jmp 0xd61c
leaq -0x20(%rbp), %rdi
callq 0xd530
jmp 0xd627
leaq -0x60(%rbp), %rdi
callq 0xd530
jmp 0xd632
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movl -0xc(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0xd8a6
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0xc8(%rbp)
movsd 0xecb0(%rip), %xmm0     # 0x1c318
movsd 0x6e08(%rip), %xmm1     # 0x14478
mulsd %xmm1, %xmm0
movl -0xa0(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
movl -0xc(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x106f0
movsd %xmm1, -0x120(%rbp)
movsd %xmm0, -0x118(%rbp)
jmp 0xd6bc
movsd -0x120(%rbp), %xmm0
movsd -0x118(%rbp), %xmm1
movsd %xmm1, -0xc0(%rbp)
movsd %xmm0, -0xb8(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x10780
movq %rax, -0x128(%rbp)
jmp 0xd6f6
movq -0x128(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x106b0
movsd %xmm1, -0x138(%rbp)
movsd %xmm0, -0x130(%rbp)
jmp 0xd71b
movsd -0x138(%rbp), %xmm0
movsd -0x130(%rbp), %xmm1
movsd %xmm1, -0xb0(%rbp)
movsd %xmm0, -0xa8(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0x10780
movq %rax, -0x140(%rbp)
jmp 0xd755
movq -0x140(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x107b0
movsd %xmm1, -0x150(%rbp)
movsd %xmm0, -0x148(%rbp)
jmp 0xd77a
movsd -0x150(%rbp), %xmm0
movsd -0x148(%rbp), %xmm1
movsd %xmm1, -0xe0(%rbp)
movsd %xmm0, -0xd8(%rbp)
movq -0x8(%rbp), %rdi
movl -0xa0(%rbp), %eax
movl %eax, %esi
callq 0x10780
movq %rax, -0x158(%rbp)
jmp 0xd7b4
movq -0x158(%rbp), %rax
movups -0xe0(%rbp), %xmm0
movups %xmm0, (%rax)
movl -0xa0(%rbp), %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0x10780
movq %rax, -0x160(%rbp)
jmp 0xd7df
movq -0x160(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x107f0
movsd %xmm1, -0x170(%rbp)
movsd %xmm0, -0x168(%rbp)
jmp 0xd804
movsd -0x170(%rbp), %xmm0
movsd -0x168(%rbp), %xmm1
movsd %xmm1, -0xf0(%rbp)
movsd %xmm0, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
movl -0xa0(%rbp), %eax
movl -0xc(%rbp), %ecx
shrl %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x10780
movq %rax, -0x178(%rbp)
jmp 0xd845
movq -0x178(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xe8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0xd63c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0xd8c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x10830
jmp 0xd8c1
leaq -0x60(%rbp), %rdi
callq 0x10830
leaq -0x20(%rbp), %rdi
callq 0x10830
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x10830
movq -0x98(%rbp), %rdi
callq 0x3530
nopw %cs:(%rax,%rax)