// File: /workspace/github_cpp_makefile_star2_O3/Czxck001[P]algorithms/src/fft.cc
// Function: auto fft<double>(std::vector<std::complex<double>, std::allocator<std::complex<double>>> const&)
auto fft(const CVec<T> &x) {
  // X[k] = E[k] + g^k * O[k]

  auto N = x.size();
  auto M = N / 2;

  if (N == 1) {
    return x;
  }

  // subdivide the signal into even part and odd part
  auto e = CVec<T>();
  auto o = CVec<T>();
  for (auto i = 0; i < N; i++) {
    if (i % 2 == 0) {
      e.push_back(x[i]);
    } else {
      o.push_back(x[i]);
    }
  }

  // recursively calculate sub-spectrums
  auto E = fft(e);
  auto O = fft(o);

  // calculate the spectrum from the sub-spectrums
  auto X = CVec<T>();
  for (auto k = 0; k < N; k++) {
    X.push_back(E[k % M] + cru<T>(k, N) * O[k % M]);
  }

  return X;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rcx
movq 0x8(%rsi), %rdx
movq %rdx, %r13
subq %rcx, %r13
cmpq $0x10, %r13
jne 0x1589
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19be
jmp 0x17dd
movq %rbx, -0xa8(%rbp)
sarq $0x4, %r13
xorpd %xmm0, %xmm0
movapd %xmm0, -0x90(%rbp)
xorl %eax, %eax
movq %rax, -0x80(%rbp)
movq %rax, -0x60(%rbp)
movapd %xmm0, -0x70(%rbp)
movq %rcx, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
cmpq %rcx, %rdx
je 0x1623
cmpq $0x1, %r13
movq %r13, %r15
adcq $0x0, %r15
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%r14), %rdx
addq %r12, %rdx
testb $0x1, %bl
jne 0x1600
movq -0x88(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq -0x80(%rbp), %rsi
je 0x1612
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, (%rax)
jmp 0x1617
movq -0x68(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rsi
jne 0x15f2
callq 0x1a5e
incq %rbx
addq $0x10, %r12
cmpq %rbx, %r15
jne 0x15cc
leaq -0xe8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x154c
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x154c
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
cmpq %rax, %rcx
je 0x1762
movq %r13, %r12
shrq %r12
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
xorpd %xmm1, %xmm1
movsd %xmm0, -0x38(%rbp)
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %r14d, %r14d
movq %r14, %rax
xorl %edx, %edx
divq %r12
movq %rdx, %rbx
movq -0xe8(%rbp), %r15
shlq $0x4, %rbx
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
mulsd 0x94f(%rip), %xmm1      # 0x2008
divsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
callq 0x10e0
movq -0xd0(%rbp), %rsi
addq %rbx, %rsi
movsd %xmm0, -0xa0(%rbp)
movsd %xmm1, -0x98(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x1c78
movsd -0xa0(%rbp), %xmm0
addsd (%r15,%rbx), %xmm0
movsd -0x98(%rbp), %xmm1
addsd 0x8(%r15,%rbx), %xmm1
movsd %xmm0, -0xb8(%rbp)
movsd %xmm1, -0xb0(%rbp)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x1738
movupd -0xb8(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, -0x48(%rbp)
jmp 0x1748
leaq -0x50(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x1b8e
incq %r14
cmpq %r14, %r13
jne 0x1693
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
jmp 0x1768
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movq -0xa8(%rbp), %rbx
movq %rdx, (%rbx)
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x1795
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x17b0
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x17c5
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x17dd
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq %rbx, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x182c
jmp 0x1849
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1811
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x182c
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x184c
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
jmp 0x184c
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x1861
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x1879
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq %rbx, %rdi
callq 0x1100