// File: 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:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x78(%rsp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, 0x70(%rsp)
movq %rdi, 0x1c0(%rsp)
movq %rsi, 0x1b8(%rsp)
andb $0x1, %al
movb %al, 0x1b7(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x2430
movl %eax, 0x1b0(%rsp)
movl 0x1b0(%rsp), %edi
callq 0x24c0
movq 0x78(%rsp), %rdi
movl %eax, 0x1ac(%rsp)
movb $0x0, 0x1ab(%rsp)
movq 0x1b8(%rsp), %rsi
callq 0x13a0
testb $0x1, 0x1b7(%rsp)
je 0x1626
movq 0x78(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x25a0
movq %rax, 0x198(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x25d0
movq %rax, 0x190(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x2600
testb $0x1, %al
jne 0x15c0
jmp 0x1624
leaq 0x198(%rsp), %rdi
callq 0x2640
movq %rax, 0x188(%rsp)
movl 0x1b0(%rsp), %eax
cvtsi2sd %rax, %xmm0
movq 0x188(%rsp), %rdi
callq 0x2650
jmp 0x15f0
jmp 0x15f2
leaq 0x198(%rsp), %rdi
callq 0x2690
jmp 0x15a5
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x180(%rsp)
movl %eax, 0x17c(%rsp)
callq 0x2540
jmp 0x1a8f
jmp 0x1626
movl $0x1, 0x178(%rsp)
movl $0x1, 0x174(%rsp)
movl 0x174(%rsp), %eax
cmpl 0x1ac(%rsp), %eax
jae 0x1a66
movl 0x178(%rsp), %eax
addl %eax, %eax
movl %eax, 0x178(%rsp)
leaq 0x160(%rsp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x2480
jmp 0x1675
testb $0x1, 0x1b7(%rsp)
je 0x1766
movl 0x178(%rsp), %eax
cvtsi2sd %rax, %xmm1
movsd 0x4981(%rip), %xmm0     # 0x6018
divsd %xmm1, %xmm0
leaq 0x130(%rsp), %rdi
xorps %xmm1, %xmm1
callq 0x2480
jmp 0x16ad
leaq 0x120(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x4950(%rip), %xmm1     # 0x6010
callq 0x2480
jmp 0x16c7
leaq 0x130(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x2720
movsd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x68(%rsp)
jmp 0x16ea
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd %xmm1, 0x140(%rsp)
movsd %xmm0, 0x148(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x26b0
movsd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x58(%rsp)
jmp 0x1723
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd %xmm1, 0x150(%rsp)
movsd %xmm0, 0x158(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x168(%rsp)
jmp 0x1844
movl 0x178(%rsp), %eax
cvtsi2sd %rax, %xmm1
movsd 0x488e(%rip), %xmm0     # 0x6008
divsd %xmm1, %xmm0
leaq 0xf0(%rsp), %rdi
xorps %xmm1, %xmm1
callq 0x2480
jmp 0x1790
leaq 0xe0(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x486d(%rip), %xmm1     # 0x6010
callq 0x2480
jmp 0x17aa
leaq 0xf0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2720
movsd %xmm1, 0x40(%rsp)
movsd %xmm0, 0x48(%rsp)
jmp 0x17cd
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd %xmm1, 0x100(%rsp)
movsd %xmm0, 0x108(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x26b0
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
jmp 0x1806
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0x110(%rsp)
movsd %xmm0, 0x118(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x168(%rsp)
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
cmpl 0x1b0(%rsp), %eax
jae 0x1a4e
leaq 0xc8(%rsp), %rdi
movsd 0x479d(%rip), %xmm0     # 0x6010
xorps %xmm1, %xmm1
callq 0x2480
jmp 0x187d
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl 0x178(%rsp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x1a32
movq 0x78(%rsp), %rdi
movl 0xdc(%rsp), %eax
movl 0xc4(%rsp), %ecx
addl %ecx, %eax
movl 0x178(%rsp), %ecx
shrl %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x2520
movq %rax, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x2720
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
jmp 0x18e5
movq 0x78(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0xb0(%rsp)
movsd %xmm0, 0xb8(%rsp)
movl 0xdc(%rsp), %eax
movl 0xc4(%rsp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x2520
movups (%rax), %xmm0
movaps %xmm0, 0xa0(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x2760
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
jmp 0x194d
movq 0x78(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x90(%rsp)
movsd %xmm0, 0x98(%rsp)
movl 0xdc(%rsp), %eax
movl 0xc4(%rsp), %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x2520
movups 0x90(%rsp), %xmm0
movups %xmm0, (%rax)
leaq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x27a0
movsd %xmm1, (%rsp)
movsd %xmm0, 0x8(%rsp)
jmp 0x19b4
movq 0x78(%rsp), %rdi
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x88(%rsp)
movl 0xdc(%rsp), %eax
movl 0xc4(%rsp), %ecx
addl %ecx, %eax
movl 0x178(%rsp), %ecx
shrl %ecx
addl %ecx, %eax
movl %eax, %esi
callq 0x2520
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rax)
leaq 0xc8(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x27e0
jmp 0x1a1a
jmp 0x1a1c
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x1888
jmp 0x1a34
movl 0x178(%rsp), %eax
addl 0xdc(%rsp), %eax
movl %eax, 0xdc(%rsp)
jmp 0x184f
jmp 0x1a50
movl 0x174(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x174(%rsp)
jmp 0x163c
movb $0x1, 0x1ab(%rsp)
testb $0x1, 0x1ab(%rsp)
jne 0x1a82
movq 0x78(%rsp), %rdi
callq 0x2540
movq 0x70(%rsp), %rax
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x180(%rsp), %rdi
callq 0x1150
nopl (%rax)