// File: /workspace/github_cpp_makefile_star2_O3/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
leaq 0x3(%rsi), %rcx
movq %rcx, %rax
shrq $0x3f, %rax
addl %ecx, %eax
shrl %eax
movl $0x1, %r10d
movl %eax, %ecx
shlq %cl, %r10
movl $0x1, %r9d
movl %esi, %ecx
shlq %cl, %r9
movq %rsi, %r8
shrq $0x3f, %r8
addq %rsi, %r8
sarq %r8
leal -0x1(%r8), %ecx
movq $-0x1, %rbx
shlq %cl, %rbx
movl $0x8, %r11d
movl %eax, %ecx
shlq %cl, %r11
testq %r11, %r11
jle 0x284b6
movq %r9, %rax
subq %r10, %rax
movq %rax, -0x28(%rsp)
notq %rbx
leaq 0x1(%rsi), %rax
shrq $0x3f, %rax
leaq (%rsi,%rax), %r14
incq %r14
sarq %r14
incq %r14
leaq 0x1(%r9), %rax
movq %rax, -0x18(%rsp)
incb %r8b
movl %r8d, %ecx
movl $0x1, %eax
shlq %cl, %rax
leaq (%rdi,%r10,8), %rcx
movq %rcx, -0x30(%rsp)
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
leaq (,%r9,8), %rcx
leaq (,%r10,8), %r15
movq %rcx, %rsi
subq %r15, %rsi
addq %rdi, %rsi
movq %rsi, -0x48(%rsp)
movq %rax, -0x20(%rsp)
leaq (,%rax,8), %rax
movq %rax, -0x38(%rsp)
movq %r9, %rsi
shlq $0x4, %rsi
movq %rsi, %rax
subq %r15, %rax
negq %r15
addq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x58(%rsp)
shlq $0x4, %r10
subq %r10, %rcx
addq %rdi, %rcx
movq %rcx, -0x40(%rsp)
subq %r10, %rsi
addq %rdi, %rsi
movq %rsi, -0x50(%rsp)
movq %r14, -0x10(%rsp)
movq -0x28(%rsp), %rax
leaq (%rdi,%rax,8), %r8
movq %rbx, %r10
movq %rdi, -0x8(%rsp)
movswq (%rdx,%r10,2), %r13
movq %r13, %rax
shlq $0x5, %rax
movq %r10, %r11
movl %r14d, %ecx
shlq %cl, %r11
leaq (%r8,%rax), %rsi
movupd (%r8,%rax), %xmm2
movupd (%rsi,%r9,8), %xmm3
cmpq %rbx, %r10
jge 0x283f7
shlq $0x2, %r13
leaq (%rdi,%r11,8), %rsi
movq -0x50(%rsp), %rbp
movq -0x40(%rsp), %rdi
movq -0x58(%rsp), %rcx
movq -0x48(%rsp), %r12
movq %rbx, %r14
movq %rbx, %r11
movswq (%rdx,%r11,2), %rbx
shlq $0x5, %rbx
leaq (%rsi,%rbx), %rax
movapd %xmm2, %xmm5
addpd %xmm3, %xmm5
movupd 0x10(%r12,%r13,8), %xmm4
movupd 0x8(%rcx,%r13,8), %xmm7
movapd %xmm4, %xmm6
addpd %xmm7, %xmm6
mulpd %xmm1, %xmm5
subpd %xmm3, %xmm2
mulpd %xmm1, %xmm2
mulpd %xmm1, %xmm6
subpd %xmm7, %xmm4
mulpd %xmm1, %xmm4
movupd (%rsi,%rbx), %xmm7
movupd 0x10(%rsi,%rbx), %xmm3
movupd (%rax,%r9,8), %xmm8
movupd 0x10(%rax,%r9,8), %xmm9
movapd %xmm3, %xmm10
addpd %xmm9, %xmm10
movapd %xmm10, %xmm11
unpckhpd %xmm10, %xmm11          # xmm11 = xmm11[1],xmm10[1]
subpd %xmm9, %xmm3
movapd %xmm7, %xmm9
addpd %xmm8, %xmm9
movapd %xmm9, %xmm12
unpckhpd %xmm9, %xmm12           # xmm12 = xmm12[1],xmm9[1]
subpd %xmm8, %xmm7
mulsd %xmm0, %xmm9
mulsd %xmm0, %xmm12
mulpd %xmm1, %xmm7
movupd %xmm5, (%rsi,%rbx)
movupd %xmm2, 0x10(%rsi,%rbx)
movupd %xmm6, (%rax,%r9,8)
movupd %xmm4, 0x10(%rax,%r9,8)
movsd %xmm9, (%r12,%r13,8)
movsd %xmm12, 0x8(%r12,%r13,8)
movupd %xmm7, 0x10(%r12,%r13,8)
mulsd %xmm0, %xmm10
movsd %xmm10, -0x8(%rcx,%r13,8)
mulsd %xmm0, %xmm11
movsd %xmm11, (%rcx,%r13,8)
mulpd %xmm1, %xmm3
movupd %xmm3, 0x8(%rcx,%r13,8)
decq %r11
movupd (%rdi,%r13,8), %xmm2
movupd (%rbp,%r13,8), %xmm3
addq %r15, %r12
addq %r15, %rcx
addq %r15, %rdi
addq %r15, %rbp
cmpq %r10, %r11
jg 0x282c5
leaq (%r12,%r13,8), %rsi
leaq (%r12,%r13,8), %r11
addq $0x8, %r11
leaq (%rcx,%r13,8), %rax
leaq -0x8(%rcx,%r13,8), %rcx
movq -0x8(%rsp), %rdi
movq %r14, %rbx
movq -0x10(%rsp), %r14
jmp 0x2840c
leaq (%r8,%rax), %r11
addq $0x8, %r11
leaq (%rsi,%r9,8), %rcx
movq -0x18(%rsp), %rax
leaq (%rsi,%rax,8), %rax
movapd %xmm2, %xmm4
addpd %xmm3, %xmm4
movapd %xmm4, %xmm5
unpckhpd %xmm4, %xmm5            # xmm5 = xmm5[1],xmm4[1]
subpd %xmm3, %xmm2
mulsd %xmm0, %xmm4
mulsd %xmm0, %xmm5
movupd 0x10(%rsi), %xmm3
movupd 0x10(%rsi,%r9,8), %xmm6
movapd %xmm3, %xmm7
addpd %xmm6, %xmm7
movapd %xmm7, %xmm8
unpckhpd %xmm7, %xmm8            # xmm8 = xmm8[1],xmm7[1]
subpd %xmm6, %xmm3
movsd %xmm4, (%rsi)
movsd %xmm5, (%r11)
mulpd %xmm1, %xmm2
movupd %xmm2, 0x10(%rsi)
mulsd %xmm0, %xmm7
movsd %xmm7, (%rcx)
mulsd %xmm0, %xmm8
movsd %xmm8, (%rax)
mulpd %xmm1, %xmm3
movupd %xmm3, 0x10(%rsi,%r9,8)
leaq -0x1(%r10), %rax
testq %r10, %r10
movq %rax, %r10
jg 0x28275
movq -0x20(%rsp), %rax
leaq (%rdi,%rax,8), %rdi
movq -0x38(%rsp), %rax
addq %rax, -0x48(%rsp)
addq %rax, -0x58(%rsp)
addq %rax, -0x40(%rsp)
addq %rax, -0x50(%rsp)
cmpq -0x30(%rsp), %rdi
jb 0x28264
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq