// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: rffts1(double*, long, long, double*, short*)
void rffts1(Float_t *ioptr, long M, long Rows, Float_t *Utbl, short *BRLow){
/* Compute in-place real fft on the rows of the input array	*/
/* The result is the complex spectra of the positive frequencies */
/* except the location for the first complex number contains the real */
/* values for DC and Nyquest */
/* INPUTS */
/* *ioptr = real 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	in the following order */
/* Re(x[0]), Re(x[N/2]), Re(x[1]), Im(x[1]), Re(x[2]), Im(x[2]), ... Re(x[N/2-1]), Im(x[N/2-1]). */

Float_t	scale;
long 	StageCnt;
long 	NDiffU;

M=M-1;
switch (M){
case -1:
	break;
case 0:
	for (;Rows>0;Rows--){
		rfft1pt(ioptr);				/* a 2 pt fft */
		ioptr += 2*POW2(M);
	}
case 1:
	for (;Rows>0;Rows--){
		rfft2pt(ioptr);				/* a 4 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 2:
	for (;Rows>0;Rows--){
		rfft4pt(ioptr);				/* an 8 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
case 3:
	for (;Rows>0;Rows--){
		rfft8pt(ioptr);				/* a 16 pt fft */
		ioptr += 2*POW2(M);
	}
	break;
default:
	scale = 0.5;
	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 ){
			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, 2, NDiffU, StageCnt);		/*  RADIX 8 Stages	*/
			frstage(ioptr, M+1, Utbl);
		}

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %rbx
leaq -0x1(%rsi), %r15
cmpq $0x4, %rsi
ja 0x25a68
leaq 0xa117(%rip), %rax      # 0x2f8f0
movslq (%rax,%rbp,4), %rcx
addq %rax, %rcx
jmpq *%rcx
testq %r14, %r14
jle 0x25826
movl $0x2, %eax
movl %r15d, %ecx
shlq %cl, %rax
shlq $0x3, %rax
incq %r14
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
movapd %xmm0, %xmm2
addsd %xmm1, %xmm2
subsd %xmm1, %xmm0
movsd %xmm2, (%rbx)
movsd %xmm0, 0x8(%rbx)
addq %rax, %rbx
decq %r14
cmpq $0x1, %r14
jg 0x257f9
xorl %r14d, %r14d
testq %r14, %r14
jle 0x25cb2
movl $0x2, %eax
movl %r15d, %ecx
shlq %cl, %rax
addq $0x18, %rbx
shlq $0x3, %rax
incq %r14
movsd -0x18(%rbx), %xmm0
movsd -0x10(%rbx), %xmm1
movsd -0x8(%rbx), %xmm2
movsd (%rbx), %xmm3
movapd %xmm0, %xmm4
addsd %xmm2, %xmm4
movapd %xmm1, %xmm5
addsd %xmm3, %xmm5
subsd %xmm2, %xmm0
subsd %xmm1, %xmm3
movapd %xmm4, %xmm1
addsd %xmm5, %xmm1
subsd %xmm5, %xmm4
movsd %xmm1, -0x18(%rbx)
movsd %xmm4, -0x10(%rbx)
movsd %xmm0, -0x8(%rbx)
movsd %xmm3, (%rbx)
addq %rax, %rbx
decq %r14
cmpq $0x1, %r14
jg 0x25845
jmp 0x25cb2
testq %r14, %r14
jle 0x25cb2
movl $0x2, %r12d
movl %r15d, %ecx
shlq %cl, %r12
shlq $0x3, %r12
incq %r14
movq %rbx, %rdi
callq 0x293de
addq %r12, %rbx
decq %r14
cmpq $0x1, %r14
jg 0x258bc
jmp 0x25cb2
testq %r14, %r14
jle 0x25cb2
movl $0x2, %eax
movl %r15d, %ecx
shlq %cl, %rax
addq $0x38, %rbx
shlq $0x3, %rax
incq %r14
movsd 0x9fa4(%rip), %xmm0     # 0x2f8a0
movsd 0x9fa4(%rip), %xmm1     # 0x2f8a8
movsd 0x573c(%rip), %xmm2     # 0x2b048
movsd -0x38(%rbx), %xmm7
movsd -0x30(%rbx), %xmm3
movsd -0x18(%rbx), %xmm6
movsd -0x10(%rbx), %xmm8
movsd -0x28(%rbx), %xmm10
movsd -0x20(%rbx), %xmm4
movsd -0x8(%rbx), %xmm11
movsd (%rbx), %xmm12
movapd %xmm7, %xmm5
addsd %xmm6, %xmm5
movapd %xmm3, %xmm13
addsd %xmm8, %xmm13
subsd %xmm6, %xmm7
subsd %xmm8, %xmm3
movapd %xmm10, %xmm8
subsd %xmm11, %xmm8
movapd %xmm4, %xmm9
subsd %xmm12, %xmm9
addsd %xmm11, %xmm10
addsd %xmm12, %xmm4
movapd %xmm5, %xmm6
addsd %xmm10, %xmm6
movapd %xmm13, %xmm11
addsd %xmm4, %xmm11
subsd %xmm10, %xmm5
subsd %xmm13, %xmm4
movapd %xmm7, %xmm10
subsd %xmm9, %xmm10
movapd %xmm3, %xmm12
addsd %xmm8, %xmm12
addsd %xmm7, %xmm9
subsd %xmm8, %xmm3
movapd %xmm6, %xmm8
addsd %xmm11, %xmm8
subsd %xmm11, %xmm6
movapd %xmm9, %xmm7
addsd %xmm10, %xmm7
movapd %xmm3, %xmm11
subsd %xmm12, %xmm11
addsd %xmm12, %xmm3
subsd %xmm9, %xmm10
movapd %xmm3, %xmm9
mulsd %xmm0, %xmm9
addsd %xmm7, %xmm9
mulsd %xmm0, %xmm10
addsd %xmm10, %xmm9
mulsd %xmm1, %xmm3
addsd %xmm11, %xmm3
addsd %xmm10, %xmm3
addsd %xmm7, %xmm7
subsd %xmm9, %xmm7
addsd %xmm11, %xmm11
movapd %xmm3, %xmm10
subsd %xmm11, %xmm10
movsd %xmm5, -0x18(%rbx)
movsd %xmm4, -0x10(%rbx)
movsd %xmm8, -0x38(%rbx)
movsd %xmm6, -0x30(%rbx)
mulsd %xmm2, %xmm9
movsd %xmm9, -0x28(%rbx)
mulsd %xmm2, %xmm3
movsd %xmm3, -0x20(%rbx)
mulsd %xmm2, %xmm7
movsd %xmm7, -0x8(%rbx)
mulsd %xmm2, %xmm10
movsd %xmm10, (%rbx)
addq %rax, %rbx
decq %r14
cmpq $0x1, %r14
jg 0x2590c
jmp 0x25cb2
testq %r14, %r14
jle 0x25cb2
movq %rcx, %r13
leaq -0x2(%rbp), %rsi
movabsq $0x5555555555555556, %rcx # imm = 0x5555555555555556
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
addq %rdx, %rax
movq %rax, 0x8(%rsp)
leaq (%rax,%rax,2), %rax
subq %rax, %rsi
xorl %eax, %eax
movq %rsi, 0x28(%rsp)
cmpq $0x1, %rsi
sete %al
setne %dl
cmpq $0x3, %r15
setb %sil
movl $0x1, %edi
movl %r15d, %ecx
shlq %cl, %rdi
movl $0x2, %r10d
shlq %cl, %r10
movq %r10, 0x20(%rsp)
shrq $0x3, %rdi
movq %rdi, 0x10(%rsp)
orb %dl, %sil
movb %sil, 0x7(%rsp)
leaq 0x2(,%rax,2), %rax
movq %rax, 0x18(%rsp)
movq %r8, 0x30(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r8, %rdx
movsd 0x5544(%rip), %xmm0     # 0x2b048
callq 0x28ab0
movq 0x18(%rsp), %r12
cmpb $0x0, 0x7(%rsp)
jne 0x25c3e
movq 0x10(%rsp), %rax
movq %rbx, %rcx
movsd 0x20(%rcx), %xmm0
movsd (%rcx), %xmm1
movsd 0x8(%rcx), %xmm2
movsd 0x28(%rcx), %xmm3
movsd 0x40(%rcx), %xmm4
movsd 0x60(%rcx), %xmm5
movsd 0x48(%rcx), %xmm6
movsd 0x68(%rcx), %xmm7
movapd %xmm1, %xmm8
addsd %xmm0, %xmm8
movapd %xmm2, %xmm9
addsd %xmm3, %xmm9
subsd %xmm0, %xmm1
subsd %xmm3, %xmm2
movapd %xmm4, %xmm0
addsd %xmm5, %xmm0
movapd %xmm6, %xmm3
addsd %xmm7, %xmm3
subsd %xmm5, %xmm4
subsd %xmm7, %xmm6
movsd %xmm8, (%rcx)
movsd %xmm9, 0x8(%rcx)
movsd %xmm1, 0x20(%rcx)
movsd %xmm2, 0x28(%rcx)
movsd %xmm0, 0x40(%rcx)
movsd %xmm3, 0x48(%rcx)
movsd %xmm4, 0x60(%rcx)
movsd %xmm6, 0x68(%rcx)
movsd 0x10(%rcx), %xmm0
movsd 0x38(%rcx), %xmm1
movsd 0x18(%rcx), %xmm2
movsd 0x30(%rcx), %xmm3
movsd 0x50(%rcx), %xmm4
movsd 0x78(%rcx), %xmm5
movsd 0x58(%rcx), %xmm6
movsd 0x70(%rcx), %xmm7
movapd %xmm0, %xmm8
addsd %xmm1, %xmm8
movapd %xmm2, %xmm9
subsd %xmm3, %xmm9
subsd %xmm1, %xmm0
addsd %xmm3, %xmm2
movapd %xmm4, %xmm1
addsd %xmm5, %xmm1
movapd %xmm6, %xmm3
subsd %xmm7, %xmm3
subsd %xmm5, %xmm4
addsd %xmm7, %xmm6
movsd %xmm8, 0x10(%rcx)
movsd %xmm9, 0x18(%rcx)
movsd %xmm0, 0x30(%rcx)
movsd %xmm2, 0x38(%rcx)
movsd %xmm1, 0x50(%rcx)
movsd %xmm3, 0x58(%rcx)
movsd %xmm4, 0x70(%rcx)
movsd %xmm6, 0x78(%rcx)
subq $-0x80, %rcx
decq %rax
jne 0x25b21
movl $0x4, %r12d
cmpq $0x2, 0x28(%rsp)
jne 0x25c58
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x274fa
shll $0x2, %r12d
movl $0x2, %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %r8
cmpq $0xa, %r15
ja 0x25c7b
movq 0x8(%rsp), %r9
callq 0x2622d
jmp 0x25c85
movq 0x8(%rsp), %r9
callq 0x24b5c
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x29814
movq 0x20(%rsp), %rax
leaq (%rbx,%rax,8), %rbx
leaq -0x1(%r14), %rax
cmpq $0x1, %r14
movq %rax, %r14
movq 0x30(%rsp), %r8
jg 0x25af3
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq