// File: /workspace/github_c_makefile_star2_O1/esheldon[P]xshear/src/cosmo.c
// Function: gauleg
void gauleg(double x1, double x2, int npts, double* x, double* w) {
	int i, j, m;
	double xm, xl, z1, z, p1, p2, p3, pp=0, EPS, abszdiff;

	EPS = 4.e-11;

	m = (npts + 1)/2;

	xm = (x1 + x2)/2.0;
	xl = (x2 - x1)/2.0;
	z1 = 0.0;

	for (i=1; i<= m; ++i) 
	{

		z=cos( M_PI*(i-0.25)/(npts+.5) );

		abszdiff = fabs(z-z1);

		while (abszdiff > EPS) 
		{
			p1 = 1.0;
			p2 = 0.0;
			for (j=1; j <= npts;++j)
			{
				p3 = p2;
				p2 = p1;
				p1 = ( (2.0*j - 1.0)*z*p2 - (j-1.0)*p3 )/j;
			}
			pp = npts*(z*p1 - p2)/(z*z -1.);
			z1=z;
			z=z1 - p1/pp;

			abszdiff = fabs(z-z1);

		}

		x[i-1] = xm - xl*z;
		x[npts+1-i-1] = xm + xl*z;
		w[i-1] = 2.0*xl/( (1.-z*z)*pp*pp );
		w[npts+1-i-1] = w[i-1];


	}

}

// Assembly:
testl %edi, %edi
jle 0x4ba6
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
movapd %xmm0, %xmm3
movapd %xmm1, %xmm2
addsd %xmm1, %xmm3
movsd 0x46da(%rip), %xmm1     # 0x9070
mulsd %xmm1, %xmm3
movsd %xmm3, 0x18(%rsp)
subsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
leal 0x1(%r15), %eax
shrl %eax
cvtsi2sd %edi, %xmm5
movsd 0x46b6(%rip), %xmm0     # 0x9070
addsd %xmm5, %xmm0
movsd %xmm0, 0x10(%rsp)
movapd 0x46e4(%rip), %xmm0     # 0x90b0
xorpd %xmm2, %xmm0
movapd %xmm0, 0x40(%rsp)
movapd %xmm2, 0x50(%rsp)
addsd %xmm2, %xmm2
movapd %xmm2, 0x30(%rsp)
movl %edi, %r12d
cmpl $0x2, %eax
movl $0x1, %r13d
cmovgel %eax, %r13d
incl %r13d
xorpd %xmm3, %xmm3
movl $0x1, %ebp
xorpd %xmm10, %xmm10
movsd %xmm5, 0x8(%rsp)
movsd %xmm3, 0x20(%rsp)
movsd %xmm10, 0x28(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
addsd 0x473f(%rip), %xmm0     # 0x9168
mulsd 0x4617(%rip), %xmm0     # 0x9048
divsd 0x10(%rsp), %xmm0
callq 0x2140
movsd 0x28(%rsp), %xmm10
movsd 0x4725(%rip), %xmm7     # 0x9170
movapd 0x466d(%rip), %xmm6     # 0x90c0
movapd %xmm0, %xmm1
subsd %xmm10, %xmm1
andpd %xmm6, %xmm1
ucomisd %xmm7, %xmm1
jbe 0x4b1e
movsd 0x8(%rsp), %xmm5
movsd 0x45a7(%rip), %xmm8     # 0x9020
movsd 0x45b6(%rip), %xmm9     # 0x9038
movapd %xmm0, %xmm10
xorpd %xmm3, %xmm3
xorl %eax, %eax
movapd %xmm8, %xmm2
movapd %xmm8, %xmm1
movapd %xmm1, %xmm0
movapd %xmm2, %xmm1
addsd %xmm2, %xmm1
addsd %xmm9, %xmm1
mulsd %xmm10, %xmm1
xorps %xmm4, %xmm4
cvtsi2sd %eax, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm0, %xmm1
subsd %xmm4, %xmm1
divsd %xmm2, %xmm1
addsd %xmm8, %xmm2
incl %eax
movapd %xmm0, %xmm3
cmpl %eax, %r15d
jne 0x4a97
movapd %xmm10, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm0, %xmm3
mulsd %xmm5, %xmm3
movapd %xmm10, %xmm0
mulsd %xmm10, %xmm0
addsd %xmm9, %xmm0
divsd %xmm0, %xmm3
divsd %xmm3, %xmm1
movapd %xmm10, %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, %xmm1
subsd %xmm10, %xmm1
andpd %xmm6, %xmm1
ucomisd %xmm7, %xmm1
ja 0x4a82
jmp 0x4b2d
movsd 0x44f9(%rip), %xmm8     # 0x9020
movsd 0x20(%rsp), %xmm3
movapd 0x40(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm2
addsd %xmm2, %xmm1
movsd %xmm1, -0x8(%r14,%rbp,8)
movapd 0x50(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movq %r12, %rax
subq %rbp, %rax
movsd %xmm1, (%r14,%rax,8)
mulsd %xmm0, %xmm0
movapd %xmm8, %xmm1
subsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movapd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbx,%rbp,8)
movsd %xmm0, (%rbx,%rax,8)
incq %rbp
cmpq %r13, %rbp
jne 0x4a0d
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq