// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/quadrature.c
// Function: quadrature_gauss_legendre
int quadrature_gauss_legendre(
			      double *mu,
			      double *w8,
			      int n,
			      double tol,
			      ErrorMsg error_message) {

  int m,j,i,counter;
  double z1,z,pp,p3,p2,p1;

  m=(n+1)/2;
  for (i=1;i<=m;i++) {
    z=cos(_PI_*((double)i-0.25)/((double)n+0.5));
    counter=0;
    do {
      p1=1.0;
      p2=0.0;
      for (j=1;j<=n;j++) {
        p3=p2;
        p2=p1;
        p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j;
      }
      pp=n*(z*p1-p2)/(z*z-1.0);
      z1=z;
      z=z1-p1/pp;
      counter++;
      class_test(counter == _MAX_IT_,
		 error_message,
		 "maximum number of iteration reached: increase either _MAX_IT_ or tol\n");
    } while (fabs(z-z1) > tol);
    mu[i-1]=-z;
    mu[n-i]=z;
    w8[i-1]=2.0/((1.0-z*z)*pp*pp);
    w8[n-i]=w8[i-1];

  }
  return _SUCCESS_;
}

// Assembly:
testl %edx, %edx
jle 0x21e12
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
leal 0x1(%r14), %eax
shrl %eax
cvtsi2sd %edx, %xmm6
movsd 0xd00bb(%rip), %xmm1    # 0xf1cd0
addsd %xmm6, %xmm1
movl %edx, %ecx
movq %rcx, (%rsp)
cmpl $0x2, %eax
movl $0x1, %ebp
cmovgel %eax, %ebp
incl %ebp
movl $0x1, %r13d
movsd 0xcf64e(%rip), %xmm2    # 0xf1288
movsd 0xd2386(%rip), %xmm3    # 0xf3fc8
movsd %xmm0, 0x18(%rsp)
movsd %xmm6, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
divsd %xmm1, %xmm0
callq 0x86a0
movapd 0xcf5ca(%rip), %xmm9    # 0xf1240
movsd 0xcfb69(%rip), %xmm8    # 0xf17e8
movsd 0xcf5d9(%rip), %xmm7    # 0xf1260
movsd 0x10(%rsp), %xmm6
movsd 0x18(%rsp), %xmm5
xorl %eax, %eax
xorpd %xmm3, %xmm3
xorl %ecx, %ecx
movapd %xmm7, %xmm1
movapd %xmm7, %xmm2
xorps %xmm4, %xmm4
cvtsi2sd %ecx, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm1, %xmm3
movapd %xmm2, %xmm1
addsd %xmm2, %xmm1
addsd %xmm8, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm4, %xmm1
divsd %xmm2, %xmm1
addsd %xmm7, %xmm2
incl %ecx
cmpl %ecx, %r14d
jne 0x21ca3
incl %eax
cmpl $0x2710, %eax           # imm = 0x2710
je 0x21da2
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm3, %xmm2
mulsd %xmm6, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm8, %xmm3
divsd %xmm3, %xmm2
divsd %xmm2, %xmm1
movapd %xmm0, %xmm3
subsd %xmm1, %xmm3
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
andpd %xmm9, %xmm1
ucomisd %xmm5, %xmm1
movapd %xmm3, %xmm0
ja 0x21c95
movapd %xmm3, %xmm0
xorpd 0xcf4f5(%rip), %xmm0    # 0xf1230
movlpd %xmm0, -0x8(%r12,%r13,8)
movq (%rsp), %rax
subq %r13, %rax
movsd %xmm3, (%r12,%rax,8)
mulsd %xmm3, %xmm3
movapd %xmm7, %xmm0
subsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
movsd 0xcff95(%rip), %xmm1    # 0xf1d00
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%r15,%r13,8)
movsd %xmm1, (%r15,%rax,8)
incq %r13
cmpq %rbp, %r13
movsd 0x8(%rsp), %xmm1
movsd 0xcf4f8(%rip), %xmm2    # 0xf1288
movsd 0xd2230(%rip), %xmm3    # 0xf3fc8
jne 0x21c54
xorl %eax, %eax
jmp 0x21e00
leaq 0xd25d8(%rip), %rsi     # 0xf4381
leaq 0x820(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xcf2c0(%rip), %rsi     # 0xf1082
leaq 0xd25fe(%rip), %rdx     # 0xf43c7
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xcf252(%rip), %rsi     # 0xf1034
leaq 0xd25f2(%rip), %rdx     # 0xf43db
movq %rbx, %rdi
movl $0x304, %ecx            # imm = 0x304
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq