// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/FFT/fftlib.cpp
// Function: frstage(double*, long, double*)
inline void frstage(Float_t *ioptr, long M, Float_t *Utbl){
/*	Finish RFFT		*/

unsigned long 	pos;
unsigned long 	posi;
unsigned long 	diffUcnt;

Float_t 	*p0r, *p1r;
Float_t 	*u0r, *u0i;

Float_t w0r, w0i;
Float_t f0r, f0i, f1r, f1i, f4r, f4i, f5r, f5i;
Float_t t0r, t0i, t1r, t1i;
const Float_t Two = 2.0;

pos = POW2(M-1);
posi = pos + 1;

p0r = ioptr;
p1r = ioptr + pos/2;

u0r = Utbl + POW2(M-3);

w0r =  *u0r,

f0r = *(p0r);
f0i = *(p0r + 1);
f4r = *(p0r + pos);
f4i = *(p0r + posi);
f1r = *(p1r);
f1i = *(p1r + 1);
f5r = *(p1r + pos);
f5i = *(p1r + posi);

	t0r = Two * f0r + Two * f0i;    /* compute Re(x[0]) */
	t0i = Two * f0r - Two * f0i;    /* compute Re(x[N/2]) */
	t1r = f4r + f4r;
	t1i = -f4i - f4i;

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

	f1r = f0r + w0r * f4r + w0r * f4i;
	f1i = f0i - w0r * f4r + w0r * f4i;
	f5r = Two * f0r - f1r;
	f5i = f1i - Two * f0i;

*(p0r) = t0r;
*(p0r + 1) = t0i;
*(p0r + pos) = t1r;
*(p0r + posi) = t1i;
*(p1r) = f1r;
*(p1r + 1) = f1i;
*(p1r + pos) = f5r;
*(p1r + posi) = f5i;

u0r = Utbl + 1;
u0i = Utbl + (POW2(M-2)-1);

w0r =  *u0r,
w0i =  *u0i;
	
p0r = (ioptr + 2);
p1r = (ioptr + (POW2(M-2)-1)*2);

				/* Butterflys */
				/*
		f0	-	t0	-	-	f0
		f5	-	t1	- w0	-	f5

		f1	-	t0	-	-	f1
		f4	-	t1	-iw0 -	f4
				*/

for (diffUcnt = POW2(M-3)-1; diffUcnt > 0 ; diffUcnt--){

	f0r = *(p0r);
	f0i = *(p0r + 1);
	f5r = *(p1r + pos);
	f5i = *(p1r + posi);
	f1r = *(p1r);
	f1i = *(p1r + 1);
	f4r = *(p0r + pos);
	f4i = *(p0r + posi);

	t0r = f0r + f5r;
	t0i = f0i - f5i;
	t1r = f0i + f5i;
	t1i = f5r - f0r;

	f0r = t0r + w0r * t1r + w0i * t1i;
	f0i = t0i - w0i * t1r + w0r * t1i;
	f5r = Two * t0r - f0r;
	f5i = f0i - Two * t0i;

	t0r = f1r + f4r;
	t0i = f1i - f4i;
	t1r = f1i + f4i;
	t1i = f4r - f1r;

	f1r = t0r + w0i * t1r + w0r * t1i;
	f1i = t0i - w0r * t1r + w0i * t1i;
	f4r = Two * t0r - f1r;
	f4i = f1i - Two * t0i;

	*(p0r) = f0r;
	*(p0r + 1) = f0i;
	*(p1r + pos) = f5r;
	*(p1r + posi) = f5i;

	w0r = *++u0r;
	w0i = *--u0i;

	*(p1r) = f1r;
	*(p1r + 1) = f1i;
	*(p0r + pos) = f4r;
	*(p0r + posi) = f4i;

	p0r += 2;
	p1r -= 2;
};
}

