// File: /workspace/github_c_makefile_star2_O3/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 0x21de5
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 $0x1f, %eax
addl %r14d, %eax
incl %eax
sarl %eax
cvtsi2sd %edx, %xmm6
movsd 0xcd0e8(%rip), %xmm1    # 0xeecd0
addsd %xmm6, %xmm1
movl %edx, %ecx
movq %rcx, (%rsp)
cmpl $0x2, %eax
movl $0x1, %ebp
cmovgel %eax, %ebp
incl %ebp
movl $0x1, %r13d
movsd 0xcc67b(%rip), %xmm2    # 0xee288
movsd 0xcf3c3(%rip), %xmm3    # 0xf0fd8
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 0xcc5f7(%rip), %xmm9    # 0xee240
movsd 0xccb96(%rip), %xmm8    # 0xee7e8
movsd 0xcc606(%rip), %xmm7    # 0xee260
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 0x21c76
incl %eax
cmpl $0x2710, %eax           # imm = 0x2710
je 0x21d75
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 0x21c68
movapd %xmm3, %xmm0
xorpd 0xcc522(%rip), %xmm0    # 0xee230
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 0xccfc2(%rip), %xmm1    # 0xeed00
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%r15,%r13,8)
movsd %xmm1, (%r15,%rax,8)
incq %r13
cmpq %rbp, %r13
movsd 0x8(%rsp), %xmm1
movsd 0xcc525(%rip), %xmm2    # 0xee288
movsd 0xcf26d(%rip), %xmm3    # 0xf0fd8
jne 0x21c27
xorl %eax, %eax
jmp 0x21dd3
leaq 0xcf615(%rip), %rsi     # 0xf1391
leaq 0x820(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xcc2ed(%rip), %rsi     # 0xee082
leaq 0xcf63b(%rip), %rdx     # 0xf13d7
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xcc27f(%rip), %rsi     # 0xee034
leaq 0xcf62f(%rip), %rdx     # 0xf13eb
movq %rbx, %rdi
movl $0x304, %ecx            # imm = 0x304
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
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