// File: kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: iffts1(double*, long, long, double*, short*)
void iffts1(Float_t *ioptr, long M, long Rows, Float_t *Utbl, short *BRLow){
/* Compute in-place inverse complex fft on the rows of the input array	*/
/* INPUTS */
/* *ioptr = input data array	*/
/* M = log2 of fft size	*/
/* Rows = number of rows in ioptr array (use Rows of 1 if ioptr is a 1 dimensional array)	*/
/* *Utbl = cosine table	*/
/* *BRLow = bit reversed counter table	*/
/* OUTPUTS */
/* *ioptr = output data array	*/

long 	StageCnt;
long 	NDiffU;
const Float_t scale = 1.0/POW2(M);

switch (M){
case 0:
	break;
case 1:
	for (;Rows>0;Rows--){
		ifft2pt(ioptr, scale);				/* a 2 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 2:
	for (;Rows>0;Rows--){
		ifft4pt(ioptr, scale);				/* a 4 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 3:
	for (;Rows>0;Rows--){
		ifft8pt(ioptr, scale);				/* an 8 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
default:
	for (;Rows>0;Rows--){

		scbitrevR2(ioptr, M, BRLow, scale);	/* bit reverse and first radix 2 stage */
		
		StageCnt = (M-1) / 3;		// number of radix 8 stages
		NDiffU = 2;				// one radix 2 stage already complete

		if ( (M-1-(StageCnt * 3)) == 1 ){
			ibfR2(ioptr, M, NDiffU);				/* 1 radix 2 stage */
			NDiffU *= 2;
		}

		if ( (M-1-(StageCnt * 3)) == 2 ){
			ibfR4(ioptr, M, NDiffU);			/* 1 radix 4 stage */
			NDiffU *= 4;
		}

		if (M <= MCACHE)
			ibfstages(ioptr, M, Utbl, 1, NDiffU, StageCnt);		/*  RADIX 8 Stages	*/

		else{
			ifftrecurs(ioptr, M, Utbl, 1, NDiffU, StageCnt);		/*  RADIX 8 Stages	*/
		}

		ioptr += 2*POW2(M);
	}
}
}

// 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 -0x10(%rbp), %rcx
shlq $0x34, %rcx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
subq $0x3, %rax
ja 0x3b0bf
movq -0x48(%rbp), %rax
leaq 0x12a0e(%rip), %rcx     # 0x4d9f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x3b1d8
jmp 0x3aff2
cmpq $0x0, -0x18(%rbp)
jle 0x3b030
movq -0x8(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x42850
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x3aff2
jmp 0x3b1d8
jmp 0x3b037
cmpq $0x0, -0x18(%rbp)
jle 0x3b075
movq -0x8(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x42920
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x3b037
jmp 0x3b1d8
jmp 0x3b07c
cmpq $0x0, -0x18(%rbp)
jle 0x3b0ba
movq -0x8(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x42b30
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x3b07c
jmp 0x3b1d8
jmp 0x3b0c1
cmpq $0x0, -0x18(%rbp)
jle 0x3b1d6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
callq 0x43240
movq -0x10(%rbp), %rax
subq $0x1, %rax
movl $0x3, %ecx
cqto
idivq %rcx
movq %rax, -0x30(%rbp)
movq $0x2, -0x38(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
imulq $0x3, -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x1, %rax
jne 0x3b132
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x43ae0
movq -0x38(%rbp), %rax
shlq %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
imulq $0x3, -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x2, %rax
jne 0x3b165
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x43fc0
movq -0x38(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x38(%rbp)
cmpq $0xa, -0x10(%rbp)
ja 0x3b18c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x1, %ecx
callq 0x40290
jmp 0x3b1aa
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x1, %ecx
callq 0x3aea0
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq %rax
shlq $0x3, %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x3b0c1
jmp 0x3b1d8
addq $0x50, %rsp
popq %rbp
retq
nop