// File: /workspace/github_c_makefile_star2_O1/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 0x200d0
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %r14
movq 0x858(%rsp), %rbp
movq 0x850(%rsp), %rdx
movl $0x1, %r15d
movl %ecx, %eax
leaq 0xd40e1(%rip), %rcx     # 0xf3fd0
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 0x200e8
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0x20125
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 0x2016f
testl %r12d, %r12d
movq 0x850(%rsp), %rax
jle 0x1ff8c
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 0x1ff5c
movq (%rsp), %rdi
callq 0x8410
movq 0x8(%rsp), %rdi
callq 0x8410
jmp 0x200d0
testl %r12d, %r12d
jle 0x200d0
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0xd12a3(%rip), %xmm1    # 0xf1260
addsd %xmm1, %xmm0
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 0xd1268(%rip), %xmm0    # 0xf1260
divsd %xmm1, %xmm0
addsd 0xd17e4(%rip), %xmm0    # 0xf17e8
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 0x1ffd5
jmp 0x200d0
testl %r12d, %r12d
jle 0x200d0
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 0xd1c1f(%rip), %xmm1    # 0xf1cd0
cmpq %r15, %r13
je 0x200ba
movapd %xmm0, %xmm1
movsd %xmm1, (%rbx,%r15,8)
incq %r15
cmpq %r15, %rbp
movq 0x850(%rsp), %rdx
jne 0x20072
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 0xd0f15(%rip), %rsi     # 0xf1004
leaq 0xf60d4(%rip), %rdx     # 0x1161ca
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
leaq 0xd0f25(%rip), %rsi     # 0xf1034
leaq 0xd40ea(%rip), %rdx     # 0xf4200
movq 0x860(%rsp), %rdi
movl $0x1b, %ecx
jmp 0x20160
leaq 0xd0ed8(%rip), %rsi     # 0xf1004
leaq 0xeb1e8(%rip), %rdx     # 0x10b31b
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
leaq 0xd0ee8(%rip), %rsi     # 0xf1034
leaq 0xd40ad(%rip), %rdx     # 0xf4200
movq 0x860(%rsp), %rdi
movl $0x1c, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
jmp 0x200d3