// File: /workspace/github_c_makefile_star2_O1/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)
movq %r8, %r14
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, 0x38(%rsp)
movq %rdi, %r13
movl %edx, %ebx
testl %edx, %edx
jle 0x201d5
xorl %eax, %eax
movsd 0xd10be(%rip), %xmm3    # 0xf1260
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movapd %xmm1, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm1, %xmm1
addsd %xmm0, %xmm1
addsd %xmm3, %xmm1
movsd %xmm1, (%r15,%rax,8)
movsd %xmm2, (%r14,%rax,8)
incq %rax
cmpq %rax, %rbx
jne 0x201a2
movsd %xmm0, 0x10(%rsp)
xorpd %xmm1, %xmm1
cmpl $0x2, %ebp
jl 0x2020b
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 0x201ea
movsd %xmm1, (%rsp)
movsd 0xd1048(%rip), %xmm0    # 0xf1260
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x8290
movsd (%rsp), %xmm8
movsd 0x10(%rsp), %xmm7
testl %ebp, %ebp
jle 0x204e2
addsd %xmm0, %xmm8
movsd 0xd3d16(%rip), %xmm3    # 0xf3f60
mulsd %xmm7, %xmm3
addsd 0xd3d12(%rip), %xmm3    # 0xf3f68
movsd 0xd101a(%rip), %xmm0    # 0xf1278
mulsd %xmm7, %xmm0
movsd 0xd0ff5(%rip), %xmm9    # 0xf1260
addsd %xmm9, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xd1051(%rip), %xmm2    # 0xf12d0
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
divsd %xmm2, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0xd3cd7(%rip), %xmm0    # 0xf3f70
mulsd %xmm7, %xmm0
addsd 0xd23db(%rip), %xmm0    # 0xf2680
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
mulsd 0xd3cc1(%rip), %xmm1    # 0xf3f78
addsd %xmm9, %xmm1
movsd 0xd3cbc(%rip), %xmm0    # 0xf3f80
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
divsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0xd0fd2(%rip), %xmm0    # 0xf12b0
mulsd %xmm7, %xmm0
addsd %xmm9, %xmm0
movsd %xmm0, 0x28(%rsp)
xorpd %xmm3, %xmm3
xorl %r12d, %r12d
movsd 0xd14eb(%rip), %xmm10   # 0xf17e8
movapd 0xd0f3a(%rip), %xmm11   # 0xf1240
movsd 0xd19d1(%rip), %xmm12   # 0xf1ce0
movsd %xmm8, (%rsp)
movsd 0x8(%rsp), %xmm0
testl %r12d, %r12d
je 0x2039d
cmpl $0x1, %r12d
jne 0x20332
addsd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm0
jmp 0x2039d
leal -0x1(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd %xmm0, %xmm1
mulsd 0xd3c3e(%rip), %xmm1    # 0xf3f88
addsd %xmm9, %xmm1
movapd %xmm0, %xmm2
mulsd 0xd3c35(%rip), %xmm2    # 0xf3f90
divsd %xmm2, %xmm1
movapd %xmm0, %xmm2
mulsd 0xd3c2d(%rip), %xmm2    # 0xf3f98
mulsd %xmm7, %xmm2
mulsd 0xd3c29(%rip), %xmm0    # 0xf3fa0
addsd %xmm9, %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 0x203c6
movapd %xmm9, %xmm0
movapd %xmm9, %xmm1
jmp 0x20422
xorpd %xmm3, %xmm3
movl $0x1, %ecx
movapd %xmm9, %xmm1
movapd %xmm9, %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 0x203d9
divsd %xmm1, %xmm2
subsd %xmm2, %xmm13
andpd %xmm11, %xmm2
movapd %xmm13, %xmm3
andpd %xmm11, %xmm3
addsd %xmm9, %xmm3
mulsd %xmm12, %xmm3
ucomisd %xmm2, %xmm3
jae 0x20458
leal 0x1(%rax), %ecx
cmpl $0xa, %eax
movl %ecx, %eax
jb 0x203a7
movsd %xmm13, (%r13,%r12,8)
cmpl $0x1, 0x1c(%rsp)
movapd %xmm13, 0x40(%rsp)
jne 0x20472
addsd %xmm13, %xmm8
movsd %xmm8, 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 (%rsp), %xmm8
movsd 0xd0da5(%rip), %xmm9    # 0xf1260
movsd 0xd1324(%rip), %xmm10   # 0xf17e8
movapd 0xd0d73(%rip), %xmm11   # 0xf1240
movsd 0xd180a(%rip), %xmm12   # 0xf1ce0
movapd 0x40(%rsp), %xmm3
jne 0x20315
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq