// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: bfR4(double*, long, long)
inline void bfR4(Float_t *ioptr, long M, long NDiffU){
/*** 1 radix 4 stage ***/
unsigned long	pos;
unsigned long	posi;
unsigned long	pinc;
unsigned long	pnext;
unsigned long	pnexti;
unsigned long 	NSameU;
unsigned long 	SameUCnt;

Float_t	*pstrt;
Float_t 	*p0r, *p1r, *p2r, *p3r;

Float_t w1r = 1.0/MYROOT2; /* cos(pi/4)	*/
Float_t f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
Float_t f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
Float_t t1r, t1i;
const Float_t Two = 2.0;

pinc = NDiffU * 2;		// 2 floats per complex
pnext =  pinc * 4;
pnexti =  pnext + 1;
pos = 2;
posi = pos+1;
NSameU = POW2(M) / 4 /NDiffU;	// 4 pts per butterfly
pstrt = ioptr;
p0r = pstrt;
p1r = pstrt+pinc;
p2r = p1r+pinc;
p3r = p2r+pinc;

		/* Butterflys		*/
		/*
		f0	-	-	f0	-	-	f4
		f1	-  1 -	f5	-	-	f5
		f2	-	-	f6	-  1 -	f6
		f3	-  1 -	f3	- -i -	f7
		*/
		/* Butterflys		*/
		/*
		f0	-	-	f4	-	-	f4
		f1	- -i -	t1	-	-	f5
		f2	-	-	f2	- w1 -	f6
		f3	- -i -	f7	- iw1-	f7
		*/

f0r = *p0r;
f1r = *p1r;
f2r = *p2r;
f3r = *p3r;
f0i = *(p0r + 1);
f1i = *(p1r + 1);
f2i = *(p2r + 1);
f3i = *(p3r + 1);

f5r = f0r - f1r;
f5i = f0i - f1i;
f0r = f0r + f1r;
f0i = f0i + f1i;

f6r = f2r + f3r;
f6i = f2i + f3i;
f3r = f2r - f3r;
f3i = f2i - f3i;

for (SameUCnt = NSameU-1; SameUCnt > 0 ; SameUCnt--){

	f7r = f5r - f3i;
	f7i = f5i + f3r;
	f5r = f5r + f3i;
	f5i = f5i - f3r;

	f4r = f0r + f6r;
	f4i = f0i + f6i;
	f6r = f0r - f6r;
	f6i = f0i - f6i;

	f2r = *(p2r + pos);
	f2i = *(p2r + posi);
	f1r = *(p1r + pos);
	f1i = *(p1r + posi);
	f3i = *(p3r + posi);
	f0r = *(p0r + pos);
	f3r = *(p3r + pos);
	f0i = *(p0r + posi);

	*p3r = f7r;
	*p0r = f4r;
	*(p3r + 1) = f7i;
	*(p0r + 1) = f4i;
	*p1r = f5r;
	*p2r = f6r;
	*(p1r + 1) = f5i;
	*(p2r + 1) = f6i;

	f7r = f2r - f3i;
	f7i = f2i + f3r;
	f2r = f2r + f3i;
	f2i = f2i - f3r;

	f4r = f0r + f1i;
	f4i = f0i - f1r;
	t1r = f0r - f1i;
	t1i = f0i + f1r;

	f5r = t1r - f7r * w1r + f7i * w1r;
	f5i = t1i - f7r * w1r - f7i * w1r;
	f7r = t1r * Two - f5r;
	f7i = t1i * Two - f5i;

	f6r = f4r - f2r * w1r - f2i * w1r;
	f6i = f4i + f2r * w1r - f2i * w1r;
	f4r = f4r * Two - f6r;
	f4i = f4i * Two - f6i;

	f3r = *(p3r + pnext);
	f0r = *(p0r + pnext);
	f3i = *(p3r + pnexti);
	f0i = *(p0r + pnexti);
	f2r = *(p2r + pnext);
	f2i = *(p2r + pnexti);
	f1r = *(p1r + pnext);
	f1i = *(p1r + pnexti);

	*(p2r + pos) = f6r;
	*(p1r + pos) = f5r;
	*(p2r + posi) = f6i;
	*(p1r + posi) = f5i;
	*(p3r + pos) = f7r;
	*(p0r + pos) = f4r;
	*(p3r + posi) = f7i;
	*(p0r + posi) = f4i;

	f6r = f2r + f3r;
	f6i = f2i + f3i;
	f3r = f2r - f3r;
	f3i = f2i - f3i;

	f5r = f0r - f1r;
	f5i = f0i - f1i;
	f0r = f0r + f1r;
	f0i = f0i + f1i;

	p3r += pnext;
	p0r += pnext;
	p1r += pnext;
	p2r += pnext;

}
f7r = f5r - f3i;
f7i = f5i + f3r;
f5r = f5r + f3i;
f5i = f5i - f3r;

f4r = f0r + f6r;
f4i = f0i + f6i;
f6r = f0r - f6r;
f6i = f0i - f6i;

f2r = *(p2r + pos);
f2i = *(p2r + posi);
f1r = *(p1r + pos);
f1i = *(p1r + posi);
f3i = *(p3r + posi);
f0r = *(p0r + pos);
f3r = *(p3r + pos);
f0i = *(p0r + posi);

*p3r = f7r;
*p0r = f4r;
*(p3r + 1) = f7i;
*(p0r + 1) = f4i;
*p1r = f5r;
*p2r = f6r;
*(p1r + 1) = f5i;
*(p2r + 1) = f6i;

f7r = f2r - f3i;
f7i = f2i + f3r;
f2r = f2r + f3i;
f2i = f2i - f3r;

f4r = f0r + f1i;
f4i = f0i - f1r;
t1r = f0r - f1i;
t1i = f0i + f1r;

f5r = t1r - f7r * w1r + f7i * w1r;
f5i = t1i - f7r * w1r - f7i * w1r;
f7r = t1r * Two - f5r;
f7i = t1i * Two - f5i;

f6r = f4r - f2r * w1r - f2i * w1r;
f6i = f4i + f2r * w1r - f2i * w1r;
f4r = f4r * Two - f6r;
f4i = f4i * Two - f6i;

*(p2r + pos) = f6r;
*(p1r + pos) = f5r;
*(p2r + posi) = f6i;
*(p1r + posi) = f5i;
*(p3r + pos) = f7r;
*(p0r + pos) = f4r;
*(p3r + posi) = f7i;
*(p0r + posi) = f4i;

}

