// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: bitrevR2(double*, long, short*)
inline void bitrevR2(Float_t *ioptr, long M, short *BRLow){
/*** bit reverse and first radix 2 stage of 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) = t0r;
			*(p1r+1) = t0i;
			*(p1r+2) = f1r;
			*(p1r+(2+1)) = f1i;
			*(p1r+posA) = t1r;
			*(p1r+posAi) = t1i;
			*(p1r+posB) = f3r;
			*(p1r+posBi) = f3i;
			*(p0r) = f0r;
			*(p0r+1) = f0i;
			*(p0r+2) = f5r;
			*(p0r+(2+1)) = f5i;
			*(p0r+posA) = f2r;
			*(p0r+posAi) = f2i;
			*(p0r+posB) = f7r;
			*(p0r+posBi) = 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) = t0r;
		*(p0r+1) = t0i;
		*(p0r+2) = f1r;
		*(p0r+(2+1)) = f1i;
		*(p0r+posA) = t1r;
		*(p0r+posAi) = t1i;
		*(p0r+posB) = f3r;
		*(p0r+posBi) = 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, %r11
shrq $0x3f, %r11
addq %rsi, %r11
sarq %r11
leal -0x1(%r11), %ecx
movq $-0x1, %r14
shlq %cl, %r14
movl $0x8, %r8d
movl %eax, %ecx
shlq %cl, %r8
testq %r8, %r8
jle 0x26cfc
movq %r9, %rax
subq %r10, %rax
movq %rax, -0x28(%rsp)
notq %r14
leaq 0x1(%rsi), %rax
shrq $0x3f, %rax
leaq (%rsi,%rax), %r8
incq %r8
sarq %r8
incq %r8
leaq 0x1(%r9), %rax
movq %rax, -0x18(%rsp)
leaq (%rdi,%r10,8), %rax
movq %rax, -0x30(%rsp)
incb %r11b
movl %r11d, %ecx
movl $0x1, %eax
shlq %cl, %rax
leaq (,%r9,8), %rsi
leaq (,%r10,8), %r15
movq %rsi, %rcx
subq %r15, %rcx
addq %rdi, %rcx
movq %rcx, -0x48(%rsp)
movq %rax, -0x20(%rsp)
leaq (,%rax,8), %rax
movq %rax, -0x38(%rsp)
movq %r9, %rax
shlq $0x4, %rax
movq %rax, %rcx
subq %r15, %rcx
negq %r15
addq %rdi, %rcx
addq $0x8, %rcx
movq %rcx, -0x58(%rsp)
shlq $0x4, %r10
subq %r10, %rsi
addq %rdi, %rsi
movq %rsi, -0x40(%rsp)
subq %r10, %rax
addq %rdi, %rax
movq %rax, -0x50(%rsp)
movq %r8, -0x10(%rsp)
movq -0x28(%rsp), %rax
leaq (%rdi,%rax,8), %r11
movq %r14, %r10
movq %rdi, -0x8(%rsp)
movswq (%rdx,%r10,2), %r13
movq %r13, %rax
shlq $0x5, %rax
movq %r10, %rbx
movl %r8d, %ecx
shlq %cl, %rbx
leaq (%r11,%rax), %rsi
movupd (%r11,%rax), %xmm0
movupd (%rsi,%r9,8), %xmm1
cmpq %r14, %r10
jge 0x26c6b
shlq $0x2, %r13
leaq (%rdi,%rbx,8), %rsi
movq -0x50(%rsp), %rbp
movq -0x40(%rsp), %rdi
movq -0x58(%rsp), %rcx
movq -0x48(%rsp), %r12
movq %r14, %r8
movq %r14, %rbx
movswq (%rdx,%rbx,2), %r14
shlq $0x5, %r14
leaq (%rsi,%r14), %rax
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
movupd 0x10(%r12,%r13,8), %xmm3
movupd 0x8(%rcx,%r13,8), %xmm4
movapd %xmm3, %xmm5
addpd %xmm4, %xmm5
subpd %xmm1, %xmm0
subpd %xmm4, %xmm3
movupd (%rsi,%r14), %xmm1
movupd 0x10(%rsi,%r14), %xmm4
movupd (%rax,%r9,8), %xmm6
movupd 0x10(%rax,%r9,8), %xmm7
movapd %xmm4, %xmm8
addpd %xmm7, %xmm8
subpd %xmm7, %xmm4
movapd %xmm1, %xmm7
addpd %xmm6, %xmm7
subpd %xmm6, %xmm1
movupd %xmm2, (%rsi,%r14)
movupd %xmm0, 0x10(%rsi,%r14)
movupd %xmm5, (%rax,%r9,8)
movupd %xmm3, 0x10(%rax,%r9,8)
movupd %xmm7, (%r12,%r13,8)
movupd %xmm1, 0x10(%r12,%r13,8)
movupd %xmm8, -0x8(%rcx,%r13,8)
movupd %xmm4, 0x8(%rcx,%r13,8)
decq %rbx
movupd (%rdi,%r13,8), %xmm0
movupd (%rbp,%r13,8), %xmm1
addq %r15, %r12
addq %r15, %rcx
addq %r15, %rdi
addq %r15, %rbp
cmpq %r10, %rbx
jg 0x26b86
leaq (%r12,%r13,8), %rsi
leaq (%r12,%r13,8), %rax
addq $0x8, %rax
leaq (%rcx,%r13,8), %rbx
leaq -0x8(%rcx,%r13,8), %rcx
movq -0x8(%rsp), %rdi
movq %r8, %r14
movq -0x10(%rsp), %r8
jmp 0x26c7f
addq %r11, %rax
addq $0x8, %rax
leaq (%rsi,%r9,8), %rcx
movq -0x18(%rsp), %rbx
leaq (%rsi,%rbx,8), %rbx
movapd %xmm0, %xmm2
addpd %xmm1, %xmm2
subpd %xmm1, %xmm0
movupd 0x10(%rsi), %xmm1
movupd 0x10(%rsi,%r9,8), %xmm3
movapd %xmm1, %xmm4
addpd %xmm3, %xmm4
subpd %xmm3, %xmm1
movlpd %xmm2, (%rsi)
movhpd %xmm2, (%rax)
movupd %xmm0, 0x10(%rsi)
movlpd %xmm4, (%rcx)
movhpd %xmm4, (%rbx)
movupd %xmm1, 0x10(%rsi,%r9,8)
leaq -0x1(%r10), %rax
testq %r10, %r10
movq %rax, %r10
jg 0x26b36
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 0x26b25
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq