// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/evolver_rkck.c
// Function: evolver_rk
int evolver_rk(int (*derivs)(double x,
				  double * y,
				  double * dy,
				  void * parameters_and_workspace,
				  ErrorMsg error_message),
		    double x_ini,
		    double x_end,
		    double * y,
		    int * used_in_output,
		    int y_size,
		    void * parameters_and_workspace_for_derivs,
		    double tolerance,
		    double minimum_variation,
		    int (*evaluate_timescale)(double x,
					      void * parameters_and_workspace,
					      double * timescale,
					      ErrorMsg error_message),
		    double timestep_over_timescale,
		    double * x_sampling,
		    int x_size,
		    int (*output)(double x,
				  double y[],
				  double dy[],
				  int index_x,
				  void * parameters_and_workspace,
				  ErrorMsg error_message),
		    int (*print_variables)(double x,
					   double y[],
					   double dy[],
					   void * parameters_and_workspace,
					   ErrorMsg error_message),
		    ErrorMsg error_message) {

  int next_index_x;
  double x1,x2=0.,timestep,timescale;
  struct generic_integrator_workspace gi;
  double * dy;
  short call_output;

  class_test(x_ini > x_sampling[x_size-1],
	     error_message,
	     "called with x=%e, last x_sampling=%e",x_ini,x_sampling[x_size-1]);

  next_index_x=0;

  while (x_sampling[next_index_x] < x_ini) next_index_x++;

  class_call(initialize_generic_integrator(y_size, &gi),
	     gi.error_message,
	     error_message);

  class_alloc(dy,y_size*sizeof(double),error_message);

  x1=x_ini;

  call_output = _FALSE_;

  while ((x1 < x_end) && (next_index_x<x_size)) {

    class_call((*evaluate_timescale)(x1,
				     parameters_and_workspace_for_derivs,
				     &timescale,
				     error_message),
	       error_message,
	       error_message);

    timestep = timestep_over_timescale * timescale;

    class_test(fabs(timestep/x1) < minimum_variation,
	       error_message,
	       "integration step =%e < machine precision : leads either to numerical error or infinite loop",fabs(timestep/x1));

    if (x1 + 2.* timestep < x_sampling[next_index_x]) {
      x2 = x1 + timestep;
    }
    else {
      x2 = x_sampling[next_index_x];
      call_output = _TRUE_;
    }

    if (x2 > x_end) {
      x2 = x_end;
      call_output = _FALSE_;
    }

    if (print_variables != NULL) {

      if (x1 == x_ini) {

	class_call((*derivs)(x1,
			     y,
			     dy,
			     parameters_and_workspace_for_derivs,
			     error_message),
		   error_message,
		   error_message);
      }

      class_call((*print_variables)(x1,
				    y,
				    dy,
				    parameters_and_workspace_for_derivs,
				    error_message),
		 error_message,
		 error_message);
    }

    class_call(generic_integrator(derivs,
				  x1,
				  x2,
				  y,
				  parameters_and_workspace_for_derivs,
				  tolerance,
				  x1*minimum_variation,
				  &gi),
	       gi.error_message,
	       error_message);

    if (call_output == _TRUE_) {

      class_call((*derivs)(x2,
			   y,
			   dy,
			   parameters_and_workspace_for_derivs,
			   error_message),
		 error_message,
		 error_message);

      class_call((*output)(x2,
			   y,
			   dy,
			   next_index_x,
			   parameters_and_workspace_for_derivs,
			   error_message),
		 error_message,
		 error_message);

      call_output = _FALSE_;

      next_index_x++;

    }

    x1 = x2;

  }

  /* a last call is compulsory to ensure that all quantitites in
     y,dy,parameters_and_workspace_for_derivs are updated to the last
     point in the covered range */
  class_call((*derivs)(x1,
		       y,
		       dy,
		       parameters_and_workspace_for_derivs,
		       error_message),
	     error_message,
	     error_message);

  if (print_variables != NULL)
    class_call((*print_variables)(x1,
				  y,
				  dy,
				  parameters_and_workspace_for_derivs,
				  error_message),
	       error_message,
	       error_message);

  class_call(cleanup_generic_integrator(&gi),
	     gi.error_message,
	     error_message);

  free(dy);

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18d8, %rsp           # imm = 0x18D8
movsd %xmm3, 0x28(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movslq 0x1918(%rsp), %r12
movq 0x1930(%rsp), %r13
movq 0x1910(%rsp), %rax
movsd -0x8(%rax,%r12,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd0ce
leaq 0xe187b(%rip), %rsi     # 0xee8f9
leaq 0x860(%rsp), %rbx
movq %rbx, %rdi
movb $0x2, %al
callq 0x30af0
leaq 0xe0feb(%rip), %rsi     # 0xee082
leaq 0xe1880(%rip), %rdx     # 0xee91e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0f7d(%rip), %rsi     # 0xee034
leaq 0xe187d(%rip), %rdx     # 0xee93b
movq %r13, %rdi
movl $0x2c, %ecx
movq %r14, %r8
jmp 0xd699
movq %r8, %r14
movl %ecx, %ebp
movq %rsi, %r15
movsd %xmm2, 0x30(%rsp)
movq %r9, 0x40(%rsp)
movsd %xmm4, 0x38(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
incl %ebx
ucomisd (%rax), %xmm0
leaq 0x8(%rax), %rax
ja 0xd0ec
movsd %xmm0, 0x20(%rsp)
leaq 0x860(%rsp), %rsi
movl %ebp, %edi
callq 0xa140
cmpl $0x1, %eax
jne 0xd152
leaq 0x8c8(%rsp), %rcx
leaq 0xe12cf(%rip), %rsi     # 0xee3f0
leaq 0xe181e(%rip), %rdx     # 0xee946
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xe0ef6(%rip), %rsi     # 0xee034
leaq 0xe17f6(%rip), %rdx     # 0xee93b
movq %r13, %rdi
movl $0x34, %ecx
jmp 0xd696
movslq %ebp, %r13
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0xd364
movq %rax, %rbp
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %al
cmpl %r12d, %ebx
setge %cl
orb %al, %cl
jne 0xd3a4
xorl %r13d, %r13d
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
movq 0x1930(%rsp), %rdx
callq *0x40(%rsp)
cmpl $0x1, %eax
je 0xd4cc
movsd 0x48(%rsp), %xmm3
mulsd 0x38(%rsp), %xmm3
movapd %xmm3, %xmm0
movsd 0x8(%rsp), %xmm2
divsd %xmm2, %xmm0
andpd 0xe106a(%rip), %xmm0    # 0xee240
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0xd50f
movapd %xmm2, %xmm0
addsd %xmm3, %xmm0
addsd %xmm3, %xmm3
addsd %xmm2, %xmm3
movslq %ebx, %rax
movq 0x1910(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd %xmm3, %xmm1
cmpltsd %xmm1, %xmm3
andpd %xmm3, %xmm0
movl $0x1, %eax
cmovbel %eax, %r13d
andnpd %xmm1, %xmm3
orpd %xmm0, %xmm3
ucomisd 0x18(%rsp), %xmm3
movl $0x0, %eax
cmoval %eax, %r13d
cmpq $0x0, 0x1928(%rsp)
je 0xd2a7
movapd %xmm3, 0x50(%rsp)
ucomisd 0x20(%rsp), %xmm2
movq 0x1930(%rsp), %rcx
jne 0xd27e
jp 0xd27e
movapd %xmm2, %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq *0x10(%rsp)
movq 0x1930(%rsp), %rcx
movsd 0x8(%rsp), %xmm2
cmpl $0x1, %eax
je 0xd660
movapd %xmm2, %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq *0x1928(%rsp)
movsd 0x8(%rsp), %xmm2
cmpl $0x1, %eax
movapd 0x50(%rsp), %xmm3
je 0xd5ad
movsd 0x18(%rsp), %xmm1
minsd %xmm3, %xmm1
movapd %xmm2, %xmm3
mulsd 0x28(%rsp), %xmm3
movq 0x10(%rsp), %rdi
movapd %xmm2, %xmm0
movsd %xmm1, 0x8(%rsp)
movq %r15, %rsi
movq %r14, %rdx
movsd 0x30(%rsp), %xmm2
leaq 0x860(%rsp), %rcx
callq 0xa55f
cmpl $0x1, %eax
je 0xd568
cmpw $0x1, %r13w
jne 0xd343
movsd 0x8(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x1930(%rsp), %r13
movq %r13, %rcx
callq *0x10(%rsp)
cmpl $0x1, %eax
je 0xd5f0
movsd 0x8(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movl %ebx, %edx
movq %r14, %rcx
movq %r13, %r8
callq *0x1920(%rsp)
cmpl $0x1, %eax
je 0xd628
incl %ebx
xorl %r13d, %r13d
movsd 0x8(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd3a8
movapd %xmm1, %xmm0
cmpl %r12d, %ebx
jl 0xd191
jmp 0xd3a8
leaq 0xe0c99(%rip), %rsi     # 0xee004
leaq 0x10970b(%rip), %rdx    # 0x116a7d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0ca9(%rip), %rsi     # 0xee034
leaq 0xe15a9(%rip), %rdx     # 0xee93b
movq 0x1930(%rsp), %rdi
movl $0x36, %ecx
jmp 0xd696
movapd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x1930(%rsp), %r12
movq %r12, %rcx
callq *0x10(%rsp)
cmpl $0x1, %eax
jne 0xd40a
leaq 0xe101a(%rip), %rsi     # 0xee3f0
leaq 0xe1670(%rip), %rdx     # 0xeea4d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0c3e(%rip), %rsi     # 0xee034
leaq 0xe153e(%rip), %rdx     # 0xee93b
movq %r12, %rdi
movl $0x9f, %ecx
jmp 0xd696
movq 0x1928(%rsp), %rax
testq %rax, %rax
je 0xd46b
movsd 0x8(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq *%rax
cmpl $0x1, %eax
jne 0xd46b
leaq 0xe0fb9(%rip), %rsi     # 0xee3f0
leaq 0xe1658(%rip), %rdx     # 0xeea96
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0bdd(%rip), %rsi     # 0xee034
leaq 0xe14dd(%rip), %rdx     # 0xee93b
movq %r12, %rdi
movl $0xa8, %ecx
jmp 0xd696
leaq 0x860(%rsp), %rdi
callq 0xa4f4
cmpl $0x1, %eax
jne 0xd4bd
leaq 0x8c8(%rsp), %rcx
leaq 0xe0f64(%rip), %rsi     # 0xee3f0
leaq 0xe1766(%rip), %rdx     # 0xeebf9
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xe0b8b(%rip), %rsi     # 0xee034
leaq 0xe148b(%rip), %rdx     # 0xee93b
movq %r12, %rdi
movl $0xac, %ecx
jmp 0xd696
movq %rbp, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0xd6a5
leaq 0xe0f1d(%rip), %rsi     # 0xee3f0
leaq 0xe1497(%rip), %rdx     # 0xee971
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x1930(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0b39(%rip), %rsi     # 0xee034
leaq 0xe1439(%rip), %rdx     # 0xee93b
movq %r14, %rdi
movl $0x43, %ecx
jmp 0xd696
leaq 0xe14b5(%rip), %rsi     # 0xee9cb
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movb $0x1, %al
callq 0x30af0
leaq 0xe0b56(%rip), %rsi     # 0xee082
leaq 0xe14f4(%rip), %rdx     # 0xeea27
leaq 0x10d0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0ae5(%rip), %rsi     # 0xee034
leaq 0xe13e5(%rip), %rdx     # 0xee93b
movq 0x1930(%rsp), %rdi
movl $0x49, %ecx
jmp 0xd0c6
leaq 0x8c8(%rsp), %rcx
leaq 0xe0e79(%rip), %rsi     # 0xee3f0
leaq 0xe156a(%rip), %rdx     # 0xeeae8
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xe0aa0(%rip), %rsi     # 0xee034
leaq 0xe13a0(%rip), %rdx     # 0xee93b
movq 0x1930(%rsp), %rdi
movl $0x77, %ecx
jmp 0xd696
leaq 0xe0e3c(%rip), %rsi     # 0xee3f0
leaq 0xe14db(%rip), %rdx     # 0xeea96
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x1930(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0a58(%rip), %rsi     # 0xee034
leaq 0xe1358(%rip), %rdx     # 0xee93b
movq %r14, %rdi
movl $0x6b, %ecx
jmp 0xd696
leaq 0xe0df9(%rip), %rsi     # 0xee3f0
leaq 0xe155b(%rip), %rdx     # 0xeeb59
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe0a1d(%rip), %rsi     # 0xee034
leaq 0xe131d(%rip), %rdx     # 0xee93b
movq %r13, %rdi
movl $0x81, %ecx
jmp 0xd696
leaq 0xe0dc1(%rip), %rsi     # 0xee3f0
leaq 0xe156c(%rip), %rdx     # 0xeeba2
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xe09e5(%rip), %rsi     # 0xee034
leaq 0xe12e5(%rip), %rdx     # 0xee93b
movq %r13, %rdi
movl $0x8a, %ecx
jmp 0xd696
leaq 0xe0d89(%rip), %rsi     # 0xee3f0
leaq 0xe13df(%rip), %rdx     # 0xeea4d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %rcx, %r14
xorl %eax, %eax
callq 0x30af0
leaq 0xe09ad(%rip), %rsi     # 0xee034
leaq 0xe12ad(%rip), %rdx     # 0xee93b
movq %r14, %rdi
movl $0x62, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x18d8, %rsp           # imm = 0x18D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop