void rk4Step(double (*f)(double, double), double t0, double y0, double h, int i,
             double *t, double *y) {
  double k1, k2, k3, k4;
  k1 = y0 + h * (*f)(t0, y0);
  k2 = y0 + h * (*f)(t0 + h * .5, y0 + k1 * .5);
  k3 = y0 + h * (*f)(t0 + h * .5, y0 + k2 * .5);
  k4 = y0 + h * (*f)(t0 + h, y0 + k3 * h);
  *t = t0 + h * i;
  *y = y0 + (k1 + 2. * k2 + 2. * k3 + k4) * 1.0 / 6.0;
}


x86 assembly (clang, -O0):
<rk4Step>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   *%rax
movsd  -0x98(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe70(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xe56(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe05(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
movsd  0xdeb(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   *%rax
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x50(%rbp),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
addsd  -0x58(%rbp),%xmm1
movsd  0xd1a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd06(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rk4Step>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %rdi,%rbx
call   *%rdi
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0xeb5(%rip),%xmm4
mulsd  %xmm4,%xmm3
addsd  0x20(%rsp),%xmm3
movsd  %xmm3,0x18(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm4,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm3,%xmm0
call   *%rbx
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0xe75(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  0x18(%rsp),%xmm0
call   *%rbx
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
call   *%rbx
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  %xmm2,%xmm1
addsd  0x20(%rsp),%xmm1
movsd  %xmm1,(%r15)
movsd  0x28(%rsp),%xmm1
addsd  %xmm1,%xmm1
addsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
divsd  0xde7(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rk4Step(double (double, double)* %0, double %1, double %2, double %3, i32 %4, double* %5, double* %6) {
%8 = alloca double (double, double)*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double (double, double)* %0, double (double, double)** %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store i32 %4, i32* %12
store double* %5, double** %13
store double* %6, double** %14
%19 = load double, double* %10
%20 = load double, double* %11
%21 = load double (double, double)*, double (double, double)** %8
%22 = load double, double* %9
%23 = load double, double* %10
%24 = call double %21(double %22, double %23)
%25 = call double @llvm.fmuladd.f64(double %20, double %24, double %19)
store double %25, double* %15
%26 = load double, double* %10
%27 = load double, double* %11
%28 = load double (double, double)*, double (double, double)** %8
%29 = load double, double* %9
%30 = load double, double* %11
%31 = call double @llvm.fmuladd.f64(double %30, double 5.000000e-01, double %29)
%32 = load double, double* %10
%33 = load double, double* %15
%34 = call double @llvm.fmuladd.f64(double %33, double 5.000000e-01, double %32)
%35 = call double %28(double %31, double %34)
%36 = call double @llvm.fmuladd.f64(double %27, double %35, double %26)
store double %36, double* %16
%37 = load double, double* %10
%38 = load double, double* %11
%39 = load double (double, double)*, double (double, double)** %8
%40 = load double, double* %9
%41 = load double, double* %11
%42 = call double @llvm.fmuladd.f64(double %41, double 5.000000e-01, double %40)
%43 = load double, double* %10
%44 = load double, double* %16
%45 = call double @llvm.fmuladd.f64(double %44, double 5.000000e-01, double %43)
%46 = call double %39(double %42, double %45)
%47 = call double @llvm.fmuladd.f64(double %38, double %46, double %37)
store double %47, double* %17
%48 = load double, double* %10
%49 = load double, double* %11
%50 = load double (double, double)*, double (double, double)** %8
%51 = load double, double* %9
%52 = load double, double* %11
%53 = fadd double %51, %52
%54 = load double, double* %10
%55 = load double, double* %17
%56 = load double, double* %11
%57 = call double @llvm.fmuladd.f64(double %55, double %56, double %54)
%58 = call double %50(double %53, double %57)
%59 = call double @llvm.fmuladd.f64(double %49, double %58, double %48)
store double %59, double* %18
%60 = load double, double* %9
%61 = load double, double* %11
%62 = load i32, i32* %12
%63 = sitofp i32 %62 to double
%64 = call double @llvm.fmuladd.f64(double %61, double %63, double %60)
%65 = load double*, double** %13
store double %64, double* %65
%66 = load double, double* %10
%67 = load double, double* %15
%68 = load double, double* %16
%69 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %68, double %67)
%70 = load double, double* %17
%71 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %70, double %69)
%72 = load double, double* %18
%73 = fadd double %71, %72
%74 = fmul double %73, 1.000000e+00
%75 = fdiv double %74, 6.000000e+00
%76 = fadd double %66, %75
%77 = load double*, double** %14
store double %76, double* %77
ret void
}

LLVM IR (-O2):
define void @rk4Step(double (double, double)* nocapture %0, double %1, double %2, double %3, i32 %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = tail call double %0(double %1, double %2)
%9 = tail call double @llvm.fmuladd.f64(double %3, double %8, double %2)
%10 = tail call double @llvm.fmuladd.f64(double %3, double 5.000000e-01, double %1)
%11 = tail call double @llvm.fmuladd.f64(double %9, double 5.000000e-01, double %2)
%12 = tail call double %0(double %10, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %3, double %12, double %2)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 5.000000e-01, double %2)
%15 = tail call double %0(double %10, double %14)
%16 = tail call double @llvm.fmuladd.f64(double %3, double %15, double %2)
%17 = fadd double %1, %3
%18 = tail call double @llvm.fmuladd.f64(double %16, double %3, double %2)
%19 = tail call double %0(double %17, double %18)
%20 = tail call double @llvm.fmuladd.f64(double %3, double %19, double %2)
%21 = sitofp i32 %4 to double
%22 = tail call double @llvm.fmuladd.f64(double %3, double %21, double %1)
store double %22, double* %5
%23 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double %9)
%24 = tail call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double %23)
%25 = fadd double %24, %20
%26 = fdiv double %25, 6.000000e+00
%27 = fadd double %26, %2
store double %27, double* %6
ret void
}