// File: 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
movq %rsp, %rbp
subq $0xa8, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x3, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
subq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x10(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
subq $0x1, %rcx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0x120(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movl $0x2, %ecx
cqto
idivq %rcx
addq $0x1, %rax
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rax
movq -0x110(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jae 0x3ee5a
movq -0x120(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
jl 0x3ee2a
movq -0x120(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rax
movq -0x118(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq -0xe0(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq -0xe0(%rbp), %rdx
movq -0x128(%rbp), %rcx
shlq %cl, %rdx
movq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0xe8(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0xc0(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0xc0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xc0(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0xe8(%rbp), %rax
cmpq -0xe0(%rbp), %rax
jle 0x3ec8e
movq -0xc0(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0xc0(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xc0(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xc0(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0xc8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0xc8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0xc8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0xc8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0xc8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xc8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0xc8(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0xc8(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x20(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x28(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x40(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x60(%rbp), %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x68(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x60(%rbp), %xmm0
subsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x68(%rbp), %xmm0
subsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x80(%rbp), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x88(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x80(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x88(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0xa0(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0xa8(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x30(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x38(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0xb0(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0xb8(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x50(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x20(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x70(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x78(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0x40(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x48(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x90(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x98(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x110(%rbp), %rdx
movq -0xc0(%rbp), %rax
xorl %ecx, %ecx
subq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0xc0(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0xc0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0xc0(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0xe8(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xe8(%rbp)
movq -0xd0(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0xe8(%rbp), %rdx
movswl (%rcx,%rdx,2), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
jmp 0x3e85d
movq -0xc0(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0xc0(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xc0(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xc0(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x20(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x28(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x40(%rbp), %xmm0
subsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0xa0(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0xa8(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x30(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x38(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0xb0(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0xb8(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0xf8(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x50(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0x100(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movq -0xc0(%rbp), %rax
movq -0x108(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xe0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x3e76b
jmp 0x3ee2c
movq -0x10(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
addq $0x1, %rcx
movl $0x1, %eax
shlq %cl, %rax
shlq $0x3, %rax
addq -0x8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3e74c
addq $0xa8, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)