double matsuno(double (*f)(double, double), int timeSteps, double h) {
  double y = 1.0, x, yprime;
  int i;
  for (i = 0; i < timeSteps; i++) {
    x = h * i;
    yprime = y + h * f(x, y);
    y = y + f(x, yprime) * h;
  }
  return y;
}


x86 assembly (clang, -O0):
<matsuno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  0xee4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <matsuno+0xc4>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   *%rax
movsd  -0x40(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1128 <matsuno+0x28>
movsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matsuno>:
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
jle    118b <matsuno+0x8b>
movapd %xmm0,%xmm2
mov    %esi,%ebx
mov    %rdi,%r14
movsd  0xee0(%rip),%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm2,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
call   *%r14
movapd %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
call   *%r14
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
addsd  0xe7c(%rip),%xmm0
add    $0xffffffff,%ebx
jne    1130 <matsuno+0x30>
jmp    1193 <matsuno+0x93>
movsd  0xe6d(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @matsuno(double (double, double)* %0, i32 %1, double %2) {
%4 = alloca double (double, double)*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double (double, double)* %0, double (double, double)** %4
store i32 %1, i32* %5
store double %2, double* %6
store double 1.000000e+00, double* %7
store i32 0, i32* %10
br label %11
11: ; preds = %34, %3
%12 = load i32, i32* %10
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = load double, double* %6
%17 = load i32, i32* %10
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
store double %19, double* %8
%20 = load double, double* %7
%21 = load double, double* %6
%22 = load double (double, double)*, double (double, double)** %4
%23 = load double, double* %8
%24 = load double, double* %7
%25 = call double %22(double %23, double %24)
%26 = call double @llvm.fmuladd.f64(double %21, double %25, double %20)
store double %26, double* %9
%27 = load double, double* %7
%28 = load double (double, double)*, double (double, double)** %4
%29 = load double, double* %8
%30 = load double, double* %9
%31 = call double %28(double %29, double %30)
%32 = load double, double* %6
%33 = call double @llvm.fmuladd.f64(double %31, double %32, double %27)
store double %33, double* %7
br label %34
34: ; preds = %15
%35 = load i32, i32* %10
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
br label %11
37: ; preds = %11
%38 = load double, double* %7
ret double %38
}

LLVM IR (-O2):
define double @matsuno(double (double, double)* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %16
5: ; preds = %3, %5
%6 = phi i32 [ %14, %5 ], [ 0, %3 ]
%7 = phi double [ %13, %5 ], [ 1.000000e+00, %3 ]
%8 = sitofp i32 %6 to double
%9 = fmul double %8, %2
%10 = tail call double %0(double %9, double %7)
%11 = tail call double @llvm.fmuladd.f64(double %2, double %10, double %7)
%12 = tail call double %0(double %9, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %12, double %2, double %7)
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, %1
br i1 %15, label %16, label %5
16: ; preds = %5, %3
%17 = phi double [ 1.000000e+00, %3 ], [ %13, %5 ]
ret double %17
}