// File: /workspace/github_c_makefile_star2_O1/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 0xcfea
leaq 0xe495f(%rip), %rsi     # 0xf18f9
leaq 0x860(%rsp), %rbx
movq %rbx, %rdi
movb $0x2, %al
callq 0x30c2c
leaq 0xe40cf(%rip), %rsi     # 0xf1082
leaq 0xe4964(%rip), %rdx     # 0xf191e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe4061(%rip), %rsi     # 0xf1034
leaq 0xe4961(%rip), %rdx     # 0xf193b
movq %r13, %rdi
movl $0x2c, %ecx
movq %r14, %r8
jmp 0xd5b5
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 0xd008
movsd %xmm0, 0x20(%rsp)
leaq 0x860(%rsp), %rsi
movl %ebp, %edi
callq 0xa15c
cmpl $0x1, %eax
jne 0xd06e
leaq 0x8c8(%rsp), %rcx
leaq 0xe43b3(%rip), %rsi     # 0xf13f0
leaq 0xe4902(%rip), %rdx     # 0xf1946
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3fda(%rip), %rsi     # 0xf1034
leaq 0xe48da(%rip), %rdx     # 0xf193b
movq %r13, %rdi
movl $0x34, %ecx
jmp 0xd5b2
movslq %ebp, %r13
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0xd280
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 0xd2c0
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 0xd3e8
movsd 0x48(%rsp), %xmm3
mulsd 0x38(%rsp), %xmm3
movapd %xmm3, %xmm0
movsd 0x8(%rsp), %xmm2
divsd %xmm2, %xmm0
andpd 0xe414e(%rip), %xmm0    # 0xf1240
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0xd42b
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 0xd1c3
movapd %xmm3, 0x50(%rsp)
ucomisd 0x20(%rsp), %xmm2
movq 0x1930(%rsp), %rcx
jne 0xd19a
jp 0xd19a
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 0xd57c
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 0xd4c9
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 0xa57b
cmpl $0x1, %eax
je 0xd484
cmpw $0x1, %r13w
jne 0xd25f
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 0xd50c
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 0xd544
incl %ebx
xorl %r13d, %r13d
movsd 0x8(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd2c4
movapd %xmm1, %xmm0
cmpl %r12d, %ebx
jl 0xd0ad
jmp 0xd2c4
leaq 0xe3d7d(%rip), %rsi     # 0xf1004
leaq 0x10c7af(%rip), %rdx    # 0x119a3d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3d8d(%rip), %rsi     # 0xf1034
leaq 0xe468d(%rip), %rdx     # 0xf193b
movq 0x1930(%rsp), %rdi
movl $0x36, %ecx
jmp 0xd5b2
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 0xd326
leaq 0xe40fe(%rip), %rsi     # 0xf13f0
leaq 0xe4754(%rip), %rdx     # 0xf1a4d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3d22(%rip), %rsi     # 0xf1034
leaq 0xe4622(%rip), %rdx     # 0xf193b
movq %r12, %rdi
movl $0x9f, %ecx
jmp 0xd5b2
movq 0x1928(%rsp), %rax
testq %rax, %rax
je 0xd387
movsd 0x8(%rsp), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq *%rax
cmpl $0x1, %eax
jne 0xd387
leaq 0xe409d(%rip), %rsi     # 0xf13f0
leaq 0xe473c(%rip), %rdx     # 0xf1a96
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3cc1(%rip), %rsi     # 0xf1034
leaq 0xe45c1(%rip), %rdx     # 0xf193b
movq %r12, %rdi
movl $0xa8, %ecx
jmp 0xd5b2
leaq 0x860(%rsp), %rdi
callq 0xa510
cmpl $0x1, %eax
jne 0xd3d9
leaq 0x8c8(%rsp), %rcx
leaq 0xe4048(%rip), %rsi     # 0xf13f0
leaq 0xe484a(%rip), %rdx     # 0xf1bf9
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3c6f(%rip), %rsi     # 0xf1034
leaq 0xe456f(%rip), %rdx     # 0xf193b
movq %r12, %rdi
movl $0xac, %ecx
jmp 0xd5b2
movq %rbp, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0xd5c1
leaq 0xe4001(%rip), %rsi     # 0xf13f0
leaq 0xe457b(%rip), %rdx     # 0xf1971
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x1930(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3c1d(%rip), %rsi     # 0xf1034
leaq 0xe451d(%rip), %rdx     # 0xf193b
movq %r14, %rdi
movl $0x43, %ecx
jmp 0xd5b2
leaq 0xe4599(%rip), %rsi     # 0xf19cb
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movb $0x1, %al
callq 0x30c2c
leaq 0xe3c3a(%rip), %rsi     # 0xf1082
leaq 0xe45d8(%rip), %rdx     # 0xf1a27
leaq 0x10d0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3bc9(%rip), %rsi     # 0xf1034
leaq 0xe44c9(%rip), %rdx     # 0xf193b
movq 0x1930(%rsp), %rdi
movl $0x49, %ecx
jmp 0xcfe2
leaq 0x8c8(%rsp), %rcx
leaq 0xe3f5d(%rip), %rsi     # 0xf13f0
leaq 0xe464e(%rip), %rdx     # 0xf1ae8
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3b84(%rip), %rsi     # 0xf1034
leaq 0xe4484(%rip), %rdx     # 0xf193b
movq 0x1930(%rsp), %rdi
movl $0x77, %ecx
jmp 0xd5b2
leaq 0xe3f20(%rip), %rsi     # 0xf13f0
leaq 0xe45bf(%rip), %rdx     # 0xf1a96
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x1930(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3b3c(%rip), %rsi     # 0xf1034
leaq 0xe443c(%rip), %rdx     # 0xf193b
movq %r14, %rdi
movl $0x6b, %ecx
jmp 0xd5b2
leaq 0xe3edd(%rip), %rsi     # 0xf13f0
leaq 0xe463f(%rip), %rdx     # 0xf1b59
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3b01(%rip), %rsi     # 0xf1034
leaq 0xe4401(%rip), %rdx     # 0xf193b
movq %r13, %rdi
movl $0x81, %ecx
jmp 0xd5b2
leaq 0xe3ea5(%rip), %rsi     # 0xf13f0
leaq 0xe4650(%rip), %rdx     # 0xf1ba2
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3ac9(%rip), %rsi     # 0xf1034
leaq 0xe43c9(%rip), %rdx     # 0xf193b
movq %r13, %rdi
movl $0x8a, %ecx
jmp 0xd5b2
leaq 0xe3e6d(%rip), %rsi     # 0xf13f0
leaq 0xe44c3(%rip), %rdx     # 0xf1a4d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %rcx, %r14
xorl %eax, %eax
callq 0x30c2c
leaq 0xe3a91(%rip), %rsi     # 0xf1034
leaq 0xe4391(%rip), %rdx     # 0xf193b
movq %r14, %rdi
movl $0x62, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x18d8, %rsp           # imm = 0x18D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop