// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/quadrature.c
// Function: compute_Laguerre
int compute_Laguerre(double *x, double *w, int N, double alpha, double *b, double *c,int totalweight){
  int i,j,iter,maxiter=10;
  double x0=0.,r1,r2,ratio,d,logprod,logcc;
  double p0,p1,p2,dp0,dp1,dp2;
  double eps=1e-14;
  /* Initialise recursion coefficients: */
  for(i=0; i<N; i++){
    b[i] = alpha + 2.0*i +1.0;
    c[i] = i*(alpha+i);
  }
  logprod = 0.0;
  for(i=1; i<N; i++) logprod +=log(c[i]);
  logcc = lgamma(alpha+1)+logprod;

  /* Loop over roots: */
  for (i=0; i<N; i++){
    /* Estimate root: */
    if (i==0) {
      x0 =(1.0+alpha)*(3.0+0.92*alpha)/( 1.0+2.4*N+1.8*alpha);
    }
    else if (i==1){
      x0 += (15.0+6.25*alpha)/( 1.0+0.9*alpha+2.5*N);
    }
    else{
      r1 = (1.0+2.55*(i-1))/( 1.9*(i-1));
      r2 = 1.26*(i-1)*alpha/(1.0+3.5*(i-1));
      ratio = (r1+r2)/(1.0+0.3*alpha);
      x0 += ratio*(x0-x[i-2]);
    }
    /* Refine root using Newtons method: */
    for(iter=1; iter<=maxiter; iter++){
      /* We need to find p2=L_N(x0), dp2=L'_N(x0) and
	 p1 = L_(N-1)(x0): */
      p1 = 1.0;
      dp1 = 0.0;
      p2 = x0 - alpha - 1.0;
      dp2 = 1.0;
      for (j=1; j<N; j++ ){
	p0 = p1;
	dp0 = dp1;
	p1 = p2;
	dp1 = dp2;
	p2  = (x0-b[j])*p1 - c[j]*p0;
	dp2 = (x0-b[j])*dp1 + p1 - c[j]*dp0;
      }
      /* New guess at root: */
      d = p2/dp2;
      x0 -= d;
      if (fabs(d)<=eps*(fabs(x0)+1.0)) break;
    }
    /* Okay, write root and weight: */
    x[i] = x0;

    if (totalweight == _TRUE_)
      w[i] = exp(x0+logcc-log(dp2*p1));
    else
       w[i] = exp(logcc-log(dp2*p1));
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, 0x1c(%rsp)
movapd %xmm0, %xmm2
movq %rsi, 0x38(%rsp)
testl %edx, %edx
jle 0x20595
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rdi, %r13
movl %edx, %ebx
xorl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm0
addsd %xmm2, %xmm0
addsd 0xcdfee(%rip), %xmm0    # 0xee260
movsd %xmm0, (%r15,%rax,8)
movsd %xmm1, (%r14,%rax,8)
incq %rax
cmpq %rax, %rbx
jne 0x2024f
movsd %xmm2, 0x10(%rsp)
xorpd %xmm1, %xmm1
cmpl $0x1, %ebx
je 0x202bc
movl $0x1, %r12d
movsd %xmm1, (%rsp)
movsd (%r14,%r12,8), %xmm0
callq 0x82c0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
incq %r12
cmpq %r12, %rbx
jne 0x2029b
movsd %xmm1, (%rsp)
movsd 0xcdf97(%rip), %xmm0    # 0xee260
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x8290
movsd (%rsp), %xmm9
movsd 0x10(%rsp), %xmm7
testl %ebp, %ebp
movsd 0xcdf6f(%rip), %xmm8    # 0xee260
jle 0x205a6
addsd %xmm0, %xmm9
movsd 0xd0c6c(%rip), %xmm3    # 0xf0f70
mulsd %xmm7, %xmm3
addsd 0xd0c68(%rip), %xmm3    # 0xf0f78
movsd 0xcdf60(%rip), %xmm0    # 0xee278
mulsd %xmm7, %xmm0
addsd %xmm8, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xcdfa0(%rip), %xmm2    # 0xee2d0
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
divsd %xmm2, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0xd0c36(%rip), %xmm0    # 0xf0f80
mulsd %xmm7, %xmm0
addsd 0xcf32a(%rip), %xmm0    # 0xef680
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
mulsd 0xd0c20(%rip), %xmm1    # 0xf0f88
addsd %xmm8, %xmm1
movsd 0xd0c1b(%rip), %xmm0    # 0xf0f90
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
divsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0xcdf21(%rip), %xmm0    # 0xee2b0
mulsd %xmm7, %xmm0
addsd %xmm8, %xmm0
movsd %xmm0, 0x28(%rsp)
xorpd %xmm3, %xmm3
xorl %r12d, %r12d
movsd 0xce43a(%rip), %xmm10   # 0xee7e8
movapd 0xcde89(%rip), %xmm11   # 0xee240
movsd 0xce920(%rip), %xmm12   # 0xeece0
movsd %xmm9, (%rsp)
movsd 0x8(%rsp), %xmm0
testl %r12d, %r12d
je 0x2044e
cmpl $0x1, %r12d
jne 0x203e3
addsd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm0
jmp 0x2044e
leal -0x1(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd %xmm0, %xmm1
mulsd 0xd0b9d(%rip), %xmm1    # 0xf0f98
addsd %xmm8, %xmm1
movapd %xmm0, %xmm2
mulsd 0xd0b94(%rip), %xmm2    # 0xf0fa0
divsd %xmm2, %xmm1
movapd %xmm0, %xmm2
mulsd 0xd0b8c(%rip), %xmm2    # 0xf0fa8
mulsd %xmm7, %xmm2
mulsd 0xd0b88(%rip), %xmm0    # 0xf0fb0
addsd %xmm8, %xmm0
divsd %xmm0, %xmm2
addsd %xmm1, %xmm2
divsd 0x28(%rsp), %xmm2
movapd %xmm3, %xmm0
subsd -0x10(%r13,%r12,8), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm3, %xmm0
movl $0x1, %eax
movapd %xmm0, %xmm13
movapd %xmm13, %xmm2
subsd %xmm7, %xmm2
addsd %xmm10, %xmm2
cmpl $0x1, %ebp
jne 0x20477
movapd %xmm8, %xmm0
movapd %xmm8, %xmm1
jmp 0x204d3
xorpd %xmm3, %xmm3
movl $0x1, %ecx
movapd %xmm8, %xmm1
movapd %xmm8, %xmm4
movapd %xmm2, %xmm0
movapd %xmm1, %xmm5
movapd %xmm13, %xmm1
subsd (%r15,%rcx,8), %xmm1
movsd (%r14,%rcx,8), %xmm6
mulsd %xmm6, %xmm4
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
subsd %xmm4, %xmm2
mulsd %xmm5, %xmm1
addsd %xmm0, %xmm1
mulsd %xmm6, %xmm3
subsd %xmm3, %xmm1
incq %rcx
movapd %xmm5, %xmm3
movapd %xmm0, %xmm4
cmpq %rcx, %rbx
jne 0x2048a
divsd %xmm1, %xmm2
subsd %xmm2, %xmm13
andpd %xmm11, %xmm2
movapd %xmm13, %xmm3
andpd %xmm11, %xmm3
addsd %xmm8, %xmm3
mulsd %xmm12, %xmm3
ucomisd %xmm2, %xmm3
jae 0x20509
leal 0x1(%rax), %ecx
cmpl $0xa, %eax
movl %ecx, %eax
jb 0x20458
movsd %xmm13, (%r13,%r12,8)
cmpl $0x1, 0x1c(%rsp)
movapd %xmm13, 0x40(%rsp)
jne 0x20523
addsd %xmm13, %xmm9
movsd %xmm9, 0x20(%rsp)
mulsd %xmm1, %xmm0
callq 0x82c0
movsd 0x20(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x8670
movq 0x38(%rsp), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpq %rbx, %r12
movsd 0x10(%rsp), %xmm7
movsd 0xcdcfa(%rip), %xmm8    # 0xee260
movsd (%rsp), %xmm9
movsd 0xce273(%rip), %xmm10   # 0xee7e8
movapd 0xcdcc2(%rip), %xmm11   # 0xee240
movsd 0xce759(%rip), %xmm12   # 0xeece0
movapd 0x40(%rsp), %xmm3
jne 0x203c6
jmp 0x205a6
addsd 0xcdcc3(%rip), %xmm2    # 0xee260
movapd %xmm2, %xmm0
callq 0x8290
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq