// File: /workspace/github_c_makefile_star2_O2/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 $0x18e8, %rsp           # imm = 0x18E8
movsd %xmm4, 0x50(%rsp)
movq %r9, 0x58(%rsp)
movsd %xmm3, 0x40(%rsp)
movsd %xmm2, 0x48(%rsp)
movl %ecx, %ebx
movsd %xmm1, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
movslq 0x1928(%rsp), %rax
movq 0x1940(%rsp), %r13
movq 0x1920(%rsp), %rcx
movq %rax, 0x60(%rsp)
movsd -0x8(%rcx,%rax,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb800
leaq 0xda144(%rip), %rsi     # 0xe58f9
leaq 0x870(%rsp), %rbx
movq %rbx, %rdi
movb $0x2, %al
callq 0x2e014
leaq 0xd98b4(%rip), %rsi     # 0xe5082
leaq 0xda149(%rip), %rdx     # 0xe591e
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd9846(%rip), %rsi     # 0xe5034
leaq 0xda146(%rip), %rdx     # 0xe593b
pushq $0x2c
popq %rcx
movq %r13, %rdi
movq %r14, %r8
jmp 0xb86e
movq %r8, %r14
movq %rsi, %r12
pushq $-0x1
popq %rbp
movq %rcx, %rax
incl %ebp
ucomisd (%rax), %xmm0
leaq 0x8(%rax), %rax
ja 0xb80c
movsd %xmm0, 0x30(%rsp)
leaq 0x870(%rsp), %rsi
movl %ebx, %edi
callq 0x8cb0
cmpl $0x1, %eax
jne 0xb88e
leaq 0x8d8(%rsp), %rcx
leaq 0xd9baf(%rip), %rsi     # 0xe53f0
leaq 0xda0fe(%rip), %rdx     # 0xe5946
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd97d6(%rip), %rsi     # 0xe5034
leaq 0xda0d6(%rip), %rdx     # 0xe593b
pushq $0x34
popq %rcx
movq %r13, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x18e8, %rsp           # imm = 0x18E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ebx, %rbx
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x8490
movq %rax, (%rsp)
testq %rax, %rax
je 0xbaae
pushq $0x1
popq %r15
movsd 0x30(%rsp), %xmm1
movq 0x1938(%rsp), %rbx
movslq %ebp, %rax
movq %rax, 0x38(%rsp)
xorl %r13d, %r13d
movsd 0x18(%rsp), %xmm0
ucomisd %xmm1, %xmm0
movsd %xmm1, 0x10(%rsp)
jbe 0xbae2
movq 0x38(%rsp), %rax
cmpl 0x60(%rsp), %eax
jge 0xbae2
movapd %xmm1, %xmm0
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
movq 0x1940(%rsp), %rdx
callq *0x58(%rsp)
cmpl $0x1, %eax
je 0xbb46
movsd 0x68(%rsp), %xmm3
mulsd 0x50(%rsp), %xmm3
movapd %xmm3, %xmm0
movsd 0x10(%rsp), %xmm2
divsd %xmm2, %xmm0
andpd 0xd9911(%rip), %xmm0    # 0xe5240
movsd 0x40(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0xbb83
movapd %xmm2, %xmm0
addsd %xmm3, %xmm0
addsd %xmm3, %xmm3
addsd %xmm2, %xmm3
movq 0x1920(%rsp), %rax
movq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
ucomisd %xmm3, %xmm1
cmpltsd %xmm1, %xmm3
andpd %xmm3, %xmm0
cmovbel %r15d, %r13d
andnpd %xmm1, %xmm3
orpd %xmm0, %xmm3
ucomisd 0x18(%rsp), %xmm3
movl $0x0, %eax
cmoval %eax, %r13d
testq %rbx, %rbx
je 0xba00
movapd %xmm3, 0x20(%rsp)
ucomisd 0x30(%rsp), %xmm2
movq 0x1940(%rsp), %r15
movq (%rsp), %rbx
jne 0xb9cd
jp 0xb9cd
movapd %xmm2, %xmm0
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq *0x8(%rsp)
movsd 0x10(%rsp), %xmm2
cmpl $0x1, %eax
je 0xbcc8
movapd %xmm2, %xmm0
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq 0x1938(%rsp), %rbx
callq *%rbx
movsd 0x10(%rsp), %xmm2
cmpl $0x1, %eax
pushq $0x1
popq %r15
movapd 0x20(%rsp), %xmm3
je 0xbc1a
movsd 0x18(%rsp), %xmm1
minsd %xmm3, %xmm1
movapd %xmm2, %xmm3
mulsd 0x40(%rsp), %xmm3
movq 0x8(%rsp), %rdi
movapd %xmm2, %xmm0
movsd %xmm1, 0x20(%rsp)
movq %r12, %rsi
movq %r14, %rdx
movsd 0x48(%rsp), %xmm2
leaq 0x870(%rsp), %rcx
callq 0x908f
cmpl $0x1, %eax
je 0xbbda
movsd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
cmpw $0x1, %r13w
jne 0xb8c7
movq %r12, %rdi
movq (%rsp), %rsi
movq %r14, %rdx
movq 0x1940(%rsp), %r13
movq %r13, %rcx
callq *0x8(%rsp)
cmpl $0x1, %eax
je 0xbd64
movsd 0x20(%rsp), %xmm0
movq %r12, %rdi
movq (%rsp), %rsi
movl %ebp, %edx
movq %r14, %rcx
movq %r13, %r8
callq *0x1930(%rsp)
cmpl $0x1, %eax
je 0xbd9f
incl %ebp
movsd 0x20(%rsp), %xmm1
jmp 0xb8bc
leaq 0xd954f(%rip), %rsi     # 0xe5004
leaq 0x101e61(%rip), %rdx    # 0x10d91d
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0xd9560(%rip), %rsi     # 0xe5034
leaq 0xd9e60(%rip), %rdx     # 0xe593b
pushq $0x36
jmp 0xb7f7
movapd %xmm1, %xmm0
movq %r12, %rbx
movq %r12, %rdi
movq (%rsp), %rsi
movq %r14, %rdx
movq 0x1940(%rsp), %r12
movq %r12, %rcx
callq *0x8(%rsp)
cmpl $0x1, %eax
jne 0xbc65
leaq 0xd98de(%rip), %rsi     # 0xe53f0
leaq 0xd9f34(%rip), %rdx     # 0xe5a4d
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd9502(%rip), %rsi     # 0xe5034
leaq 0xd9e02(%rip), %rdx     # 0xe593b
movq %r12, %rdi
movl $0x9f, %ecx
jmp 0xbc56
leaq 0xd98a3(%rip), %rsi     # 0xe53f0
leaq 0xd9e1d(%rip), %rdx     # 0xe5971
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq 0x1940(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd94bf(%rip), %rsi     # 0xe5034
leaq 0xd9dbf(%rip), %rdx     # 0xe593b
pushq $0x43
jmp 0xbc52
leaq 0xd9e41(%rip), %rsi     # 0xe59cb
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movb $0x1, %al
callq 0x2e014
leaq 0xd94e2(%rip), %rsi     # 0xe5082
leaq 0xd9e80(%rip), %rdx     # 0xe5a27
leaq 0x10e0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd9471(%rip), %rsi     # 0xe5034
leaq 0xd9d71(%rip), %rdx     # 0xe593b
pushq $0x49
popq %rcx
movq 0x1940(%rsp), %rdi
movq %r14, %r8
jmp 0xbc59
leaq 0x8d8(%rsp), %rcx
leaq 0xd9807(%rip), %rsi     # 0xe53f0
leaq 0xd9ef8(%rip), %rdx     # 0xe5ae8
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd942e(%rip), %rsi     # 0xe5034
leaq 0xd9d2e(%rip), %rdx     # 0xe593b
pushq $0x77
popq %rcx
movq 0x1940(%rsp), %rdi
jmp 0xbc56
leaq 0xd97cf(%rip), %rsi     # 0xe53f0
leaq 0xd9e6e(%rip), %rdx     # 0xe5a96
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq 0x1940(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd93eb(%rip), %rsi     # 0xe5034
leaq 0xd9ceb(%rip), %rdx     # 0xe593b
pushq $0x6b
popq %rcx
movq %r14, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0xb879
movq 0x1938(%rsp), %rax
testq %rax, %rax
je 0xbd01
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
movq (%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
callq *%rax
cmpl $0x1, %eax
jne 0xbd01
leaq 0xd9759(%rip), %rsi     # 0xe53f0
leaq 0xd9df8(%rip), %rdx     # 0xe5a96
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd937d(%rip), %rsi     # 0xe5034
leaq 0xd9c7d(%rip), %rdx     # 0xe593b
movq %r12, %rdi
movl $0xa8, %ecx
jmp 0xbc56
leaq 0xd9721(%rip), %rsi     # 0xe53f0
leaq 0xd9d77(%rip), %rdx     # 0xe5a4d
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd9345(%rip), %rsi     # 0xe5034
leaq 0xd9c45(%rip), %rdx     # 0xe593b
pushq $0x62
popq %rcx
movq %r15, %rdi
jmp 0xb86b
leaq 0x870(%rsp), %rdi
callq 0x9024
cmpl $0x1, %eax
jne 0xbd53
leaq 0x8d8(%rsp), %rcx
leaq 0xd96ce(%rip), %rsi     # 0xe53f0
leaq 0xd9ed0(%rip), %rdx     # 0xe5bf9
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd92f5(%rip), %rsi     # 0xe5034
leaq 0xd9bf5(%rip), %rdx     # 0xe593b
movq %r12, %rdi
movl $0xac, %ecx
jmp 0xbc56
movq (%rsp), %rdi
callq 0x8430
xorl %r15d, %r15d
jmp 0xb879
leaq 0xd9685(%rip), %rsi     # 0xe53f0
leaq 0xd9de7(%rip), %rdx     # 0xe5b59
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd92a9(%rip), %rsi     # 0xe5034
leaq 0xd9ba9(%rip), %rdx     # 0xe593b
movq %r13, %rdi
movl $0x81, %ecx
jmp 0xbc56
leaq 0xd964a(%rip), %rsi     # 0xe53f0
leaq 0xd9df5(%rip), %rdx     # 0xe5ba2
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd926e(%rip), %rsi     # 0xe5034
leaq 0xd9b6e(%rip), %rdx     # 0xe593b
movq %r13, %rdi
movl $0x8a, %ecx
jmp 0xbc56
nop