// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/quadrature.c
// Function: get_qsampling_manual
int get_qsampling_manual(double *x,
			 double *w,
			 int N,
			 double qmax,
			 enum ncdm_quadrature_method method,
			 double *qvec,
			 int qsiz,
			 int (*function)(void * params_for_function, double q, double *f0),
			 void * params_for_function,
			 ErrorMsg errmsg) {

  double y, h, t;
  double *b, *c;
  int i;
  switch (method){
  case (qm_auto) :
    return _FAILURE_;
  case (qm_Laguerre) :
    /* Allocate storage for Laguerre coefficients: */
    class_alloc(b,N*sizeof(double),errmsg);
    class_alloc(c,N*sizeof(double),errmsg);
    compute_Laguerre(x,w,N,0.0,b,c,_TRUE_);
    for (i=0; i<N; i++){
      (*function)(params_for_function,x[i],&y);
      w[i] *= y;
    }
    free(b);
    free(c);
    return _SUCCESS_;
  case (qm_trapz) :
    for (i=0; i<N; i++){
      /** Note that we count q=0 as an extra point with weight 0 */
      h = qmax/N;
      x[i] = h + i*h;
      (*function)(params_for_function,x[i],&y);
      w[i] = y*h;
      if (i==N-1)
	w[i] *=0.5;
    }
    return _SUCCESS_;
  case (qm_trapz_indefinite) :
    /** We do the variable transformation q = 1/t-1. The trapezoidal rule is closed, but since the distribution function
	goes to zero in both limits, we can use an effectively N+2 rule simply by not using the exterior points. */
    for (i=0; i<N; i++){
      h = 1.0/(N+1.0);
      t = h + i*h;
      x[i] = 1.0/t-1.0;
      (*function)(params_for_function,x[i],&y);
      w[i] = y*h/t/t;
    }
    return _SUCCESS_;
  }
  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movsd %xmm0, (%rsp)
cmpl $0x3, %ecx
ja 0x2017d
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %r14
movq 0x858(%rsp), %rbp
movq 0x850(%rsp), %rdx
movl $0x1, %r15d
movl %ecx, %eax
leaq 0xd1045(%rip), %rcx     # 0xf0fe0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq %r12d, %r13
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8460
movq %rax, (%rsp)
testq %rax, %rax
je 0x20195
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0x201d2
xorpd %xmm0, %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movq (%rsp), %rcx
movq %rax, 0x8(%rsp)
movq %rax, %r8
movl $0x1, %r9d
callq 0x2021c
testl %r12d, %r12d
movq 0x850(%rsp), %rax
jle 0x20038
movl %r12d, %r15d
xorl %r13d, %r13d
movsd (%r14,%r13,8), %xmm0
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
movq %rax, %r12
callq *%rax
movq %r12, %rax
movsd 0x10(%rsp), %xmm0
mulsd (%rbx,%r13,8), %xmm0
movsd %xmm0, (%rbx,%r13,8)
incq %r13
cmpq %r13, %r15
jne 0x20008
movq (%rsp), %rdi
callq 0x8410
movq 0x8(%rsp), %rdi
callq 0x8410
jmp 0x2017d
testl %r12d, %r12d
jle 0x2017d
leal 0x1(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0xce1f2(%rip), %xmm1    # 0xee260
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movl %r12d, %r12d
leaq 0x10(%rsp), %r13
xorl %r15d, %r15d
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0xce1bb(%rip), %xmm0    # 0xee260
divsd %xmm1, %xmm0
addsd 0xce737(%rip), %xmm0    # 0xee7e8
movsd %xmm0, (%r14,%r15,8)
movq %rbp, %rdi
movq %r13, %rsi
callq *0x850(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x20082
jmp 0x2017d
testl %r12d, %r12d
jle 0x2017d
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
leal -0x1(%r12), %r13d
movl %r12d, %ebp
xorl %r15d, %r15d
leaq 0x10(%rsp), %r12
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%r14,%r15,8)
movq 0x858(%rsp), %rdi
movq %r12, %rsi
callq *%rdx
movsd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0xceb72(%rip), %xmm1    # 0xeecd0
cmpq %r15, %r13
je 0x20167
movapd %xmm0, %xmm1
movsd %xmm1, (%rbx,%r15,8)
incq %r15
cmpq %r15, %rbp
movq 0x850(%rsp), %rdx
jne 0x2011f
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcde68(%rip), %rsi     # 0xee004
leaq 0xf3067(%rip), %rdx     # 0x11320a
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
leaq 0xcde78(%rip), %rsi     # 0xee034
leaq 0xd104d(%rip), %rdx     # 0xf1210
movq 0x860(%rsp), %rdi
movl $0x1b, %ecx
jmp 0x2020d
leaq 0xcde2b(%rip), %rsi     # 0xee004
leaq 0xe8163(%rip), %rdx     # 0x108343
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
leaq 0xcde3b(%rip), %rsi     # 0xee034
leaq 0xd1010(%rip), %rdx     # 0xf1210
movq 0x860(%rsp), %rdi
movl $0x1c, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x30af0
jmp 0x20180