// File: /workspace/github_cpp_makefile_star2_O2/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, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movq 0x8(%rsi), %rdi
subq (%rsi), %rdi
shrq $0x4, %rdi
movq %rdi, 0x30(%rsp)
callq 0x1b16
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1378
movl %ebp, (%rsp)
testl %ebp, %ebp
je 0x14c6
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movl 0x30(%rsp), %edx
cvtsi2sd %rdx, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
cmpq %rcx, %rax
je 0x14c6
movupd (%rax), %xmm1
divpd %xmm0, %xmm1
movupd %xmm1, (%rax)
addq $0x10, %rax
jmp 0x14af
pushq $0x1
popq %rbp
xorpd %xmm0, %xmm0
movhpd 0x1b53(%rip), %xmm0     # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x60(%rsp)
leaq 0x10(%rsp), %r12
movl %ebp, %r14d
cmpl 0x4(%rsp), %ebp
jae 0x164b
leal (%r14,%r14), %eax
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq %rax, 0x38(%rsp)
cvtsi2sd %rax, %xmm0
cmpb $0x0, (%rsp)
je 0x1554
movsd 0x1b1d(%rip), %xmm1     # 0x3030
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movapd 0x60(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1b31
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %r12, %rdi
callq 0x1b23
jmp 0x159b
movsd 0x1ac4(%rip), %xmm1     # 0x3020
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movapd 0x60(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1b31
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %r12, %rdi
callq 0x1b23
movsd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x28(%rsp)
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %eax, %eax
movl %ebp, 0x8(%rsp)
cmpl 0x30(%rsp), %eax
jae 0x163f
movsd 0x1a62(%rip), %xmm0     # 0x3028
movapd %xmm0, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, %ebp
movq %r14, %r15
subq $0x1, %r15
jb 0x162e
leal (%r14,%rbp), %r13d
shlq $0x4, %r13
movq (%rbx), %rsi
addq %r13, %rsi
movq %r12, %rdi
callq 0x1b31
movl %ebp, %eax
movq (%rbx), %rcx
shlq $0x4, %rax
movupd (%rcx,%rax), %xmm2
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd %xmm0, %xmm1
addpd %xmm2, %xmm1
movupd %xmm1, (%rcx,%rax)
movq (%rbx), %rax
subpd %xmm0, %xmm2
movupd %xmm2, (%rax,%r13)
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1b56
incl %ebp
jmp 0x15d5
movl 0xc(%rsp), %eax
addl 0x38(%rsp), %eax
movl 0x8(%rsp), %ebp
jmp 0x15b4
incl %ebp
movq 0x38(%rsp), %r14
jmp 0x14e3
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1661
jmp 0x1661
movq %rax, %r14
movq %rbx, %rdi
callq 0x1edc
movq %r14, %rdi
callq 0x1160