// File: /workspace/github_cpp_makefile_star2_O1/hdlguy[P]fft_demo/fft.cpp
// Function: Fft::convolve(std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void Fft::convolve(const vector<double> &xreal, const vector<double> &ximag, const vector<double> &yreal, const vector<double> &yimag, vector<double> &outreal, vector<double> &outimag) {
	if (xreal.size() != ximag.size() || xreal.size() != yreal.size() || yreal.size() != yimag.size() || xreal.size() != outreal.size() || outreal.size() != outimag.size())
		throw "Mismatched lengths";
	
	size_t n = xreal.size();
	vector<double> xr(xreal);
	vector<double> xi(ximag);
	vector<double> yr(yreal);
	vector<double> yi(yimag);
	
	transform(xr, xi);
	transform(yr, yi);
	for (size_t i = 0; i < n; i++) {
		double temp = xr[i] * yr[i] - xi[i] * yi[i];
		xi[i] = xi[i] * yr[i] + xr[i] * yi[i];
		xr[i] = temp;
	}
	inverseTransform(xr, xi);
	for (size_t i = 0; i < n; i++) {  // Scaling (because this FFT implementation omits it)
		outreal[i] = xr[i] / n;
		outimag[i] = xi[i] / n;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %rsi, %r13
movq (%rdi), %rax
movq 0x8(%rdi), %rbx
movq %rbx, -0x70(%rbp)
movq %rax, %r14
subq %rax, %rbx
movq 0x8(%rsi), %rax
subq (%rsi), %rax
cmpq %rax, %rbx
jne 0x1d0b
movq %rdx, %r12
movq 0x8(%rdx), %rax
subq (%rdx), %rax
cmpq %rax, %rbx
jne 0x1d0b
movq %rcx, %r15
movq 0x8(%rcx), %rcx
subq (%r15), %rcx
cmpq %rcx, %rax
jne 0x1d0b
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq %rax, %rbx
jne 0x1d0b
movq -0x30(%rbp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
cmpq %rcx, %rax
jne 0x1d0b
movq %rdi, %rsi
leaq -0x68(%rbp), %rdi
callq 0x1f44
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x1f44
leaq -0xa0(%rbp), %rdi
movq %r12, %rsi
callq 0x1f44
movq %r14, %r12
movq -0x70(%rbp), %r14
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x1f44
leaq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x12ec
leaq -0xa0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x12ec
sarq $0x3, %rbx
cmpq %r12, %r14
je 0x1c47
movq -0x68(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq -0x88(%rbp), %rsi
cmpq $0x1, %rbx
movq %rbx, %rdi
adcq $0x0, %rdi
xorl %r8d, %r8d
movsd (%rax,%r8,8), %xmm0
movsd (%rcx,%r8,8), %xmm1
movsd (%rdx,%r8,8), %xmm2
movsd (%rsi,%r8,8), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, (%rdx,%r8,8)
movsd %xmm4, (%rax,%r8,8)
incq %r8
cmpq %r8, %rdi
jne 0x1bff
leaq -0x50(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x12ec
cmpq %r12, %r14
je 0x1cbe
movq -0x68(%rbp), %rax
movq %rbx, %xmm1
punpckldq 0x13b6(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x13be(%rip), %xmm1     # 0x3030
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rsi
movq (%rsi), %rsi
cmpq $0x1, %rbx
adcq $0x0, %rbx
xorl %edi, %edi
movsd (%rax,%rdi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdi,8)
movsd (%rdx,%rdi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rbx
jne 0x1c9a
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x1ccf
callq 0x10c0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x1ce0
callq 0x10c0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1cee
callq 0x10c0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1cfc
callq 0x10c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x1070
leaq 0x1324(%rip), %rcx      # 0x3040
movq %rcx, (%rax)
movq 0x32a2(%rip), %rsi      # 0x4fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x1140
movq %rax, %rbx
jmp 0x1d53
movq %rax, %rbx
jmp 0x1d64
movq %rax, %rbx
jmp 0x1d72
movq %rax, %rbx
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x1d53
callq 0x10c0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x1d64
callq 0x10c0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1d72
callq 0x10c0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1d80
callq 0x10c0
movq %rbx, %rdi
callq 0x1160