// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/quadrature.c
// Function: gk_quad
int gk_quad(int (*test)(void * params_for_function, double q, double *psi),
	    int (*function)(void * params_for_function, double q, double *f0),
	    void * params_for_function,
	    qss_node* node,
	    double a,
	    double b,
	    int isindefinite){
  const double z_k[15]={-0.991455371120813,
			-0.949107912342759,
			-0.864864423359769,
			-0.741531185599394,
			-0.586087235467691,
			-0.405845151377397,
			-0.207784955007898,
			0.0,
			0.207784955007898,
			0.405845151377397,
			0.586087235467691,
			0.741531185599394,
			0.864864423359769,
			0.949107912342759,
			0.991455371120813};
  const double w_k[15]={0.022935322010529,
			0.063092092629979,
			0.104790010322250,
			0.140653259715525,
			0.169004726639267,
			0.190350578064785,
			0.204432940075298,
			0.209482141084728,
			0.204432940075298,
			0.190350578064785,
			0.169004726639267,
			0.140653259715525,
			0.104790010322250,
			0.063092092629979,
			0.022935322010529};
  const double w_g[7]={0.129484966168870,
		       0.279705391489277,
		       0.381830050505119,
		       0.417959183673469,
		       0.381830050505119,
		       0.279705391489277,
		       0.129484966168870};
  int i,j;
  double x,wg,wk,t,Ik,Ig,y,y2;

  /* 	Loop through abscissas, transform the interval and form the Kronrod
     15 point estimate of the integral.
     Every second time we update the Gauss 7 point quadrature estimate. */

  Ik=0.0;
  Ig=0.0;
  for (i=0;i<15;i++){
    /* Transform z into t in interval between a and b: */
    t = 0.5*(a*(1-z_k[i])+b*(1+z_k[i]));
    /* Modify weight such that it reflects the linear transformation above: */
    wk = 0.5*(b-a)*w_k[i];
    if (isindefinite==_TRUE_){
      /* Transform t into x in interval between 0 and inf: */
      x = 1.0/t-1.0;
      /* Modify weight accordingly: */
      wk = wk/(t*t);
    }
    else{
      x = t;
    }
    (*test)(params_for_function,x,&y);
    (*function)(params_for_function,x,&y2);
    wk *= y2;
    /* Update Kronrod integral: */
    Ik +=wk*y;
    /* If node->x and node->w is allocated, store values: */
    if (node->x!=NULL) node->x[i] = x;
    if (node->w!=NULL) node->w[i] = wk;
    /* If i is uneven, update Gauss integral: */
    if ((i%2)==1){
      j = (i-1)/2;
      /* Transform weight according to linear transformation: */
      wg = 0.5*(b-a)*w_g[j];
      if (isindefinite == _TRUE_){
        /* Transform weight according to non-linear transformation x = 1/t -1: */
        wg = wg/(t*t);
      }
      /* Update integral: */
      Ig +=wg*y*y2;
    }
  }
  node->err = pow(200*fabs(Ik-Ig),1.5);
  node->I = Ik;
  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x38(%rsp)
movq %rdi, %r12
movsd %xmm1, 0x48(%rsp)
movsd %xmm0, 0x40(%rsp)
subsd %xmm0, %xmm1
mulsd 0xc66f3(%rip), %xmm1    # 0xe5cb0
movsd %xmm1, 0x8(%rsp)
xorpd %xmm0, %xmm0
xorl %r13d, %r13d
xorl %r15d, %r15d
xorpd %xmm1, %xmm1
movsd %xmm1, (%rsp)
cmpq $0xf, %r15
movsd %xmm0, 0x18(%rsp)
je 0x1f721
leaq 0xc89c3(%rip), %rax     # 0xe7fb0
movsd (%r13,%rax), %xmm1
movsd 0xc5c64(%rip), %xmm2    # 0xe5260
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
addsd %xmm2, %xmm1
mulsd 0x48(%rsp), %xmm1
mulsd 0x40(%rsp), %xmm0
addsd %xmm1, %xmm0
mulsd 0xc6690(%rip), %xmm0    # 0xe5cb0
leaq 0xc8a09(%rip), %rax     # 0xe8030
movsd (%r13,%rax), %xmm3
mulsd 0x8(%rsp), %xmm3
divsd %xmm0, %xmm2
addsd 0xc61a8(%rip), %xmm2    # 0xe57e8
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
cmpl $0x1, %ebp
movsd %xmm1, 0x50(%rsp)
je 0x1f659
movapd %xmm0, %xmm2
jmp 0x1f65d
divsd %xmm1, %xmm3
movsd %xmm3, 0x10(%rsp)
movsd %xmm2, 0x20(%rsp)
movq %r14, %rdi
movapd %xmm2, %xmm0
leaq 0x30(%rsp), %rsi
callq *%r12
movq %r14, %rdi
movsd 0x20(%rsp), %xmm0
leaq 0x28(%rsp), %rsi
callq *0x38(%rsp)
movsd 0x10(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x1f6b5
movsd 0x20(%rsp), %xmm2
movsd %xmm2, (%rax,%r15,8)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x1f6c4
movsd %xmm1, (%rax,%r15,8)
testb $0x1, %r15b
je 0x1f707
leal -0x1(%r15), %eax
shrl %eax
leaq 0xc89d9(%rip), %rcx     # 0xe80b0
movsd (%rcx,%rax,8), %xmm1
mulsd 0x8(%rsp), %xmm1
cmpl $0x1, %ebp
jne 0x1f6ed
divsd 0x50(%rsp), %xmm1
mulsd 0x30(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
movsd (%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rsp)
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incq %r15
addq $0x8, %r13
jmp 0x1f5d6
subsd (%rsp), %xmm0
andpd 0xc5b12(%rip), %xmm0    # 0xe5240
mulsd 0xc885a(%rip), %xmm0    # 0xe7f90
movsd 0xc884a(%rip), %xmm1    # 0xe7f88
callq 0x8650
movsd %xmm0, 0x8(%rbx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rbx)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq