// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movl %r9d, 0x1c(%rsp)
movq %r8, %r14
movq %rcx, %r15
movapd %xmm0, %xmm2
movl %edx, %r13d
movq %rsi, 0x60(%rsp)
movq %rdi, 0x20(%rsp)
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %ebp
cmovgl %edx, %ebp
movsd 0xc7220(%rip), %xmm3    # 0xe5260
cmpq %rax, %rbp
je 0x1e072
cvtsi2sd %eax, %xmm0
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm0
addsd %xmm2, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%r15,%rax,8)
movsd %xmm1, (%r14,%rax,8)
incq %rax
jmp 0x1e040
movslq %r13d, %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x1
popq %r12
movsd %xmm2, 0x10(%rsp)
cmpq %rbx, %r12
jge 0x1e0bc
movsd (%r14,%r12,8), %xmm0
callq 0x82e0
movsd 0xc71bf(%rip), %xmm3    # 0xe5260
movsd 0x10(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
incq %r12
jmp 0x1e089
addsd %xmm3, %xmm2
movsd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm0
callq 0x82b0
movsd 0xc7189(%rip), %xmm6    # 0xe5260
movsd 0x10(%rsp), %xmm5
movsd 0xc9e4b(%rip), %xmm3    # 0xe7f30
mulsd %xmm5, %xmm3
addsd 0xc9e47(%rip), %xmm3    # 0xe7f38
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0xc716f(%rip), %xmm0    # 0xe5278
mulsd %xmm5, %xmm0
addsd %xmm6, %xmm0
cvtsi2sd %r13d, %xmm1
movsd 0xc71b2(%rip), %xmm2    # 0xe52d0
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
divsd %xmm2, %xmm3
movsd %xmm3, 0x50(%rsp)
movsd 0xc9e08(%rip), %xmm2    # 0xe7f40
mulsd %xmm5, %xmm2
addsd 0xc8604(%rip), %xmm2    # 0xe6748
mulsd 0xc9dfc(%rip), %xmm1    # 0xe7f48
mulsd 0x30(%rsp), %xmm2
addsd %xmm6, %xmm1
movsd 0xc9df2(%rip), %xmm0    # 0xe7f50
mulsd %xmm5, %xmm0
addsd %xmm1, %xmm0
divsd %xmm0, %xmm2
movsd %xmm2, 0x58(%rsp)
movsd 0xc7138(%rip), %xmm0    # 0xe52b0
mulsd %xmm5, %xmm0
addsd %xmm6, %xmm0
movsd %xmm0, 0x48(%rsp)
xorpd %xmm3, %xmm3
xorl %r12d, %r12d
movsd 0xc7653(%rip), %xmm7    # 0xe57e8
pushq $0x1
popq %r13
movapd 0xc709e(%rip), %xmm9    # 0xe5240
movsd 0xc7b15(%rip), %xmm10   # 0xe5cc0
cmpq %rbp, %r12
je 0x1e39b
movsd 0x58(%rsp), %xmm0
testl %r12d, %r12d
movsd 0x70(%rsp), %xmm11
movsd 0x68(%rsp), %xmm12
je 0x1e24a
cmpl $0x1, %r12d
jne 0x1e1df
addsd 0x50(%rsp), %xmm3
movapd %xmm3, %xmm0
jmp 0x1e24a
leal -0x1(%r12), %eax
cvtsi2sd %eax, %xmm0
movapd %xmm0, %xmm1
mulsd 0xc9d64(%rip), %xmm1    # 0xe7f58
addsd %xmm6, %xmm1
movapd %xmm0, %xmm2
mulsd 0xc9d5c(%rip), %xmm2    # 0xe7f60
divsd %xmm2, %xmm1
movapd %xmm0, %xmm2
mulsd 0xc9d54(%rip), %xmm2    # 0xe7f68
mulsd %xmm5, %xmm2
mulsd 0xc9d50(%rip), %xmm0    # 0xe7f70
addsd %xmm6, %xmm0
divsd %xmm0, %xmm2
addsd %xmm1, %xmm2
divsd 0x48(%rsp), %xmm2
movapd %xmm3, %xmm0
movq 0x20(%rsp), %rax
subsd -0x10(%rax,%r12,8), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm3, %xmm0
movapd %xmm0, %xmm8
pushq $0x1
popq %rax
cmpl $0xb, %eax
je 0x1e2f8
movapd %xmm8, %xmm0
subsd %xmm5, %xmm0
addsd %xmm7, %xmm0
xorpd %xmm1, %xmm1
movq %r13, %rcx
movapd %xmm6, %xmm12
movapd %xmm6, %xmm11
cmpq %rbx, %rcx
jge 0x1e2ca
movapd %xmm8, %xmm2
subsd (%r15,%rcx,8), %xmm2
movsd (%r14,%rcx,8), %xmm3
mulsd %xmm3, %xmm12
movapd %xmm2, %xmm4
mulsd %xmm0, %xmm4
subsd %xmm12, %xmm4
mulsd %xmm11, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm3, %xmm1
subsd %xmm1, %xmm2
incq %rcx
movapd %xmm0, %xmm12
movapd %xmm4, %xmm0
movapd %xmm11, %xmm1
movapd %xmm2, %xmm11
jmp 0x1e279
divsd %xmm11, %xmm0
subsd %xmm0, %xmm8
andpd %xmm9, %xmm0
movapd %xmm8, %xmm1
andpd %xmm9, %xmm1
addsd %xmm6, %xmm1
mulsd %xmm10, %xmm1
incl %eax
ucomisd %xmm0, %xmm1
jb 0x1e252
movq 0x20(%rsp), %rax
movsd %xmm8, (%rax,%r12,8)
cmpl $0x1, 0x1c(%rsp)
movapd %xmm8, 0x30(%rsp)
je 0x1e319
movsd 0x8(%rsp), %xmm0
jmp 0x1e324
movsd 0x8(%rsp), %xmm0
addsd %xmm8, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd %xmm12, 0x68(%rsp)
movapd %xmm12, %xmm0
movsd %xmm11, 0x70(%rsp)
mulsd %xmm11, %xmm0
callq 0x82e0
movsd 0x28(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x86a0
movq 0x60(%rsp), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movsd 0x10(%rsp), %xmm5
movsd 0xc6eea(%rip), %xmm6    # 0xe5260
movsd 0xc746a(%rip), %xmm7    # 0xe57e8
movapd 0x30(%rsp), %xmm3
movapd 0xc6eb3(%rip), %xmm9    # 0xe5240
movsd 0xc792a(%rip), %xmm10   # 0xe5cc0
jmp 0x1e1ab
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq