// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movq %rsi, 0x1b8(%rsp)
movq %rdx, 0x1b0(%rsp)
movq %rcx, 0x1a8(%rsp)
movsd %xmm0, 0x1a0(%rsp)
movsd %xmm1, 0x198(%rsp)
movl %r8d, 0x194(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x197a20(%rip), %rsi    # 0x1d5090
movl $0x78, %edx
callq 0x8300
leaq 0x90(%rsp), %rdi
leaq 0x197a87(%rip), %rsi    # 0x1d5110
movl $0x78, %edx
callq 0x8300
leaq 0x50(%rsp), %rdi
leaq 0x197af1(%rip), %rsi    # 0x1d5190
movl $0x38, %edx
callq 0x8300
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x0, 0x4c(%rsp)
cmpl $0xf, 0x4c(%rsp)
jge 0x3d927
movsd 0x1a0(%rsp), %xmm1
movslq 0x4c(%rsp), %rax
movsd 0x194b64(%rip), %xmm2   # 0x1d2248
subsd 0x110(%rsp,%rax,8), %xmm2
movsd 0x198(%rsp), %xmm0
movslq 0x4c(%rsp), %rax
movsd 0x194b45(%rip), %xmm3   # 0x1d2248
addsd 0x110(%rsp,%rax,8), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x195568(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x198(%rsp), %xmm1
subsd 0x1a0(%rsp), %xmm1
movsd 0x195544(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
movslq 0x4c(%rsp), %rax
mulsd 0x90(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x30(%rsp)
cmpl $0x1, 0x194(%rsp)
jne 0x3d7a4
movsd 0x194ada(%rip), %xmm0   # 0x1d2248
divsd 0x28(%rsp), %xmm0
movsd 0x194acc(%rip), %xmm1   # 0x1d2248
subsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x3d7b0
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x1c0(%rsp), %rax
movq 0x1b0(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
leaq 0x10(%rsp), %rsi
callq *%rax
movq 0x1b8(%rsp), %rax
movq 0x1b0(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
leaq 0x8(%rsp), %rsi
callq *%rax
movsd 0x8(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x1a8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x3d847
movsd 0x40(%rsp), %xmm0
movq 0x1a8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x4c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1a8(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x3d872
movsd 0x30(%rsp), %xmm0
movq 0x1a8(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x4c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x4c(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x3d915
movl 0x4c(%rsp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0x48(%rsp)
movsd 0x198(%rsp), %xmm1
subsd 0x1a0(%rsp), %xmm1
movsd 0x1953d4(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
movslq 0x48(%rsp), %rax
mulsd 0x50(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x38(%rsp)
cmpl $0x1, 0x194(%rsp)
jne 0x3d8ef
movsd 0x38(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x3d917
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x3d6c3
movsd 0x20(%rsp), %xmm1
subsd 0x18(%rsp), %xmm1
movaps 0x1948f6(%rip), %xmm0   # 0x1d2230
pand %xmm0, %xmm1
movsd 0x197692(%rip), %xmm0   # 0x1d4fd8
mulsd %xmm1, %xmm0
movsd 0x1952fe(%rip), %xmm1   # 0x1d2c50
callq 0x8610
movq 0x1a8(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x20(%rsp), %xmm0
movq 0x1a8(%rsp), %rax
movsd %xmm0, (%rax)
xorl %eax, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
retq