// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
testq %rsi, %rsi
setle %al
testq %rdx, %rdx
setle %cl
orb %al, %cl
jne 0x23edf
movl $0x1, %r14d
movl %r15d, %ecx
shlq %cl, %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x24741
cmpq $0x2, %r13
je 0x23f00
cmpq $0x1, %r13
jne 0x23fe1
movl $0x2, %r13d
movl %r15d, %ecx
shlq %cl, %r13
leaq 0x15d73(%rip), %r12     # 0x39bf0
leaq (,%r13,8), %rdx
addq (%r12,%r15,8), %rdx
movl $0x1, %esi
movl $0x1, %r9d
movq %rbx, %rdi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%r12,%r15,8), %rdx
leaq (%rdx,%r13,8), %rdi
movl $0x2, %esi
movl $0x2, %r9d
movq %r14, %rcx
movq %r14, %r8
callq 0x29494
movq (%r12,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x24741
movq (%r12,%r15,8), %rdi
movl $0x1, %ecx
jmp 0x23fbf
addq %r15, %r13
movl $0x1, %edx
movq %rbx, %rdi
movq %r13, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24741
movl $0x2, %r13d
movl %r15d, %ecx
shlq %cl, %r13
leaq 0x15cdd(%rip), %r12     # 0x39bf0
leaq (,%r13,8), %rdx
addq (%r12,%r15,8), %rdx
movl $0x2, %esi
movl $0x1, %r9d
movq %rbx, %rdi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%r12,%r15,8), %rdx
leaq (%rdx,%r13,8), %rdi
movl $0x2, %esi
movl $0x2, %r9d
movq %r14, %rcx
movq %r14, %r8
callq 0x29494
movq (%r12,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x24741
movq (%r12,%r15,8), %rdi
movl $0x2, %ecx
movl $0x1, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r14, %r9
callq 0x29601
addq $0x10, %rbx
movq (%r12,%r15,8), %rdx
movl $0x2, %esi
movl $0x1, %r9d
movq %rbx, %rdi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%r12,%r15,8), %rdi
movl $0x1, %edx
movq %r15, %rsi
callq 0x246ef
movq (%r12,%r15,8), %rdi
movl $0x2, %ecx
movl $0x1, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r14, %r9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29601
movl $0x1, %r12d
movl %r13d, %ecx
shlq %cl, %r12
shrq %r12
movl $0x2, %eax
movl %r15d, %ecx
shlq %cl, %rax
movq %rax, (%rsp)
leaq 0x15bea(%rip), %rbp     # 0x39bf0
leaq (,%rax,8), %rdx
addq (%rbp,%r15,8), %rdx
movl $0x1, %r9d
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%rbp,%r15,8), %rdx
movq (%rsp), %rax
leaq (%rdx,%rax,8), %rdi
movl $0x2, %esi
movl $0x2, %r9d
movq %r14, %rcx
movq %r14, %r8
callq 0x29494
movq (%rbp,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x24741
movq (%rbp,%r15,8), %rdi
movl $0x1, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x29601
leaq 0x10(%rbx), %rdi
movq %rdi, (%rsp)
movq (%rbp,%r15,8), %rdx
movl $0x3, %r9d
movq %r12, %rsi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%rbp,%r15,8), %rdi
movl $0x3, %edx
movq %r15, %rsi
callq 0x246ef
movq (%rbp,%r15,8), %rdi
movl $0x3, %r8d
movq %r14, %rsi
movq (%rsp), %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x29601
cmpq $0x4, %r13
jb 0x24132
addq $0x40, %rbx
movl $0x4, %r13d
movq (%rbp,%r15,8), %rdx
movl $0x4, %r9d
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rcx
movq %r14, %r8
callq 0x29601
movq (%rbp,%r15,8), %rdi
movl $0x4, %edx
movq %r15, %rsi
callq 0x246ef
movq (%rbp,%r15,8), %rdi
movl $0x4, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x29601
addq $0x4, %r13
addq $0x40, %rbx
cmpq %r12, %r13
jb 0x240db
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq