// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/dei_rkck.c
// Function: generic_integrator
int generic_integrator(int (*derivs)(double x, double y[], double yprime[], void * parameters_and_workspace, ErrorMsg error_message),
		       double x1,
		       double x2,
		       double ystart[],
		       void * parameters_and_workspace_for_derivs,
		       double eps,
		       double hmin,
		       struct generic_integrator_workspace * pgi)

{
  int nstp,i;
  double x,hnext,hdid,h,h1;

  h1=x2-x1;
  x=x1;
  h=dsign(h1,x2-x1);
  for (i=0;i<pgi->n;i++) pgi->y[i]=ystart[i];
  for (nstp=1;nstp<=_MAXSTP_;nstp++) {
    class_call((*derivs)(x,pgi->y,pgi->dydx,parameters_and_workspace_for_derivs, pgi->error_message),
	       pgi->error_message,
	       pgi->error_message);
    for (i=0;i<pgi->n;i++)
      pgi->yscal[i]=fabs(pgi->y[i])+fabs(pgi->dydx[i]*h)+_TINY_;
    if ((x+h-x2)*(x+h-x1) > 0.0) h=x2-x;
    class_call(rkqs(&x,
		    h,
		    eps,
		    &hdid,
		    &hnext,
		    derivs,
		    parameters_and_workspace_for_derivs,
		    pgi),
	       pgi->error_message,
	       pgi->error_message);
    if ((x-x2)*(x2-x1) >= 0.0) {
      for (i=0;i<pgi->n;i++) ystart[i]=pgi->y[i];
      return _SUCCESS_;
    }
    class_test(fabs(hnext/x1) <= hmin,
	       pgi->error_message,
	       "Step size too small: step:%g, minimum:%g, in interval: [%g:%g]",
	       fabs(hnext/x1),
	       hmin,
	       x1,
	       x2);
    h=hnext;
  }

  class_stop(pgi->error_message,
	     "Too many integration steps needed within interval [%g : %g],\n the system of equations is probably buggy or featuring a discontinuity",x1,x2);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1078, %rsp           # imm = 0x1078
movq %rcx, %r15
movsd %xmm3, 0x18(%rsp)
movsd %xmm2, 0x28(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movapd %xmm1, %xmm3
movq %rdi, %r13
subsd %xmm0, %xmm1
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
movapd 0xe6c70(%rip), %xmm0    # 0xf1230
movapd %xmm1, 0x40(%rsp)
xorpd %xmm1, %xmm0
movslq (%rcx), %rax
testq %rax, %rax
jle 0xa5eb
movq 0x10(%r15), %rcx
xorl %edx, %edx
movsd (%r14,%rdx,8), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xa5d8
movapd 0x40(%rsp), %xmm2
maxsd %xmm0, %xmm2
leaq 0x68(%r15), %rbx
movl $0x1, %ebp
movsd %xmm3, 0x20(%rsp)
movapd %xmm2, 0x50(%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
movsd %xmm0, 0x30(%rsp)
movq %r12, %rdx
movq %rbx, %rcx
callq *%r13
cmpl $0x1, %eax
je 0xa7a2
movslq (%r15), %rax
testq %rax, %rax
movapd 0xe6c02(%rip), %xmm2    # 0xf1240
movsd 0xe6c0a(%rip), %xmm3    # 0xf1250
movapd 0x50(%rsp), %xmm4
jle 0xa687
movq 0x8(%r15), %rcx
movq 0x10(%r15), %rdx
movq 0x18(%r15), %rsi
xorl %edi, %edi
movsd (%rdx,%rdi,8), %xmm0
andpd %xmm2, %xmm0
movsd (%rsi,%rdi,8), %xmm1
mulsd %xmm4, %xmm1
andpd %xmm2, %xmm1
addsd %xmm0, %xmm1
addsd %xmm3, %xmm1
movsd %xmm1, (%rcx,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0xa65c
movapd %xmm4, %xmm1
movsd 0x30(%rsp), %xmm3
addsd %xmm3, %xmm1
movapd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm2
subsd %xmm2, %xmm0
subsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
subsd %xmm3, %xmm2
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm4, %xmm0
orpd %xmm2, %xmm0
leaq 0x10(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
leaq 0x68(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r13, %rcx
movq %r12, %r8
movq %r15, %r9
callq 0xa8c1
testl %eax, %eax
jne 0xa7da
movsd 0x10(%rsp), %xmm0
movsd 0x20(%rsp), %xmm3
subsd %xmm3, %xmm0
mulsd 0x40(%rsp), %xmm0
ucomisd 0xe6b49(%rip), %xmm0    # 0xf1258
jae 0xa818
movsd 0x38(%rsp), %xmm2
movapd %xmm2, %xmm0
divsd 0x8(%rsp), %xmm0
andpd 0xe6b13(%rip), %xmm0    # 0xf1240
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0xa841
incl %ebp
cmpl $0x186a1, %ebp          # imm = 0x186A1
jne 0xa604
leaq 0xe6dae(%rip), %rsi     # 0xf1500
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movapd %xmm3, %xmm1
movb $0x2, %al
callq 0x30c2c
leaq 0xe6e13(%rip), %rsi     # 0xf1585
leaq 0x870(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe68a6(%rip), %rsi     # 0xf1034
leaq 0xe6be9(%rip), %rdx     # 0xf137e
movq %rbx, %rdi
movl $0x80, %ecx
jmp 0xa89c
leaq 0xe6c47(%rip), %rsi     # 0xf13f0
leaq 0xe6c52(%rip), %rdx     # 0xf1402
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe686b(%rip), %rsi     # 0xf1034
leaq 0xe6bae(%rip), %rdx     # 0xf137e
movq %rbx, %rdi
movl $0x63, %ecx
jmp 0xa810
leaq 0xe6c0f(%rip), %rsi     # 0xf13f0
leaq 0xe6c70(%rip), %rdx     # 0xf1458
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe6833(%rip), %rsi     # 0xf1034
leaq 0xe6b76(%rip), %rdx     # 0xf137e
movq %rbx, %rdi
movl $0x70, %ecx
movq %r14, %r8
jmp 0xa89f
movslq (%r15), %rcx
testq %rcx, %rcx
jle 0xa8bd
movq 0x10(%r15), %rdx
xorl %eax, %eax
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%r14,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0xa82c
jmp 0xa8ab
leaq 0xe6c62(%rip), %rsi     # 0xf14aa
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movsd 0x18(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movb $0x4, %al
callq 0x30c2c
leaq 0xe6818(%rip), %rsi     # 0xf1082
leaq 0xe6c78(%rip), %rdx     # 0xf14e9
leaq 0x870(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe67a7(%rip), %rsi     # 0xf1034
leaq 0xe6aea(%rip), %rdx     # 0xf137e
movq %rbx, %rdi
movl $0x7b, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xa8ab