// File: kebwi[P]Trifid/src/FFT/fft2d.cpp
// Function: rspect2dprod(double*, double*, double*, long, long)
void rspect2dprod(Float_t *data1, Float_t *data2, Float_t *outdata, long N2, long N1){
// When multiplying a pair of 2d spectra from rfft2d care must be taken to multiply the
// four real values seperately from the complex ones. This routine does it correctly.
// the result can be stored in-place over one of the inputs
/* *data1 = input data array	first spectra */
/* *data2 = input data array	second spectra */
/* N2 = fft size number of rows into rfft2d for both data1 and data2 */
/* N1 = fft size number of columns into rfft2d for both data1 and data2 */
long N = N2 * N1/2;		// number of "complex" numbers in spectra

if( (N2 > 1) && (N1>1)){
	outdata[0] = data1[0] * data2[0];	// multiply the zero freq, zero wavenumber values
	outdata[1] = data1[1] * data2[1];	// multiply the zero freq, nyquest wavenumber values

	cvprod(data1 + 2, data2 + 2, outdata + 2, N/2-1);

	outdata[N] = data1[N] * data2[N];		// multiply the nyquest freq, zero wavenumber values
	outdata[N+1] = data1[N+1] * data2[N+1];	// multiply the nyquest freq, nyquest wavenumber values

	cvprod(data1 + N+2, data2 + N+2, outdata + N+2, N/2-1);
}
else{	// really 1D rfft spectra
	N = N2 * N1;	// one of these is a 1
	if(N>1){
		outdata[0] = data1[0] * data2[0];	// multiply the zero freq values
		outdata[1] = data1[1] * data2[1];	// multiply the nyquest freq values
		cvprod(data1 + 2, data2 + 2, outdata + 2, N/2-1);	// multiply the other positive freq values
	}
	else{
		outdata[0] = data1[0] * data2[0];
	}
}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x20(%rbp), %rax
imulq -0x28(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x30(%rbp)
cmpq $0x1, -0x20(%rbp)
jle 0x3a3e7
cmpq $0x1, -0x28(%rbp)
jle 0x3a3e7
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
mulsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq -0x40(%rbp), %rdx
movq %rax, %rcx
subq $0x1, %rcx
callq 0x485a0
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
mulsd 0x8(%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
addq $0x10, %rsi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq -0x38(%rbp), %rdx
movq %rax, %rcx
subq $0x1, %rcx
callq 0x485a0
jmp 0x3a484
movq -0x20(%rbp), %rax
imulq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x1, -0x30(%rbp)
jle 0x3a46a
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
mulsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq -0x48(%rbp), %rdx
movq %rax, %rcx
subq $0x1, %rcx
callq 0x485a0
jmp 0x3a482
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
mulsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x3a484
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)