// File: /workspace/github_cpp_makefile_star2_O1/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 0x2414a
movl $0x1, %r14d
movl %r15d, %ecx
shlq %cl, %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x249a9
cmpq $0x2, %r13
je 0x2416b
cmpq $0x1, %r13
jne 0x2424c
movl $0x2, %r13d
movl %r15d, %ecx
shlq %cl, %r13
leaq 0x15b08(%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 0x2a2c5
movq (%r12,%r15,8), %rdx
leaq (%rdx,%r13,8), %rdi
movl $0x2, %esi
movl $0x2, %r9d
movq %r14, %rcx
movq %r14, %r8
callq 0x2a158
movq (%r12,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x249a9
movq (%r12,%r15,8), %rdi
movl $0x1, %ecx
jmp 0x2422a
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 0x249a9
movl $0x2, %r13d
movl %r15d, %ecx
shlq %cl, %r13
leaq 0x15a72(%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 0x2a2c5
movq (%r12,%r15,8), %rdx
leaq (%rdx,%r13,8), %rdi
movl $0x2, %esi
movl $0x2, %r9d
movq %r14, %rcx
movq %r14, %r8
callq 0x2a158
movq (%r12,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x249a9
movq (%r12,%r15,8), %rdi
movl $0x2, %ecx
movl $0x1, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r14, %r9
callq 0x2a2c5
addq $0x10, %rbx
movq (%r12,%r15,8), %rdx
movl $0x2, %esi
movl $0x1, %r9d
movq %rbx, %rdi
movq %r14, %rcx
movq %r14, %r8
callq 0x2a2c5
movq (%r12,%r15,8), %rdi
movl $0x1, %edx
movq %r15, %rsi
callq 0x24957
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 0x2a2c5
movl $0x1, %r12d
movl %r13d, %ecx
shlq %cl, %r12
shrq %r12
movl $0x2, %eax
movl %r15d, %ecx
shlq %cl, %rax
movq %rax, (%rsp)
leaq 0x1597f(%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 0x2a2c5
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 0x2a158
movq (%rbp,%r15,8), %rdi
movl $0x2, %edx
movq %r15, %rsi
callq 0x249a9
movq (%rbp,%r15,8), %rdi
movl $0x1, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x2a2c5
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 0x2a2c5
movq (%rbp,%r15,8), %rdi
movl $0x3, %edx
movq %r15, %rsi
callq 0x24957
movq (%rbp,%r15,8), %rdi
movl $0x3, %r8d
movq %r14, %rsi
movq (%rsp), %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x2a2c5
cmpq $0x4, %r13
jb 0x2439d
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 0x2a2c5
movq (%rbp,%r15,8), %rdi
movl $0x4, %edx
movq %r15, %rsi
callq 0x24957
movq (%rbp,%r15,8), %rdi
movl $0x4, %r8d
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x2a2c5
addq $0x4, %r13
addq $0x40, %rbx
cmpq %r12, %r13
jb 0x24346
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq