// File: kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: ffts1(double*, long, long, double*, short*)
void ffts1(Float_t *ioptr, long M, long Rows, Float_t *Utbl, short *BRLow){
/* Compute in-place complex fft on the rows of the input array	*/
/* INPUTS */
/* *ioptr = input data array	*/
/* M = log2 of fft size	(ex M=10 for 1024 point fft) */
/* 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;

switch (M){
case 0:
	break;
case 1:
	for (;Rows>0;Rows--){
		fft2pt(ioptr);				/* a 2 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 2:
	for (;Rows>0;Rows--){
		fft4pt(ioptr);				/* a 4 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 3:
	for (;Rows>0;Rows--){
		fft8pt(ioptr);				/* an 8 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
default:
	for (;Rows>0;Rows--){

		bitrevR2(ioptr, M, BRLow);						/* 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 ){
			bfR2(ioptr, M, NDiffU);				/* 1 radix 2 stage */
			NDiffU *= 2;
		}

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

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

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
subq $0x3, %rax
ja 0x3ad77
movq -0x40(%rbp), %rax
leaq 0x12d37(%rip), %rcx     # 0x4d9e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x3ae8b
jmp 0x3acb9
cmpq $0x0, -0x18(%rbp)
jle 0x3acf2
movq -0x8(%rbp), %rdi
callq 0x3dd10
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 0x3acb9
jmp 0x3ae8b
jmp 0x3acf9
cmpq $0x0, -0x18(%rbp)
jle 0x3ad32
movq -0x8(%rbp), %rdi
callq 0x3ddd0
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 0x3acf9
jmp 0x3ae8b
jmp 0x3ad39
cmpq $0x0, -0x18(%rbp)
jle 0x3ad72
movq -0x8(%rbp), %rdi
callq 0x3dfb0
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 0x3ad39
jmp 0x3ae8b
jmp 0x3ad79
cmpq $0x0, -0x18(%rbp)
jle 0x3ae89
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x3e650
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 0x3ade5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x3ee70
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 0x3ae18
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x3f350
movq -0x38(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x38(%rbp)
cmpq $0xa, -0x10(%rbp)
ja 0x3ae3f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x1, %ecx
callq 0x3b750
jmp 0x3ae5d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x1, %ecx
callq 0x3ab80
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 0x3ad79
jmp 0x3ae8b
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)