// Assembly:
pushq %rbx
movq %rsi, %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rdx, %rcx
shrq $0x2, %rax
xorl %edx, %edx
divq %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
leaq (%rdi,%rdx), %r8
leaq (%r8,%rdx), %rsi
movsd (%rdi), %xmm1
movsd 0x8(%rdi), %xmm0
movsd (%rdi,%rdx), %xmm5
movsd 0x8(%rdi,%rdx), %xmm6
movsd (%rdx,%r8), %xmm4
movsd 0x8(%rdx,%r8), %xmm2
movsd (%rdx,%rsi), %xmm10
movsd 0x8(%rdx,%rsi), %xmm11
movapd %xmm1, %xmm9
subsd %xmm5, %xmm9
movapd %xmm0, %xmm3
subsd %xmm6, %xmm3
addsd %xmm5, %xmm1
addsd %xmm6, %xmm0
movapd %xmm4, %xmm7
addsd %xmm10, %xmm7
movapd %xmm2, %xmm8
addsd %xmm11, %xmm8
subsd %xmm10, %xmm4
subsd %xmm11, %xmm2
decq %rax
je 0x277c4
movq %rcx, %r8
shlq $0x6, %r8
leaq (%rdx,%rdx,2), %r9
imulq $0x70, %rcx, %r10
movq %rcx, %rsi
shlq $0x5, %rsi
leaq (%rsi,%rsi,2), %r11
leaq (%rdx,%rdx,4), %rbx
movapd %xmm9, %xmm10
subsd %xmm2, %xmm10
movapd %xmm4, %xmm11
addsd %xmm3, %xmm11
addsd %xmm9, %xmm2
subsd %xmm4, %xmm3
movapd %xmm1, %xmm12
addsd %xmm7, %xmm12
movapd %xmm0, %xmm13
addsd %xmm8, %xmm13
subsd %xmm7, %xmm1
subsd %xmm8, %xmm0
movsd 0x10(%rdi,%rsi), %xmm8
movsd 0x18(%rdi,%rsi), %xmm4
movsd 0x10(%rdi,%rdx), %xmm7
movsd 0x18(%rdi,%rdx), %xmm14
movsd 0x10(%rdi,%r9), %xmm15
movsd 0x18(%rdi,%r9), %xmm5
movsd 0x10(%rdi), %xmm9
movsd 0x18(%rdi), %xmm6
movsd %xmm10, (%rdi,%r9)
movsd %xmm12, (%rdi)
movsd %xmm11, 0x8(%rdi,%r9)
movsd %xmm13, 0x8(%rdi)
movsd %xmm2, (%rdi,%rdx)
movsd %xmm1, (%rdi,%rsi)
movsd %xmm3, 0x8(%rdi,%rdx)
movsd %xmm0, 0x8(%rdi,%rsi)
movapd %xmm8, %xmm3
subsd %xmm5, %xmm3
movapd %xmm4, %xmm0
addsd %xmm15, %xmm0
addsd %xmm5, %xmm8
subsd %xmm15, %xmm4
movapd %xmm14, %xmm10
addsd %xmm9, %xmm10
movapd %xmm6, %xmm11
subsd %xmm7, %xmm11
subsd %xmm14, %xmm9
addsd %xmm6, %xmm7
movapd 0x4e07(%rip), %xmm1     # 0x2c490
xorpd %xmm1, %xmm3
movsd 0x820b(%rip), %xmm2     # 0x2f8a0
mulsd %xmm2, %xmm3
movapd %xmm3, %xmm12
addsd %xmm9, %xmm12
mulsd %xmm2, %xmm0
addsd %xmm0, %xmm12
addsd %xmm7, %xmm3
subsd %xmm0, %xmm3
mulsd %xmm2, %xmm8
movapd %xmm10, %xmm5
subsd %xmm8, %xmm5
xorpd %xmm1, %xmm4
mulsd %xmm2, %xmm4
addsd %xmm4, %xmm5
addsd %xmm11, %xmm8
addsd %xmm4, %xmm8
addsd %xmm10, %xmm10
subsd %xmm5, %xmm10
movsd (%rdi,%r10), %xmm6
movsd 0x8(%rdi,%r10), %xmm14
movsd (%rdi,%r8), %xmm1
movsd 0x8(%rdi,%r8), %xmm0
movsd (%rdi,%r11), %xmm4
movsd 0x8(%rdi,%r11), %xmm2
movsd (%rdi,%rbx), %xmm15
movsd 0x8(%rdi,%rbx), %xmm13
movsd %xmm5, 0x10(%rdi,%rsi)
addsd %xmm9, %xmm9
subsd %xmm12, %xmm9
movsd %xmm12, 0x10(%rdi,%rdx)
addsd %xmm11, %xmm11
subsd %xmm8, %xmm11
movsd %xmm8, 0x18(%rdi,%rsi)
addsd %xmm7, %xmm7
subsd %xmm3, %xmm7
movsd %xmm3, 0x18(%rdi,%rdx)
movsd %xmm9, 0x10(%rdi,%r9)
movsd %xmm10, 0x10(%rdi)
movsd %xmm7, 0x18(%rdi,%r9)
movsd %xmm11, 0x18(%rdi)
movapd %xmm6, %xmm7
addsd %xmm4, %xmm7
subsd %xmm6, %xmm4
movapd %xmm14, %xmm8
addsd %xmm2, %xmm8
subsd %xmm14, %xmm2
movapd %xmm1, %xmm9
subsd %xmm15, %xmm9
addsd %xmm15, %xmm1
movapd %xmm0, %xmm3
subsd %xmm13, %xmm3
addsd %xmm13, %xmm0
addq %r8, %rdi
decq %rax
jne 0x275ad
leaq (%rcx,%rcx,2), %rax
shlq $0x4, %rax
addq %rdi, %rax
addq %rdi, %rsi
addq %rdi, %rdx
movq %rdx, %r8
movq %rax, %rdx
jmp 0x277c7
addq %rsi, %rdx
movapd %xmm9, %xmm10
subsd %xmm2, %xmm10
movapd %xmm4, %xmm11
addsd %xmm3, %xmm11
addsd %xmm9, %xmm2
subsd %xmm4, %xmm3
movapd %xmm1, %xmm9
addsd %xmm7, %xmm9
movapd %xmm0, %xmm12
addsd %xmm8, %xmm12
subsd %xmm7, %xmm1
subsd %xmm8, %xmm0
movsd 0x10(%rsi), %xmm5
movsd 0x18(%rsi), %xmm7
movsd 0x10(%r8), %xmm4
movsd 0x18(%r8), %xmm8
movsd 0x10(%rdx), %xmm13
movsd 0x18(%rdx), %xmm14
movsd 0x10(%rdi), %xmm6
movsd 0x18(%rdi), %xmm15
movsd %xmm10, (%rdx)
movsd %xmm9, (%rdi)
movsd %xmm11, 0x8(%rdx)
movsd %xmm12, 0x8(%rdi)
movsd %xmm2, (%r8)
movsd %xmm1, (%rsi)
movsd %xmm3, 0x8(%r8)
movsd %xmm0, 0x8(%rsi)
movapd %xmm5, %xmm0
subsd %xmm14, %xmm0
movapd %xmm7, %xmm9
addsd %xmm13, %xmm9
addsd %xmm14, %xmm5
subsd %xmm13, %xmm7
movapd %xmm8, %xmm1
addsd %xmm6, %xmm1
movapd %xmm15, %xmm2
subsd %xmm4, %xmm2
subsd %xmm8, %xmm6
addsd %xmm15, %xmm4
movapd 0x4bf6(%rip), %xmm8     # 0x2c490
xorpd %xmm8, %xmm0
movsd 0x7ff8(%rip), %xmm10    # 0x2f8a0
mulsd %xmm10, %xmm0
movapd %xmm0, %xmm3
addsd %xmm6, %xmm3
mulsd %xmm10, %xmm9
addsd %xmm9, %xmm3
addsd %xmm4, %xmm0
subsd %xmm9, %xmm0
addsd %xmm6, %xmm6
subsd %xmm3, %xmm6
addsd %xmm4, %xmm4
subsd %xmm0, %xmm4
mulsd %xmm10, %xmm5
movapd %xmm1, %xmm9
subsd %xmm5, %xmm9
xorpd %xmm8, %xmm7
mulsd %xmm10, %xmm7
addsd %xmm7, %xmm9
addsd %xmm2, %xmm5
addsd %xmm7, %xmm5
addsd %xmm1, %xmm1
subsd %xmm9, %xmm1
addsd %xmm2, %xmm2
subsd %xmm5, %xmm2
movsd %xmm9, 0x10(%rsi)
movsd %xmm3, 0x10(%r8)
movsd %xmm5, 0x18(%rsi)
movsd %xmm0, 0x18(%r8)
movsd %xmm6, 0x10(%rdx)
movsd %xmm1, 0x10(%rdi)
movsd %xmm4, 0x18(%rdx)
movsd %xmm2, 0x18(%rdi)
popq %rbx
retq