// File: /workspace/github_cpp_makefile_star2_O3/henrixh[P]shittydsa/examples/../src/fft.h
// Function: transform(std::vector<std::complex<double>, std::allocator<std::complex<double>>>&, bool)
vc transform(vc& xs, bool inverse) {
  ul n { (ul)xs.size() };
  ul lb_n { lb(n)  };
  vc A { bitreversecopy(xs) };

  if (inverse) {
    for (auto&& a : A) {
      a /= (fp)n;
    }
  }

  // Pseudocode shamelessly stolen from wikipedia #magic
  ul m { 1 };
  for (ul s { 1 }; s < lb_n; s++) {
    m *= 2;
    cd twiddlechange;
    if (inverse) {
      twiddlechange = exp(cd(2 * M_PI/(fp)m, 0)*cd(0,1));
    } else {
      twiddlechange = exp(cd(-2 * M_PI/(fp)m, 0)*cd(0,1));
    }

    for (ul k { 0 }; k < n; k += m) {
      cd twiddle {1,0};
      for (ul j { 0 }; j < m/2; ++j) {
        cd t = twiddle * A[k + j + m/2];
        cd u = A[k + j];
        A[k + j] = u + t;
        A[k + j + m/2] = u - t;
        twiddle *= twiddlechange;
      }
    }
  }
  return A;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, 0x18(%rsp)
movq %rdi, %r14
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
shrq $0x4, %rbx
xorl %ebp, %ebp
testl %ebx, %ebx
je 0x14ae
movl %ebx, %ecx
movl %ebx, %eax
sarl %eax
incl %ebp
cmpl $0x1, %ecx
movl %eax, %ecx
ja 0x14a3
movq %r14, %rdi
callq 0x137e
cmpb $0x0, 0x18(%rsp)
je 0x14e9
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpq %rcx, %rax
je 0x14e9
movl %ebx, %edx
cvtsi2sd %rdx, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movupd (%rax), %xmm1
divpd %xmm0, %xmm1
movupd %xmm1, (%rax)
addq $0x10, %rax
cmpq %rcx, %rax
jne 0x14d4
cmpl $0x2, %ebp
jb 0x165e
movl $0x1, %eax
xorpd %xmm0, %xmm0
movhpd 0x1b0d(%rip), %xmm0     # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x60(%rsp)
movq %rsp, %rdi
leaq 0x30(%rsp), %r13
movl $0x1, %ecx
movl %ebp, 0x1c(%rsp)
movq %rbx, 0x58(%rsp)
movl %ecx, 0x20(%rsp)
movq %rax, %r15
addl %eax, %eax
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
cmpb $0x0, 0x18(%rsp)
je 0x1550
movsd 0x1aca(%rip), %xmm1     # 0x3018
jmp 0x1558
movsd 0x1ab0(%rip), %xmm1     # 0x3008
divsd %xmm0, %xmm1
movaps 0x60(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd %xmm1, (%rsp)
movq $0x0, 0x8(%rsp)
movq %r13, %rsi
callq 0x1d84
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x10e0
movsd %xmm0, 0x40(%rsp)
movsd %xmm1, 0x48(%rsp)
testl %ebx, %ebx
movq %rsp, %rdi
je 0x1649
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movsd 0x1a5c(%rip), %xmm0     # 0x3010
movapd %xmm0, 0x30(%rsp)
movq %r15, %rbx
movl %ecx, 0x24(%rsp)
movl %ecx, %r12d
testq %r15, %r15
je 0x1634
movq %r13, %rbp
leal (%r15,%r12), %r13d
shlq $0x4, %r13
movq (%r14), %rsi
addq %r13, %rsi
movaps 0x30(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %rsp, %rdi
callq 0x1d84
movl %r12d, %eax
movapd (%rsp), %xmm0
movq (%r14), %rcx
shlq $0x4, %rax
movupd (%rcx,%rax), %xmm1
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movupd %xmm2, (%rcx,%rax)
movq (%r14), %rax
subpd %xmm0, %xmm1
movupd %xmm1, (%rax,%r13)
movq %rbp, %r13
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x1d84
movq %rsp, %rdi
incl %r12d
decq %rbx
jne 0x15c9
movl 0x24(%rsp), %ecx
addl 0x28(%rsp), %ecx
movq 0x58(%rsp), %rbx
cmpl %ebx, %ecx
jb 0x15ac
movl 0x20(%rsp), %ecx
incl %ecx
movq 0x28(%rsp), %rax
cmpl 0x1c(%rsp), %ecx
jne 0x151f
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq