// File: /workspace/github_cpp_makefile_star2_O2/kebwi[P]Trifid/src/FFT/fft2d.cpp
// Function: rfft2d(double*, long, long)
void rfft2d(Float_t *data, long M2, long M){
/* Compute 2D real fft and return results in-place	*/
/* First performs real fft on rows using size from M to compute positive frequencies */
/* then performs transform on columns using size from M2 to compute wavenumbers */
/* If you think of the result as a complex pow(2,M2) by pow(2,M-1) matrix */
/* then the first column contains the positive wavenumber spectra of DC frequency */
/* followed by the positive wavenumber spectra of the nyquest frequency */
/* since these are two positive wavenumber spectra the first complex value */
/* of each is really the real values for the zero and nyquest wavenumber packed together */
/* All other columns contain the positive and negative wavenumber spectra of a positive frequency */
/* See rspect2dprod for multiplying two of these spectra together- ex. for fast convolution */
/* INPUTS */
/* *data = input data array	*/
/* M2 = log2 of fft size number of rows in */
/* M = log2 of fft size number of columns in */
/* OUTPUTS */
/* *data = output data array	*/
long i1;
if((M2>0)&&(M>0)){
	rffts(data, M, POW2(M2));
	if (M==1){
		cxpose(data, POW2(M)/2, Array2d[M2]+POW2(M2)*2, POW2(M2), POW2(M2), 1);
		xpose(Array2d[M2]+POW2(M2)*2, 2, Array2d[M2], POW2(M2), POW2(M2), 2);
		rffts(Array2d[M2], M2, 2);
		cxpose(Array2d[M2], POW2(M2), data, POW2(M)/2, 1, POW2(M2));
	}
	else if (M==2){
		cxpose(data, POW2(M)/2, Array2d[M2]+POW2(M2)*2, POW2(M2), POW2(M2), 1);
		xpose(Array2d[M2]+POW2(M2)*2, 2, Array2d[M2], POW2(M2), POW2(M2), 2);
		rffts(Array2d[M2], M2, 2);
		cxpose(Array2d[M2], POW2(M2), data, POW2(M)/2, 1, POW2(M2));

		cxpose(data + 2, POW2(M)/2, Array2d[M2], POW2(M2), POW2(M2), 1);
		ffts(Array2d[M2], M2, 1);
		cxpose(Array2d[M2], POW2(M2), data + 2, POW2(M)/2, 1, POW2(M2));
	}
	else{
		cxpose(data, POW2(M)/2, Array2d[M2]+POW2(M2)*2, POW2(M2), POW2(M2), 1);
		xpose(Array2d[M2]+POW2(M2)*2, 2, Array2d[M2], POW2(M2), POW2(M2), 2);
		rffts(Array2d[M2], M2, 2);
		cxpose(Array2d[M2], POW2(M2), data, POW2(M)/2, 1, POW2(M2));

		cxpose(data + 2, POW2(M)/2, Array2d[M2], POW2(M2), POW2(M2), 3);
		ffts(Array2d[M2], M2, 3);
		cxpose(Array2d[M2], POW2(M2), data + 2, POW2(M)/2, 3, POW2(M2));
		for (i1=4; i1<POW2(M)/2; i1+=4){
			cxpose(data + i1*2, POW2(M)/2, Array2d[M2], POW2(M2), POW2(M2), 4);
			ffts(Array2d[M2], M2, 4);
			cxpose(Array2d[M2], POW2(M2), data + i1*2, POW2(M)/2, 4, POW2(M2));
		}
	}
}
else
	rffts(data, M2+M, 1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
setle %al
testq %rdx, %rdx
setle %cl
orb %al, %cl
jne 0x1cf4d
pushq $0x1
popq %r13
movq %r13, %rdx
movl %r14d, %ecx
shlq %cl, %rdx
movq %rbx, %rdi
movq %rbp, %rsi
movq %rdx, 0x8(%rsp)
callq 0x1d7e3
cmpq $0x2, %rbp
je 0x1cf6c
cmpq $0x1, %rbp
jne 0x1d042
pushq $0x2
popq %r12
movl %r14d, %ecx
shlq %cl, %r12
leaq 0x15d00(%rip), %rbp     # 0x32be0
leaq (,%r12,8), %rdx
addq (%rbp,%r14,8), %rdx
pushq $0x1
popq %r13
movq %rbx, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r15
movq %r15, %rcx
movq %r15, %r8
movq %r13, %r9
callq 0x21836
movq (%rbp,%r14,8), %rdx
leaq (%rdx,%r12,8), %rdi
pushq $0x2
popq %rsi
movq %r15, %rcx
movq %r15, %r8
movq %rsi, %r9
movq %rsi, %r12
callq 0x21700
movq (%rbp,%r14,8), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1d7e3
movq (%rbp,%r14,8), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r13, %r8
jmp 0x1d02c
addq %r14, %rbp
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rbp, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d7e3
pushq $0x2
popq %r13
movq %r13, %r12
movl %r14d, %ecx
shlq %cl, %r12
leaq 0x15c60(%rip), %rbp     # 0x32be0
leaq (,%r12,8), %rdx
addq (%rbp,%r14,8), %rdx
pushq $0x1
popq %r9
movq %rbx, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r15
movq %r15, %rcx
movq %r15, %r8
callq 0x21836
movq (%rbp,%r14,8), %rdx
leaq (%rdx,%r12,8), %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r15, %r8
movq %r13, %r9
callq 0x21700
movq (%rbp,%r14,8), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x1d7e3
movq (%rbp,%r14,8), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
pushq $0x1
popq %r12
movq %r12, %r8
movq %r15, %r9
callq 0x21836
addq $0x10, %rbx
movq (%rbp,%r14,8), %rdx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rcx
movq %r15, %r8
movq %r12, %r9
callq 0x21836
movq (%rbp,%r14,8), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1d789
movq (%rbp,%r14,8), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r12, %r8
movq %r15, %r9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21836
movq %r13, %r12
movl %ebp, %ecx
shlq %cl, %r12
shrq %r12
pushq $0x2
popq %rbp
movl %r14d, %ecx
shlq %cl, %rbp
leaq 0x15b83(%rip), %rax     # 0x32be0
leaq (,%rbp,8), %rdx
addq (%rax,%r14,8), %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %r15
movq %r15, %rcx
movq %r15, %r8
movq %r13, %r9
callq 0x21836
leaq 0x15b57(%rip), %rax     # 0x32be0
movq (%rax,%r14,8), %rdx
leaq (%rdx,%rbp,8), %rdi
pushq $0x2
popq %rsi
movq %r15, %rcx
movq %r15, %r8
movq %rsi, %r9
callq 0x21700
leaq 0x15b37(%rip), %rbp     # 0x32be0
movq (%rbp,%r14,8), %rdi
movq %r14, %rsi
pushq $0x2
popq %rdx
callq 0x1d7e3
movq (%rbp,%r14,8), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r8
movq %r15, %r9
callq 0x21836
leaq 0x10(%rbx), %r13
movq (%rbp,%r14,8), %rdx
pushq $0x3
popq %rbp
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rcx
movq %r15, %r8
movq %rbp, %r9
callq 0x21836
leaq 0x15ae7(%rip), %rax     # 0x32be0
movq (%rax,%r14,8), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x1d789
movq %r14, 0x18(%rsp)
leaq 0x15acc(%rip), %rax     # 0x32be0
movq (%rax,%r14,8), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, 0x10(%rsp)
movq %r12, %rcx
movq %rbp, %r8
movq %r15, %r9
callq 0x21836
addq $0x40, %rbx
movq %rbx, %r15
pushq $0x4
popq %rax
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %r14
pushq $0x4
popq %r13
cmpq 0x10(%rsp), %rax
jae 0x1d1af
movq %rax, 0x20(%rsp)
leaq 0x15a7f(%rip), %rbx     # 0x32be0
movq (%rbx,%r12,8), %rdx
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rcx
movq %r14, %r8
movq %r13, %r9
callq 0x21836
movq (%rbx,%r12,8), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1d789
movq (%rbx,%r12,8), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %r13, %r8
movq %r14, %r9
callq 0x21836
movq 0x20(%rsp), %rax
addq $0x4, %rax
addq $0x40, %r15
jmp 0x1d14e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq