// File: /workspace/github_c_makefile_star2_O1/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 0xd03ae(%rip), %xmm1    # 0xf1cd0
movsd %xmm1, 0x10(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
movsd %xmm0, 0x8(%rsp)
leaq 0xd269c(%rip), %rax     # 0xf3fe0
movsd (%r13,%rax), %xmm1
movsd 0xcf90d(%rip), %xmm2    # 0xf1260
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
addsd %xmm2, %xmm1
mulsd 0x48(%rsp), %xmm1
mulsd 0x40(%rsp), %xmm0
addsd %xmm1, %xmm0
mulsd 0xd0359(%rip), %xmm0    # 0xf1cd0
leaq 0xd26e2(%rip), %rax     # 0xf4060
movsd (%r13,%rax), %xmm3
mulsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm2
addsd 0xcfe51(%rip), %xmm2    # 0xf17e8
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
cmpl $0x1, %ebp
movsd %xmm1, 0x50(%rsp)
je 0x219b0
movapd %xmm0, %xmm2
jmp 0x219b4
divsd %xmm1, %xmm3
movsd %xmm3, 0x18(%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 0x18(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x21a0c
movsd 0x20(%rsp), %xmm2
movsd %xmm2, (%rax,%r15,8)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x21a1b
movsd %xmm1, (%rax,%r15,8)
testb $0x1, %r15b
je 0x21a5e
leal -0x1(%r15), %eax
shrl %eax
leaq 0xd26b2(%rip), %rcx     # 0xf40e0
movsd (%rcx,%rax,8), %xmm1
mulsd 0x10(%rsp), %xmm1
cmpl $0x1, %ebp
jne 0x21a44
divsd 0x50(%rsp), %xmm1
mulsd 0x30(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
movsd (%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rsp)
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incq %r15
addq $0x8, %r13
cmpq $0xf, %r15
jne 0x21937
movsd %xmm0, 0x8(%rsp)
subsd (%rsp), %xmm0
andpd 0xcf7b0(%rip), %xmm0    # 0xf1240
mulsd 0xd2528(%rip), %xmm0    # 0xf3fc0
movsd 0xd2518(%rip), %xmm1    # 0xf3fb8
callq 0x8620
movsd %xmm0, 0x8(%rbx)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rbx)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq