// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: scbitrevR2(double*, long, short*, double)
inline void scbitrevR2(Float_t *ioptr, long M, short *BRLow, Float_t scale){
/*** scaled bit reverse and first radix 2 stage forward or inverse fft ***/
Float_t	f0r;
Float_t	f0i;
Float_t	f1r;
Float_t	f1i;
Float_t	f2r;
Float_t	f2i;
Float_t	f3r;
Float_t	f3i;
Float_t	f4r;
Float_t	f4i;
Float_t	f5r;
Float_t	f5i;
Float_t	f6r;
Float_t	f6i;
Float_t	f7r;
Float_t	f7i;
Float_t	t0r;
Float_t	t0i;
Float_t	t1r;
Float_t	t1i;
Float_t	*p0r;
Float_t	*p1r;
Float_t	*IOP;
Float_t 	*iolimit;
long 	Colstart;
long 	iCol;
unsigned long 	posA;
unsigned long 	posAi;
unsigned long 	posB;
unsigned long 	posBi;

const unsigned long Nrems2 = POW2((M+3)/2);
const unsigned long Nroot_1_ColInc = POW2(M)-Nrems2;
const unsigned long Nroot_1 = POW2(M/2-1)-1;
const unsigned long ColstartShift = (M+1)/2 +1;
posA = POW2(M);		// 1/2 of POW2(M) complexes
posAi = posA + 1;
posB = posA + 2;
posBi = posB + 1;

iolimit = ioptr + Nrems2;
for (; ioptr < iolimit; ioptr += POW2(M/2+1)){
	for (Colstart = Nroot_1; Colstart >= 0; Colstart--){
		iCol = Nroot_1;
		p0r = ioptr+ Nroot_1_ColInc + BRLow[Colstart]*4;
		IOP = ioptr + (Colstart << ColstartShift);
		p1r = IOP + BRLow[iCol]*4;
		f0r = *(p0r);
		f0i = *(p0r+1);
		f1r = *(p0r+posA);
		f1i = *(p0r+posAi);
		for (; iCol > Colstart;){
			f2r = *(p0r+2);
			f2i = *(p0r+(2+1));
			f3r = *(p0r+posB);
			f3i = *(p0r+posBi);
			f4r = *(p1r);
			f4i = *(p1r+1);
			f5r = *(p1r+posA);
			f5i = *(p1r+posAi);
			f6r = *(p1r+2);
			f6i = *(p1r+(2+1));
			f7r = *(p1r+posB);
			f7i = *(p1r+posBi);
			
			t0r	= f0r + f1r;
			t0i	= f0i + f1i;
			f1r = f0r - f1r;
			f1i = f0i - f1i;
			t1r = f2r + f3r;
			t1i = f2i + f3i;
			f3r = f2r - f3r;
			f3i = f2i - f3i;
			f0r = f4r + f5r;
			f0i = f4i + f5i;
			f5r = f4r - f5r;
			f5i = f4i - f5i;
			f2r = f6r + f7r;
			f2i = f6i + f7i;
			f7r = f6r - f7r;
			f7i = f6i - f7i;

			*(p1r) = scale*t0r;
			*(p1r+1) = scale*t0i;
			*(p1r+2) = scale*f1r;
			*(p1r+(2+1)) = scale*f1i;
			*(p1r+posA) = scale*t1r;
			*(p1r+posAi) = scale*t1i;
			*(p1r+posB) = scale*f3r;
			*(p1r+posBi) = scale*f3i;
			*(p0r) = scale*f0r;
			*(p0r+1) = scale*f0i;
			*(p0r+2) = scale*f5r;
			*(p0r+(2+1)) = scale*f5i;
			*(p0r+posA) = scale*f2r;
			*(p0r+posAi) = scale*f2i;
			*(p0r+posB) = scale*f7r;
			*(p0r+posBi) = scale*f7i;

			p0r -= Nrems2;
			f0r = *(p0r);
			f0i = *(p0r+1);
			f1r = *(p0r+posA);
			f1i = *(p0r+posAi);
			iCol -= 1;
			p1r = IOP + BRLow[iCol]*4;
		};
		f2r = *(p0r+2);
		f2i = *(p0r+(2+1));
		f3r = *(p0r+posB);
		f3i = *(p0r+posBi);

		t0r   = f0r + f1r;
		t0i   = f0i + f1i;
		f1r = f0r - f1r;
		f1i = f0i - f1i;
		t1r   = f2r + f3r;
		t1i   = f2i + f3i;
		f3r = f2r - f3r;
		f3i = f2i - f3i;

		*(p0r) = scale*t0r;
		*(p0r+1) = scale*t0i;
		*(p0r+2) = scale*f1r;
		*(p0r+(2+1)) = scale*f1i;
		*(p0r+posA) = scale*t1r;
		*(p0r+posAi) = scale*t1i;
		*(p0r+posB) = scale*f3r;
		*(p0r+posBi) = scale*f3i;

	};
};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r10
leaq 0x3(%rsi), %rcx
movq %rcx, %rax
shrq $0x3f, %rax
addl %ecx, %eax
shrl %eax
movl $0x1, %esi
movl %eax, %ecx
shlq %cl, %rsi
movl $0x1, %r9d
movl %r10d, %ecx
shlq %cl, %r9
movq %r10, %r8
shrq $0x3f, %r8
addq %r10, %r8
sarq %r8
leal -0x1(%r8), %ecx
movq $-0x1, %r14
shlq %cl, %r14
movl $0x8, %r11d
movl %eax, %ecx
shlq %cl, %r11
testq %r11, %r11
jle 0x28f8a
movq %r9, %rax
subq %rsi, %rax
movq %rax, -0x38(%rsp)
notq %r14
leaq 0x1(%r10), %rax
shrq $0x3f, %rax
leaq (%r10,%rax), %rbx
incq %rbx
sarq %rbx
incq %rbx
incb %r8b
movl %r8d, %ecx
movl $0x1, %eax
shlq %cl, %rax
leaq 0x1(%r9), %rcx
movq %rcx, -0x20(%rsp)
leaq (%rdi,%rsi,8), %rcx
movq %rcx, -0x40(%rsp)
leaq (,%r9,8), %rcx
leaq (,%rsi,8), %r15
movq %rcx, %r8
subq %r15, %r8
leaq (%rdi,%r8), %r10
addq $0x8, %r10
movq %r10, -0x60(%rsp)
movq %rax, -0x30(%rsp)
leaq (,%rax,8), %rax
movq %rax, -0x48(%rsp)
shlq $0x4, %rsi
subq %rsi, %rcx
movq %rcx, -0x28(%rsp)
movq %r9, %rax
shlq $0x4, %rax
movq %rax, %rcx
subq %rsi, %rax
leaq 0x10(%rdi), %rsi
movq %rsi, -0x70(%rsp)
subq %r15, %rcx
negq %r15
addq %rdi, %rcx
movq %rcx, -0x68(%rsp)
addq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x78(%rsp)
addq %rdi, %r8
movq %r8, -0x58(%rsp)
movsd %xmm0, -0x50(%rsp)
movq %r14, -0x10(%rsp)
movq %rbx, -0x18(%rsp)
movq -0x38(%rsp), %rax
leaq (%rdi,%rax,8), %r12
movq %r14, %r10
movq %rdi, (%rsp)
movq %r12, -0x8(%rsp)
movswq (%rdx,%r10,2), %r11
movq %r11, %rsi
shlq $0x5, %rsi
leaq (%r12,%rsi), %rax
movq %r10, %r8
movl %ebx, %ecx
shlq %cl, %r8
movsd (%r12,%rsi), %xmm2
movsd 0x8(%r12,%rsi), %xmm7
movsd (%rax,%r9,8), %xmm15
movsd 0x8(%rax,%r9,8), %xmm11
cmpq %r14, %r10
jge 0x28e8d
shlq $0x2, %r11
leaq (%rdi,%r8,8), %r13
leaq (,%r11,8), %r12
movq -0x28(%rsp), %rax
movq %r11, 0x8(%rsp)
leaq (%rax,%r11,8), %rdi
movq -0x58(%rsp), %rcx
movq -0x78(%rsp), %r11
movq -0x68(%rsp), %r8
movq -0x70(%rsp), %rax
movq -0x60(%rsp), %rbx
movq %r14, %rsi
movsd -0x50(%rsp), %xmm6
movswq (%rdx,%rsi,2), %r14
shlq $0x5, %r14
leaq (%r14,%r13), %rbp
movsd 0x10(%rcx,%r12), %xmm10
movsd 0x18(%rcx,%r12), %xmm9
movsd 0x10(%r8,%r12), %xmm13
movsd 0x18(%r8,%r12), %xmm4
movsd (%r13,%r14), %xmm8
movsd 0x8(%r13,%r14), %xmm0
movsd (%rbp,%r9,8), %xmm3
movsd 0x8(%rbp,%r9,8), %xmm12
movsd 0x10(%r13,%r14), %xmm5
movsd 0x18(%r13,%r14), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rbp,%r9,8), %xmm1
movsd %xmm1, -0x80(%rsp)
movapd %xmm2, %xmm14
addsd %xmm15, %xmm14
subsd %xmm15, %xmm2
movapd %xmm7, %xmm1
addsd %xmm11, %xmm1
subsd %xmm11, %xmm7
movapd %xmm10, %xmm11
addsd %xmm13, %xmm11
subsd %xmm13, %xmm10
movapd %xmm9, %xmm15
addsd %xmm4, %xmm15
subsd %xmm4, %xmm9
movapd %xmm8, %xmm4
addsd %xmm3, %xmm4
subsd %xmm3, %xmm8
movapd %xmm0, %xmm13
addsd %xmm12, %xmm13
subsd %xmm12, %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm5, %xmm3
movsd -0x80(%rsp), %xmm0
addsd %xmm0, %xmm3
subsd %xmm0, %xmm5
movsd %xmm5, -0x80(%rsp)
movsd 0x18(%rbp,%r9,8), %xmm0
movsd 0x10(%rsp), %xmm12
movapd %xmm12, %xmm5
addsd %xmm0, %xmm5
subsd %xmm0, %xmm12
mulsd %xmm6, %xmm14
movsd %xmm14, (%r13,%r14)
mulsd %xmm6, %xmm1
movsd %xmm1, 0x8(%r13,%r14)
mulsd %xmm6, %xmm2
movsd %xmm2, 0x10(%r13,%r14)
mulsd %xmm6, %xmm7
movsd %xmm7, 0x18(%r13,%r14)
mulsd %xmm6, %xmm11
movsd %xmm11, (%rbp,%r9,8)
mulsd %xmm6, %xmm15
movsd %xmm15, 0x8(%rbp,%r9,8)
mulsd %xmm6, %xmm10
movsd %xmm10, 0x10(%rbp,%r9,8)
mulsd %xmm6, %xmm9
movsd %xmm9, 0x18(%rbp,%r9,8)
mulsd %xmm6, %xmm4
movsd %xmm4, (%rcx,%r12)
mulsd %xmm6, %xmm13
movsd %xmm13, 0x8(%rcx,%r12)
mulsd %xmm6, %xmm8
movsd %xmm8, 0x10(%rcx,%r12)
movsd 0x18(%rsp), %xmm1
mulsd %xmm6, %xmm1
movsd %xmm1, 0x18(%rcx,%r12)
mulsd %xmm6, %xmm3
movsd %xmm3, (%r8,%r12)
mulsd %xmm6, %xmm5
movsd %xmm5, 0x8(%r8,%r12)
movsd -0x80(%rsp), %xmm1
mulsd %xmm6, %xmm1
movsd %xmm1, 0x10(%r8,%r12)
mulsd %xmm6, %xmm12
movsd %xmm12, 0x18(%r8,%r12)
decq %rsi
movsd -0x10(%rax,%rdi), %xmm2
movsd -0x8(%rax,%rdi), %xmm7
movsd -0x8(%r11,%r12), %xmm15
movsd (%r11,%r12), %xmm11
addq %r15, %rbx
addq %r15, %rax
addq %r15, %r8
addq %r15, %r11
addq %r15, %rcx
cmpq %r10, %rsi
jg 0x28c71
movq 0x8(%rsp), %rdi
leaq (%rbx,%rdi,8), %r11
leaq (%r8,%rdi,8), %rsi
leaq (%rcx,%rdi,8), %rax
leaq (%r8,%rdi,8), %rcx
addq $0x8, %rcx
movq -0x10(%rsp), %r14
movq (%rsp), %rdi
movq -0x18(%rsp), %rbx
movq -0x8(%rsp), %r12
jmp 0x28ea2
leaq (%r12,%rsi), %r11
addq $0x8, %r11
leaq (%rax,%r9,8), %rsi
movq -0x20(%rsp), %rcx
leaq (%rax,%rcx,8), %rcx
movsd 0x10(%rax), %xmm1
movsd 0x18(%rax), %xmm10
movsd 0x10(%rax,%r9,8), %xmm3
movsd 0x18(%rax,%r9,8), %xmm4
movapd %xmm2, %xmm6
addsd %xmm15, %xmm6
movapd %xmm7, %xmm5
addsd %xmm11, %xmm5
subsd %xmm15, %xmm2
subsd %xmm11, %xmm7
movapd %xmm1, %xmm8
addsd %xmm3, %xmm8
movapd %xmm10, %xmm9
addsd %xmm4, %xmm9
subsd %xmm3, %xmm1
subsd %xmm4, %xmm10
movsd -0x50(%rsp), %xmm0
mulsd %xmm0, %xmm6
movsd %xmm6, (%rax)
mulsd %xmm0, %xmm5
movsd %xmm5, (%r11)
mulsd %xmm0, %xmm2
movsd %xmm2, 0x10(%rax)
mulsd %xmm0, %xmm7
movsd %xmm7, 0x18(%rax)
mulsd %xmm0, %xmm8
movsd %xmm8, (%rsi)
mulsd %xmm0, %xmm9
movsd %xmm9, (%rcx)
mulsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rax,%r9,8)
mulsd %xmm0, %xmm10
movsd %xmm10, 0x18(%rax,%r9,8)
leaq -0x1(%r10), %rax
testq %r10, %r10
movq %rax, %r10
jg 0x28bf6
movq -0x30(%rsp), %rax
leaq (%rdi,%rax,8), %rdi
movq -0x48(%rsp), %rax
addq %rax, -0x60(%rsp)
addq %rax, -0x70(%rsp)
addq %rax, -0x68(%rsp)
addq %rax, -0x78(%rsp)
addq %rax, -0x58(%rsp)
cmpq -0x40(%rsp), %rdi
jb 0x28be1
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq