// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
movq %rcx, 0x18(%rsp)
movl %edx, %ecx
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
leal 0x1(%rcx), %eax
pushq $0x2
popq %rsi
cltd
cvtsi2sd %ecx, %xmm7
idivl %esi
movsd 0xc640a(%rip), %xmm1    # 0xe5cb0
addsd %xmm7, %xmm1
xorl %ebp, %ebp
testl %ecx, %ecx
movl $0x0, %r12d
cmovgl %ecx, %r12d
movslq %eax, %r13
movslq %ecx, %rax
movq %rax, (%rsp)
pushq $0x1
popq %rbx
movsd 0xc59bb(%rip), %xmm2    # 0xe5288
movsd 0xc86c3(%rip), %xmm3    # 0xe7f98
pushq $0x1
popq %r14
movsd %xmm0, 0x28(%rsp)
movsd %xmm7, 0x20(%rsp)
movsd %xmm1, 0x8(%rsp)
cmpq %r13, %rbx
jg 0x1faa6
cvtsi2sd %ebx, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
divsd %xmm1, %xmm0
callq 0x86d0
movapd 0xc592e(%rip), %xmm10   # 0xe5240
movsd 0xc5ecd(%rip), %xmm9    # 0xe57e8
movsd 0xc593c(%rip), %xmm8    # 0xe5260
movsd 0x20(%rsp), %xmm7
movsd 0x28(%rsp), %xmm6
xorl %eax, %eax
xorpd %xmm2, %xmm2
movl %r12d, %ecx
movapd %xmm8, %xmm3
movl %r14d, %edx
movapd %xmm8, %xmm1
subl $0x1, %ecx
jb 0x1f984
movapd %xmm3, %xmm4
addsd %xmm3, %xmm4
addsd %xmm9, %xmm4
mulsd %xmm0, %xmm4
leal -0x1(%rdx), %esi
cvtsi2sd %esi, %xmm5
mulsd %xmm5, %xmm2
mulsd %xmm1, %xmm4
subsd %xmm2, %xmm4
divsd %xmm3, %xmm4
addsd %xmm8, %xmm3
incl %edx
movapd %xmm1, %xmm2
movapd %xmm4, %xmm1
jmp 0x1f946
incl %eax
cmpl $0x2710, %eax           # imm = 0x2710
je 0x1fa48
movapd %xmm0, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm2, %xmm3
mulsd %xmm7, %xmm3
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm9, %xmm2
divsd %xmm2, %xmm3
divsd %xmm3, %xmm1
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
andpd %xmm10, %xmm1
ucomisd %xmm6, %xmm1
movapd %xmm2, %xmm0
ja 0x1f932
movapd %xmm2, %xmm0
xorpd 0xc584b(%rip), %xmm0    # 0xe5230
movlpd %xmm0, -0x8(%r15,%rbx,8)
movq (%rsp), %rax
subq %rbx, %rax
movsd %xmm2, (%r15,%rax,8)
mulsd %xmm2, %xmm2
movapd %xmm8, %xmm0
subsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movsd 0xc62ca(%rip), %xmm1    # 0xe5ce0
divsd %xmm0, %xmm1
movq 0x10(%rsp), %rcx
movsd %xmm1, -0x8(%rcx,%rbx,8)
movsd %xmm1, (%rcx,%rax,8)
incq %rbx
movsd 0x8(%rsp), %xmm1
movsd 0xc584d(%rip), %xmm2    # 0xe5288
movsd 0xc8555(%rip), %xmm3    # 0xe7f98
jmp 0x1f8eb
leaq 0xc8902(%rip), %rsi     # 0xe8351
leaq 0x830(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xc561a(%rip), %rsi     # 0xe5082
leaq 0xc8928(%rip), %rdx     # 0xe8397
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xc55ac(%rip), %rsi     # 0xe5034
leaq 0xc891c(%rip), %rdx     # 0xe83ab
movq 0x18(%rsp), %rdi
movl $0x304, %ecx            # imm = 0x304
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq