// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jle 0x39bb3
cmpq $0x0, -0x18(%rbp)
jle 0x39bb3
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rcx
movl $0x1, %edx
shlq %cl, %rdx
callq 0x3a870
cmpq $0x1, -0x18(%rbp)
jne 0x39698
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x23741(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x38(%rbp), %rcx
movl $0x1, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x236f0(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rcx
leaq 0x236cb(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x30(%rbp), %rcx
movl $0x2, %r9d
movq %r9, %rsi
callq 0x47ef0
movq -0x10(%rbp), %rcx
leaq 0x2368d(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3a870
movq -0x10(%rbp), %rcx
leaq 0x23670(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x28(%rbp), %rcx
movl $0x1, %r8d
callq 0x48240
jmp 0x39bb1
cmpq $0x2, -0x18(%rbp)
jne 0x3989b
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x235ff(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x60(%rbp), %rcx
movl $0x1, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x235ae(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rcx
leaq 0x23589(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x58(%rbp), %rcx
movl $0x2, %r9d
movq %r9, %rsi
callq 0x47ef0
movq -0x10(%rbp), %rcx
leaq 0x2354b(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3a870
movq -0x10(%rbp), %rcx
leaq 0x2352e(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x50(%rbp), %rcx
movl $0x1, %r8d
callq 0x48240
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x234c9(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x48(%rbp), %rcx
movl $0x1, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x2348e(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x3a7b0
movq -0x10(%rbp), %rcx
leaq 0x23471(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
addq $0x10, %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x40(%rbp), %rcx
movl $0x1, %r8d
callq 0x48240
jmp 0x39baf
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x23407(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x88(%rbp), %rcx
movl $0x1, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x233b0(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rcx
leaq 0x2338b(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x80(%rbp), %rcx
movl $0x2, %r9d
movq %r9, %rsi
callq 0x47ef0
movq -0x10(%rbp), %rcx
leaq 0x2334d(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x2, %edx
callq 0x3a870
movq -0x10(%rbp), %rcx
leaq 0x23330(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x78(%rbp), %rcx
movl $0x1, %r8d
callq 0x48240
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x232cb(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x70(%rbp), %rcx
movl $0x3, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x23290(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x3, %edx
callq 0x3a7b0
movq -0x10(%rbp), %rcx
leaq 0x23273(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
addq $0x10, %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x68(%rbp), %rcx
movl $0x3, %r8d
callq 0x48240
movq $0x4, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
shrq %rcx
cmpq %rcx, %rax
jae 0x39bad
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
shrq %rsi
movq -0x10(%rbp), %rcx
leaq 0x231d9(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r8d
shlq %cl, %r8
movq -0x98(%rbp), %rcx
movl $0x4, %r9d
callq 0x48240
movq -0x10(%rbp), %rcx
leaq 0x23198(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rsi
movl $0x4, %edx
callq 0x3a7b0
movq -0x10(%rbp), %rcx
leaq 0x2317b(%rip), %rax     # 0x5ccc0
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
shlq %cl, %rsi
movq -0x8(%rbp), %rdx
movq -0x20(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shrq %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %r9d
shlq %cl, %r9
movq -0x90(%rbp), %rcx
movl $0x4, %r8d
callq 0x48240
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
jmp 0x39a9c
jmp 0x39baf
jmp 0x39bb1
jmp 0x39bc9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x3a870
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)