// File: /workspace/github_cpp_makefile_star2_O1/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 0x1587
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19ae
jmp 0x17d3
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 0x1621
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 0x15fe
movq -0x88(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq -0x80(%rbp), %rsi
je 0x1610
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, (%rax)
jmp 0x1615
movq -0x68(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rsi
jne 0x15f0
callq 0x1a4e
incq %rbx
addq $0x10, %r12
cmpq %rbx, %r15
jne 0x15ca
leaq -0xe8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x154a
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x154a
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
cmpq %rax, %rcx
je 0x1752
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 0x951(%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 0x1c68
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 0x1736
movupd -0xb8(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, -0x48(%rbp)
jmp 0x1746
leaq -0x50(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x1b7e
incq %r14
cmpq %r14, %r13
jne 0x1691
movq -0x50(%rbp), %rax
movq -0xa8(%rbp), %rbx
movq %rax, (%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rbx)
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x178b
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x17a6
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x17bb
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x17d3
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 0x1822
jmp 0x183f
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1807
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x1822
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x1842
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
jmp 0x1842
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x1857
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x186f
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq %rbx, %rdi
callq 0x1100