void rk4RefinedStep(double (*f)(double, double), double (*fy)(double, double),
                    double t0, double y0, double h, int i, double *t,
                    double *y) {
  double k1, k2, k3, k4;
  k1 = h * f(t0, y0);
  k2 =
      h * f(t0 + h / 2, y0 + 1.0 / 3.0 * k1 + 1.0 / 18.0 * h * fy(t0, y0) * k1);
  k3 = h * f(t0 + h / 2, y0 - 152.0 / 125.0 * k1 + 252.0 / 125.0 * k2 -
                             44.0 / 125.0 * h * fy(t0, y0) * k1);
  k4 = h * f(t0 + h, y0 + 19.0 / 2.0 * k1 - 72.0 / 7.0 * k2 + 25.0 / 14.0 * k3 +
                         5.0 / 2.0 * h * fy(t0, y0) * k1);
  *t = t0 + h * i;
  *y = y0 + 5.0 / 48.0 * k1 + 27.0 / 56.0 * k2 + 125.0 / 336.0 * k3 +
       1.0 / 24.0 * k4;
}


x86 assembly (clang, -O0):
<rk4RefinedStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0xe0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0xc8(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xed0(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x20(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xebe(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  0xe9e(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0xd0(%rbp),%xmm2
ff
mov    -0xc8(%rbp),%rax
movaps %xmm0,%xmm3
movsd  -0xc0(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe06(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xddc(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xdbf(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  0xd9f(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
mov    -0xa0(%rbp),%rax
movaps %xmm0,%xmm3
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movsd  -0x48(%rbp),%xmm3
movq   %xmm1,%rcx
movabs $0x8000000000000000,%rdx
xor    %rdx,%rcx
movq   %rcx,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xce7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xcca(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  0xcad(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xc90(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
mov    -0x78(%rbp),%rax
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xbfd(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xbe0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  0xbc3(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  0xba6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rk4RefinedStep>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x38(%rsp)
mov    %rsi,%rbp
mov    %rdi,%rbx
call   *%rdi
movapd %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xeb5(%rip),%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm0,%xmm2
movsd  0x38(%rsp),%xmm0
addsd  %xmm0,%xmm3
movsd  %xmm3,0x20(%rsp)
movsd  0xe9d(%rip),%xmm3
mulsd  %xmm1,%xmm3
movsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm3
movsd  %xmm3,0x28(%rsp)
movsd  0xe89(%rip),%xmm3
mulsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
call   *%rbp
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
call   *%rbx
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0xe53(%rip),%xmm2
mulsd  0x8(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe43(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0x38(%rsp),%xmm0
call   *%rbp
movsd  0xe2d(%rip),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
call   *%rbx
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movapd %xmm0,%xmm4
movsd  %xmm0,0x20(%rsp)
movsd  0x38(%rsp),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm1,%xmm5
movsd  0xde3(%rip),%xmm2
mulsd  0x8(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm2
movsd  0xdd3(%rip),%xmm3
mulsd  0x28(%rsp),%xmm3
addsd  %xmm2,%xmm3
movsd  0xdc9(%rip),%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x48(%rsp)
movsd  0xdbb(%rip),%xmm2
mulsd  %xmm5,%xmm2
movsd  %xmm2,0x40(%rsp)
call   *%rbp
movsd  0x40(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x48(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  0x18(%rsp),%xmm2
mulsd  %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
mulsd  %xmm2,%xmm1
addsd  0x38(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  0xd6f(%rip),%xmm2
movsd  %xmm1,(%r15)
addsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
mulsd  0xd5e(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  0xd54(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  0xd50(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rk4RefinedStep(double (double, double)* %0, double (double, double)* %1, double %2, double %3, double %4, i32 %5, double* %6, double* %7) {
%9 = alloca double (double, double)*
%10 = alloca double (double, double)*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double (double, double)* %0, double (double, double)** %9
store double (double, double)* %1, double (double, double)** %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store i32 %5, i32* %14
store double* %6, double** %15
store double* %7, double** %16
%21 = load double, double* %13
%22 = load double (double, double)*, double (double, double)** %9
%23 = load double, double* %11
%24 = load double, double* %12
%25 = call double %22(double %23, double %24)
%26 = fmul double %21, %25
store double %26, double* %17
%27 = load double, double* %13
%28 = load double (double, double)*, double (double, double)** %9
%29 = load double, double* %11
%30 = load double, double* %13
%31 = fdiv double %30, 2.000000e+00
%32 = fadd double %29, %31
%33 = load double, double* %12
%34 = load double, double* %17
%35 = call double @llvm.fmuladd.f64(double 0x3FD5555555555555, double %34, double %33)
%36 = load double, double* %13
%37 = fmul double 0x3FAC71C71C71C71C, %36
%38 = load double (double, double)*, double (double, double)** %10
%39 = load double, double* %11
%40 = load double, double* %12
%41 = call double %38(double %39, double %40)
%42 = fmul double %37, %41
%43 = load double, double* %17
%44 = call double @llvm.fmuladd.f64(double %42, double %43, double %35)
%45 = call double %28(double %32, double %44)
%46 = fmul double %27, %45
store double %46, double* %18
%47 = load double, double* %13
%48 = load double (double, double)*, double (double, double)** %9
%49 = load double, double* %11
%50 = load double, double* %13
%51 = fdiv double %50, 2.000000e+00
%52 = fadd double %49, %51
%53 = load double, double* %12
%54 = load double, double* %17
%55 = call double @llvm.fmuladd.f64(double -1.216000e+00, double %54, double %53)
%56 = load double, double* %18
%57 = call double @llvm.fmuladd.f64(double 2.016000e+00, double %56, double %55)
%58 = load double, double* %13
%59 = fmul double 3.520000e-01, %58
%60 = load double (double, double)*, double (double, double)** %10
%61 = load double, double* %11
%62 = load double, double* %12
%63 = call double %60(double %61, double %62)
%64 = fmul double %59, %63
%65 = load double, double* %17
%66 = fneg double %64
%67 = call double @llvm.fmuladd.f64(double %66, double %65, double %57)
%68 = call double %48(double %52, double %67)
%69 = fmul double %47, %68
store double %69, double* %19
%70 = load double, double* %13
%71 = load double (double, double)*, double (double, double)** %9
%72 = load double, double* %11
%73 = load double, double* %13
%74 = fadd double %72, %73
%75 = load double, double* %12
%76 = load double, double* %17
%77 = call double @llvm.fmuladd.f64(double 9.500000e+00, double %76, double %75)
%78 = load double, double* %18
%79 = call double @llvm.fmuladd.f64(double 0xC024924924924925, double %78, double %77)
%80 = load double, double* %19
%81 = call double @llvm.fmuladd.f64(double 0x3FFC924924924925, double %80, double %79)
%82 = load double, double* %13
%83 = fmul double 2.500000e+00, %82
%84 = load double (double, double)*, double (double, double)** %10
%85 = load double, double* %11
%86 = load double, double* %12
%87 = call double %84(double %85, double %86)
%88 = fmul double %83, %87
%89 = load double, double* %17
%90 = call double @llvm.fmuladd.f64(double %88, double %89, double %81)
%91 = call double %71(double %74, double %90)
%92 = fmul double %70, %91
store double %92, double* %20
%93 = load double, double* %11
%94 = load double, double* %13
%95 = load i32, i32* %14
%96 = sitofp i32 %95 to double
%97 = call double @llvm.fmuladd.f64(double %94, double %96, double %93)
%98 = load double*, double** %15
store double %97, double* %98
%99 = load double, double* %12
%100 = load double, double* %17
%101 = call double @llvm.fmuladd.f64(double 0x3FBAAAAAAAAAAAAB, double %100, double %99)
%102 = load double, double* %18
%103 = call double @llvm.fmuladd.f64(double 0x3FDEDB6DB6DB6DB7, double %102, double %101)
%104 = load double, double* %19
%105 = call double @llvm.fmuladd.f64(double 0x3FD7CF3CF3CF3CF4, double %104, double %103)
%106 = load double, double* %20
%107 = call double @llvm.fmuladd.f64(double 0x3FA5555555555555, double %106, double %105)
%108 = load double*, double** %16
store double %107, double* %108
ret void
}

LLVM IR (-O2):
define void @rk4RefinedStep(double (double, double)* nocapture %0, double (double, double)* nocapture %1, double %2, double %3, double %4, i32 %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = tail call double %0(double %2, double %3)
%10 = fmul double %9, %4
%11 = fmul double %4, 5.000000e-01
%12 = fadd double %11, %2
%13 = tail call double @llvm.fmuladd.f64(double %10, double 0x3FD5555555555555, double %3)
%14 = fmul double %4, 0x3FAC71C71C71C71C
%15 = tail call double %1(double %2, double %3)
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %10, double %13)
%18 = tail call double %0(double %12, double %17)
%19 = fmul double %18, %4
%20 = tail call double @llvm.fmuladd.f64(double %10, double -1.216000e+00, double %3)
%21 = tail call double @llvm.fmuladd.f64(double %19, double 2.016000e+00, double %20)
%22 = tail call double %1(double %2, double %3)
%23 = fmul double %4, -3.520000e-01
%24 = fmul double %23, %22
%25 = tail call double @llvm.fmuladd.f64(double %24, double %10, double %21)
%26 = tail call double %0(double %12, double %25)
%27 = fmul double %26, %4
%28 = fadd double %2, %4
%29 = tail call double @llvm.fmuladd.f64(double %10, double 9.500000e+00, double %3)
%30 = tail call double @llvm.fmuladd.f64(double %19, double 0xC024924924924925, double %29)
%31 = tail call double @llvm.fmuladd.f64(double %27, double 0x3FFC924924924925, double %30)
%32 = fmul double %4, 2.500000e+00
%33 = tail call double %1(double %2, double %3)
%34 = fmul double %32, %33
%35 = tail call double @llvm.fmuladd.f64(double %34, double %10, double %31)
%36 = tail call double %0(double %28, double %35)
%37 = fmul double %36, %4
%38 = sitofp i32 %5 to double
%39 = tail call double @llvm.fmuladd.f64(double %4, double %38, double %2)
store double %39, double* %6
%40 = tail call double @llvm.fmuladd.f64(double %10, double 0x3FBAAAAAAAAAAAAB, double %3)
%41 = tail call double @llvm.fmuladd.f64(double %19, double 0x3FDEDB6DB6DB6DB7, double %40)
%42 = tail call double @llvm.fmuladd.f64(double %27, double 0x3FD7CF3CF3CF3CF4, double %41)
%43 = tail call double @llvm.fmuladd.f64(double %37, double 0x3FA5555555555555, double %42)
store double %43, double* %7
ret void
}