// Assembly:
leal -0x1(%rsi), %ecx
movl $0x1, %eax
movl $0x1, %r8d
shlq %cl, %r8
movq %r8, %r10
andq $-0x2, %r10
leal -0x3(%rsi), %ecx
movl $0x1, %r9d
shlq %cl, %r9
leaq (%rdi,%r10,4), %rcx
movsd (%rdx,%r9,8), %xmm6
movsd (%rdi), %xmm2
movsd 0x8(%rdi), %xmm5
movsd (%rdi,%r8,8), %xmm3
movsd 0x8(%rdi,%r8,8), %xmm1
addsd %xmm5, %xmm5
movapd 0x27c0(%rip), %xmm0     # 0x2b480
movapd %xmm5, %xmm9
xorpd %xmm0, %xmm9
addsd %xmm3, %xmm3
movapd %xmm1, %xmm7
xorpd %xmm0, %xmm7
subsd %xmm1, %xmm7
movupd (%rcx), %xmm10
movupd (%rcx,%r8,8), %xmm1
movapd %xmm10, %xmm8
addpd %xmm1, %xmm8
movapd %xmm10, %xmm4
subpd %xmm1, %xmm4
movapd %xmm6, %xmm11
subsd %xmm10, %xmm1
mulsd %xmm6, %xmm1
xorpd %xmm0, %xmm6
movsd %xmm8, %xmm4            # xmm4 = xmm8[0],xmm4[1]
unpcklpd %xmm9, %xmm5            # xmm5 = xmm5[0],xmm9[0]
addsd %xmm2, %xmm2
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
addpd %xmm5, %xmm2
movupd %xmm2, (%rdi)
movsd %xmm3, (%rdi,%r8,8)
movsd %xmm7, 0x8(%rdi,%r8,8)
unpcklpd %xmm6, %xmm11           # xmm11 = xmm11[0],xmm6[0]
unpckhpd %xmm8, %xmm8            # xmm8 = xmm8[1,1]
mulpd %xmm11, %xmm8
addpd %xmm4, %xmm8
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
addpd %xmm8, %xmm1
movapd %xmm1, %xmm2
xorpd %xmm0, %xmm2
shufpd $0x2, %xmm1, %xmm2      # xmm2 = xmm2[0],xmm1[1]
mulpd 0x5bcd(%rip), %xmm4     # 0x2e930
addpd %xmm2, %xmm4
movupd %xmm1, (%rcx)
movupd %xmm4, (%rcx,%r8,8)
cmpq $0x1, %r9
je 0x28f07
addb $-0x2, %sil
movq $-0x1, %r10
movl %esi, %ecx
shlq %cl, %r10
movq %r10, %rcx
notq %rcx
movsd 0x8(%rdx), %xmm2
movhpd (%rdx,%rcx,8), %xmm2    # xmm2 = xmm2[0],mem[0]
shlq $0x4, %rcx
subq %r9, %rax
leaq (,%r10,8), %rsi
negq %rsi
addq %rdx, %rsi
addq $-0x10, %rsi
addq %r10, %r10
negq %r10
leaq (%r8,%r10), %r9
addq $-0x2, %r9
addq $0x2, %r8
movl $0x8, %r10d
xorl %r11d, %r11d
movapd 0x5b59(%rip), %xmm1     # 0x2e930
movapd %xmm2, %xmm12
unpckhpd %xmm2, %xmm12           # xmm12 = xmm12[1],xmm2[1]
movupd (%rdi,%rcx), %xmm8
movupd (%rdi,%r8,8), %xmm3
movapd %xmm8, %xmm5
addpd %xmm3, %xmm5
movapd %xmm8, %xmm4
subpd %xmm3, %xmm4
movupd (%rdi,%r10,2), %xmm11
movupd (%rdi,%r9,8), %xmm6
movapd %xmm11, %xmm9
addpd %xmm6, %xmm9
movapd %xmm11, %xmm7
subpd %xmm6, %xmm7
movapd %xmm9, %xmm10
unpckhpd %xmm9, %xmm10           # xmm10 = xmm10[1],xmm9[1]
subsd %xmm11, %xmm6
movapd %xmm2, %xmm11
mulsd %xmm10, %xmm11
mulsd %xmm12, %xmm10
mulsd %xmm6, %xmm12
mulsd %xmm2, %xmm6
movapd %xmm2, %xmm13
subsd %xmm8, %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm2, %xmm3
xorpd %xmm0, %xmm2
movsd %xmm5, %xmm4            # xmm4 = xmm5[0],xmm4[1]
movapd %xmm7, %xmm8
movsd %xmm9, %xmm8            # xmm8 = xmm9[0],xmm8[1]
addsd %xmm9, %xmm11
addsd %xmm11, %xmm12
unpckhpd %xmm7, %xmm7            # xmm7 = xmm7[1,1]
subsd %xmm10, %xmm7
addsd %xmm7, %xmm6
movsd %xmm12, (%rdi,%r10,2)
xorpd %xmm0, %xmm12
unpcklpd %xmm6, %xmm12           # xmm12 = xmm12[0],xmm6[0]
mulpd %xmm1, %xmm8
addpd %xmm12, %xmm8
movsd %xmm6, 0x8(%rdi,%r10,2)
movupd %xmm8, (%rdi,%r9,8)
shufpd $0x1, %xmm2, %xmm13     # xmm13 = xmm13[1],xmm2[0]
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
mulpd %xmm13, %xmm5
addpd %xmm4, %xmm5
addpd %xmm5, %xmm3
movapd %xmm3, %xmm2
xorpd %xmm0, %xmm2
shufpd $0x2, %xmm3, %xmm2      # xmm2 = xmm2[0],xmm3[1]
mulpd %xmm1, %xmm4
addpd %xmm2, %xmm4
movsd 0x8(%rdx,%r10), %xmm2
movhpd (%rsi,%r11,8), %xmm2    # xmm2 = xmm2[0],mem[0]
movupd %xmm3, (%rdi,%rcx)
movupd %xmm4, (%rdi,%r8,8)
decq %r11
addq $0x8, %r10
addq $-0x10, %rcx
addq $-0x2, %r9
addq $0x2, %r8
cmpq %r11, %rax
jne 0x28dd7
retq