// File: /workspace/github_c_makefile_star2_O2/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 0x1df75
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %r12
pushq $0x1
popq %r13
movl %ecx, %eax
leaq 0xca1f7(%rip), %rcx     # 0xe7fa0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq %r14d, %rbp
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x8490
testq %rax, %rax
je 0x1df7a
movq %rax, %rbx
movq %rbp, %rdi
callq 0x8490
testq %rax, %rax
je 0x1dfab
pushq $0x1
popq %r9
xorpd %xmm0, %xmm0
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
movq %rbx, %r13
movq %rbx, %rcx
movq %rax, (%rsp)
movq %rax, %r8
callq 0x1e002
xorl %ebx, %ebx
testl %r14d, %r14d
cmovlel %ebx, %r14d
leaq 0x10(%rsp), %rbp
cmpq %rbx, %r14
je 0x1df64
movsd (%r12,%rbx,8), %xmm0
movq 0x858(%rsp), %rdi
movq %rbp, %rsi
callq *0x850(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%r15,%rbx,8), %xmm0
movsd %xmm0, (%r15,%rbx,8)
incq %rbx
jmp 0x1de0f
cvtsi2sd %r14d, %xmm0
movsd 0xc740c(%rip), %xmm1    # 0xe5260
addsd %xmm1, %xmm0
xorl %r13d, %r13d
testl %r14d, %r14d
cmovlel %r13d, %r14d
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
leaq 0x10(%rsp), %rbp
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x1dfed
cvtsi2sd %ebx, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0xc73c6(%rip), %xmm0    # 0xe5260
divsd %xmm1, %xmm0
addsd 0xc7942(%rip), %xmm0    # 0xe57e8
movsd %xmm0, (%r12,%rbx,8)
movq 0x858(%rsp), %rdi
movq %rbp, %rsi
callq *0x850(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rbx,8)
incq %rbx
jmp 0x1de72
cvtsi2sd %r14d, %xmm0
leal -0x1(%r14), %ebx
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
leaq 0x10(%rsp), %rbp
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x1df75
cvtsi2sd %r13d, %xmm0
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%r12,%r13,8)
movq 0x858(%rsp), %rdi
movq %rbp, %rsi
callq *0x850(%rsp)
movsd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0xc7d60(%rip), %xmm1    # 0xe5cb0
cmpq %r13, %rbx
je 0x1df59
movapd %xmm0, %xmm1
movsd %xmm1, (%r15,%r13,8)
incq %r13
jmp 0x1df0a
movq %r13, %rdi
callq 0x8430
movq (%rsp), %rdi
callq 0x8430
xorl %r13d, %r13d
jmp 0x1dfed
leaq 0xc7083(%rip), %rsi     # 0xe5004
leaq 0xec122(%rip), %rdx     # 0x10a0aa
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0xc7094(%rip), %rsi     # 0xe5034
leaq 0xca229(%rip), %rdx     # 0xe81d0
pushq $0x1b
jmp 0x1dfda
leaq 0xc7052(%rip), %rsi     # 0xe5004
leaq 0xe1252(%rip), %rdx     # 0xff20b
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0xc7063(%rip), %rsi     # 0xe5034
leaq 0xca1f8(%rip), %rdx     # 0xe81d0
pushq $0x1c
popq %rcx
movq 0x860(%rsp), %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
movl %r13d, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq