// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%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, 0x20(%rsp)
movapd 0xe3c8c(%rip), %xmm0    # 0xee230
movapd %xmm1, 0x40(%rsp)
xorpd %xmm1, %xmm0
movslq (%rcx), %rax
testq %rax, %rax
jle 0xa5cf
movq 0x10(%r15), %rcx
xorl %edx, %edx
movsd (%r14,%rdx,8), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xa5bc
movapd 0x40(%rsp), %xmm2
maxsd %xmm0, %xmm2
leaq 0x68(%r15), %rbx
movl $0x1, %ebp
movsd 0x8(%rsp), %xmm4
movsd %xmm3, 0x18(%rsp)
movapd %xmm2, 0x50(%rsp)
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
movsd %xmm4, 0x30(%rsp)
movapd %xmm4, %xmm0
movq %r12, %rdx
movq %rbx, %rcx
callq *%r13
cmpl $0x1, %eax
je 0xa78e
movslq (%r15), %rax
testq %rax, %rax
movapd 0xe3c1a(%rip), %xmm2    # 0xee240
movsd 0xe3c22(%rip), %xmm3    # 0xee250
movapd 0x50(%rsp), %xmm4
jle 0xa66f
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 0xa644
movapd %xmm4, %xmm1
movsd 0x30(%rsp), %xmm3
addsd %xmm3, %xmm1
movapd %xmm1, %xmm0
movsd 0x18(%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 0x20(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
leaq 0x68(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r13, %rcx
movq %r12, %r8
movq %r15, %r9
callq 0xa8ad
testl %eax, %eax
jne 0xa7c6
movsd 0x20(%rsp), %xmm4
movapd %xmm4, %xmm0
movsd 0x18(%rsp), %xmm3
subsd %xmm3, %xmm0
mulsd 0x40(%rsp), %xmm0
ucomisd 0xe3b5d(%rip), %xmm0    # 0xee258
jae 0xa804
movsd 0x38(%rsp), %xmm2
movapd %xmm2, %xmm0
divsd 0x8(%rsp), %xmm0
andpd 0xe3b27(%rip), %xmm0    # 0xee240
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0xa82d
incl %ebp
cmpl $0x186a1, %ebp          # imm = 0x186A1
jne 0xa5ee
leaq 0xe3dc2(%rip), %rsi     # 0xee500
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movapd %xmm3, %xmm1
movb $0x2, %al
callq 0x30af0
leaq 0xe3e27(%rip), %rsi     # 0xee585
leaq 0x870(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30af0
leaq 0xe38ba(%rip), %rsi     # 0xee034
leaq 0xe3bfd(%rip), %rdx     # 0xee37e
movq %rbx, %rdi
movl $0x80, %ecx
jmp 0xa888
leaq 0xe3c5b(%rip), %rsi     # 0xee3f0
leaq 0xe3c66(%rip), %rdx     # 0xee402
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe387f(%rip), %rsi     # 0xee034
leaq 0xe3bc2(%rip), %rdx     # 0xee37e
movq %rbx, %rdi
movl $0x63, %ecx
jmp 0xa7fc
leaq 0xe3c23(%rip), %rsi     # 0xee3f0
leaq 0xe3c84(%rip), %rdx     # 0xee458
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe3847(%rip), %rsi     # 0xee034
leaq 0xe3b8a(%rip), %rdx     # 0xee37e
movq %rbx, %rdi
movl $0x70, %ecx
movq %r14, %r8
jmp 0xa88b
movslq (%r15), %rcx
testq %rcx, %rcx
jle 0xa8a9
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 0xa818
jmp 0xa897
leaq 0xe3c76(%rip), %rsi     # 0xee4aa
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
movb $0x4, %al
callq 0x30af0
leaq 0xe382c(%rip), %rsi     # 0xee082
leaq 0xe3c8c(%rip), %rdx     # 0xee4e9
leaq 0x870(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe37bb(%rip), %rsi     # 0xee034
leaq 0xe3afe(%rip), %rdx     # 0xee37e
movq %rbx, %rdi
movl $0x7b, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
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 0xa897