// File: /workspace/github_c_makefile_star2_O0/guszejnovdavid[P]MISFIT/RK4solver.c
// Function: rk4_step(double*, double, double, long)
void rk4_step ( double y[], double t, double dt, long dimension )


/******************************************************************************/
/*
  Purpose:

    Carries out the 4th order Runge-Kutta integration between t and tout
*/
{

  long j; //loop integer
  double *temp, *k1, *k2, *k3, *k4; //intermediate results
  //Allocating memory for arrays
  temp = ( double * ) malloc ( dimension * sizeof ( double ) );
  k1 = ( double * ) malloc (dimension * sizeof ( double ) );
  k2 = ( double * ) malloc ( dimension * sizeof ( double ) );
  k3 = ( double * ) malloc ( dimension * sizeof ( double ) );
  k4 = ( double * ) malloc ( dimension * sizeof ( double ) );
  
 
 Deriv_func ( t , y, k1, dt, dimension ); //calculating k1
 
 vector_const_multiply( k1, k1, dt, dimension );
 vector_const_multiply( temp, k1, 0.5, dimension ); // getting 0.5*k1
 vector_add( temp, y, temp,dimension ); // getting y+0.5*k1
 
 Deriv_func ( (t+0.5*dt) , temp, k2, dt, dimension ); //calculating k2
 
 vector_const_multiply( k2, k2, dt,dimension ); 
 vector_const_multiply( temp, k2, 0.5,dimension ); // getting 0.5*k2
 vector_add( temp, y, temp,dimension ); // getting y+0.5*k2
 Deriv_func ( (t+0.5*dt) , temp, k3, dt, dimension ); //calculating k3
 
 vector_const_multiply( k3, k3, dt,dimension ); 
 vector_add( temp, y, k3,dimension ); // getting y+k3
 Deriv_func ( (t+dt) , temp, k4, dt, dimension ); //calculating k4
 vector_const_multiply( k4, k4, dt,dimension );
 //Getting next y values
 for(j=0;j<dimension;j++){
 					 y[j]+=(k1[j]+2*k2[j]+2*k3[j]+k4[j])/6.0;
					 }		  

//Cleanup
free(temp);
free(k1);
free(k2);
free(k3);
free(k4);

return;           

      }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movsd %xmm0, 0x48(%rsp)
movsd %xmm1, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8890
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8890
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8890
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8890
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8890
movq %rax, 0x8(%rsp)
movsd 0x48(%rsp), %xmm0
movq 0x50(%rsp), %rdi
movq 0x20(%rsp), %rsi
movsd 0x40(%rsp), %xmm1
movq 0x38(%rsp), %rdx
callq 0x177a0
movq 0x20(%rsp), %rdi
movq 0x20(%rsp), %rsi
movsd 0x40(%rsp), %xmm0
movq 0x38(%rsp), %rdx
callq 0x1b7b0
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x38(%rsp), %rdx
movsd 0x3106(%rip), %xmm0     # 0x1c4f0
callq 0x1b7b0
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x1b740
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
movsd 0x30d4(%rip), %xmm2     # 0x1c4f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
movsd 0x40(%rsp), %xmm1
movq 0x38(%rsp), %rdx
callq 0x177a0
movq 0x18(%rsp), %rdi
movq 0x18(%rsp), %rsi
movsd 0x40(%rsp), %xmm0
movq 0x38(%rsp), %rdx
callq 0x1b7b0
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdx
movsd 0x3081(%rip), %xmm0     # 0x1c4f0
callq 0x1b7b0
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x1b740
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
movsd 0x304f(%rip), %xmm2     # 0x1c4f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movsd 0x40(%rsp), %xmm1
movq 0x38(%rsp), %rdx
callq 0x177a0
movq 0x10(%rsp), %rdi
movq 0x10(%rsp), %rsi
movsd 0x40(%rsp), %xmm0
movq 0x38(%rsp), %rdx
callq 0x1b7b0
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x1b740
movsd 0x48(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movsd 0x40(%rsp), %xmm1
movq 0x38(%rsp), %rdx
callq 0x177a0
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rsi
movsd 0x40(%rsp), %xmm0
movq 0x38(%rsp), %rdx
callq 0x1b7b0
movq $0x0, 0x30(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jge 0x195ca
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x18(%rsp), %rax
movq 0x30(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x8(%rsp), %rax
movq 0x30(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd 0x33b9(%rip), %xmm1     # 0x1c958
divsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movq 0x30(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x1953f
movq 0x28(%rsp), %rdi
callq 0x8780
movq 0x20(%rsp), %rdi
callq 0x8780
movq 0x18(%rsp), %rdi
callq 0x8780
movq 0x10(%rsp), %rdi
callq 0x8780
movq 0x8(%rsp), %rdi
callq 0x8780
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)