// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x1098, %rsp           # imm = 0x1098
movq 0x10b0(%rsp), %rax
movq 0x10a8(%rsp), %rax
movq 0x10a0(%rsp), %rax
movq %rdi, 0x1088(%rsp)
movq %rsi, 0x1080(%rsp)
movl %edx, 0x107c(%rsp)
movsd %xmm0, 0x1070(%rsp)
movl %ecx, 0x106c(%rsp)
movq %r8, 0x1060(%rsp)
movl %r9d, 0x105c(%rsp)
movl 0x106c(%rsp), %eax
movq %rax, 0x8(%rsp)
subq $0x3, %rax
ja 0x3b341
movq 0x8(%rsp), %rax
leaq 0x19a1b8(%rip), %rcx    # 0x1d5080
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x1094(%rsp)
jmp 0x3b34c
movslq 0x107c(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x1038(%rsp)
cmpq $0x0, 0x1038(%rsp)
jne 0x3af76
movslq 0x107c(%rsp), %rax
shlq $0x3, %rax
movl %eax, 0x1028(%rsp)
leaq 0x820(%rsp), %rdi
movl 0x1028(%rsp), %ecx
leaq 0x1970d6(%rip), %rsi    # 0x1d2004
leaq 0x1bc0e0(%rip), %rdx    # 0x1f7015
movb $0x0, %al
callq 0x5b9c0
movq 0x10b0(%rsp), %rdi
leaq 0x820(%rsp), %r8
leaq 0x1970e1(%rip), %rsi    # 0x1d2034
leaq 0x19a26e(%rip), %rdx    # 0x1d51c8
movl $0x1b, %ecx
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1094(%rsp)
jmp 0x3b34c
movslq 0x107c(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x1030(%rsp)
cmpq $0x0, 0x1030(%rsp)
jne 0x3b005
movslq 0x107c(%rsp), %rax
shlq $0x3, %rax
movl %eax, 0x81c(%rsp)
leaq 0x10(%rsp), %rdi
movl 0x81c(%rsp), %ecx
leaq 0x197044(%rip), %rsi    # 0x1d2004
leaq 0x1b1498(%rip), %rdx    # 0x1ec45f
movb $0x0, %al
callq 0x5b9c0
movq 0x10b0(%rsp), %rdi
leaq 0x10(%rsp), %r8
leaq 0x197052(%rip), %rsi    # 0x1d2034
leaq 0x19a1df(%rip), %rdx    # 0x1d51c8
movl $0x1c, %ecx
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1094(%rsp)
jmp 0x3b34c
movq 0x1088(%rsp), %rdi
movq 0x1080(%rsp), %rsi
movl 0x107c(%rsp), %edx
movq 0x1038(%rsp), %rcx
movq 0x1030(%rsp), %r8
xorps %xmm0, %xmm0
movl $0x1, %r9d
callq 0x3b360
movl $0x0, 0x102c(%rsp)
movl 0x102c(%rsp), %eax
cmpl 0x107c(%rsp), %eax
jge 0x3b0ba
movq 0x10a0(%rsp), %rax
movq 0x10a8(%rsp), %rdi
movq 0x1088(%rsp), %rcx
movslq 0x102c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
leaq 0x1050(%rsp), %rsi
callq *%rax
movsd 0x1050(%rsp), %xmm0
movq 0x1080(%rsp), %rax
movslq 0x102c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x102c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x102c(%rsp)
jmp 0x3b045
movq 0x1038(%rsp), %rdi
callq 0x8420
movq 0x1030(%rsp), %rdi
callq 0x8420
movl $0x0, 0x1094(%rsp)
jmp 0x3b34c
movl $0x0, 0x102c(%rsp)
movl 0x102c(%rsp), %eax
cmpl 0x107c(%rsp), %eax
jge 0x3b1ff
movsd 0x1070(%rsp), %xmm0
cvtsi2sdl 0x107c(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1048(%rsp)
movsd 0x1048(%rsp), %xmm1
cvtsi2sdl 0x102c(%rsp), %xmm0
movsd 0x1048(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x1088(%rsp), %rax
movslq 0x102c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x10a0(%rsp), %rax
movq 0x10a8(%rsp), %rdi
movq 0x1088(%rsp), %rcx
movslq 0x102c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
leaq 0x1050(%rsp), %rsi
callq *%rax
movsd 0x1050(%rsp), %xmm0
mulsd 0x1048(%rsp), %xmm0
movq 0x1080(%rsp), %rax
movslq 0x102c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x102c(%rsp), %eax
movl 0x107c(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3b1e7
movq 0x1080(%rsp), %rax
movslq 0x102c(%rsp), %rcx
movsd 0x197aab(%rip), %xmm0   # 0x1d2c88
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x3b1e9
movl 0x102c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x102c(%rsp)
jmp 0x3b0ef
movl $0x0, 0x1094(%rsp)
jmp 0x3b34c
movl $0x0, 0x102c(%rsp)
movl 0x102c(%rsp), %eax
cmpl 0x107c(%rsp), %eax
jge 0x3b334
cvtsi2sdl 0x107c(%rsp), %xmm1
movsd 0x197009(%rip), %xmm0   # 0x1d2248
addsd %xmm0, %xmm1
movsd 0x196ffd(%rip), %xmm0   # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0x1048(%rsp)
movsd 0x1048(%rsp), %xmm1
cvtsi2sdl 0x102c(%rsp), %xmm0
movsd 0x1048(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1040(%rsp)
movsd 0x196fbc(%rip), %xmm0   # 0x1d2248
divsd 0x1040(%rsp), %xmm0
movsd 0x196fab(%rip), %xmm1   # 0x1d2248
subsd %xmm1, %xmm0
movq 0x1088(%rsp), %rax
movslq 0x102c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x10a0(%rsp), %rax
movq 0x10a8(%rsp), %rdi
movq 0x1088(%rsp), %rcx
movslq 0x102c(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
leaq 0x1050(%rsp), %rsi
callq *%rax
movsd 0x1050(%rsp), %xmm0
mulsd 0x1048(%rsp), %xmm0
divsd 0x1040(%rsp), %xmm0
divsd 0x1040(%rsp), %xmm0
movq 0x1080(%rsp), %rax
movslq 0x102c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x102c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x102c(%rsp)
jmp 0x3b21a
movl $0x0, 0x1094(%rsp)
jmp 0x3b34c
movl $0x0, 0x1094(%rsp)
movl 0x1094(%rsp), %eax
addq $0x1098, %rsp           # imm = 0x1098
retq
nopl (%rax,%rax)