#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long double f(long double, long double);
long double runge_kutta_4(long double x, long double y, double h) {
  long double k1, k2, k3, k4;
  k1 = f(x, y);
  k2 = f(x + 0.5 * h, y + 0.5 * h * k1);
  k3 = f(x + 0.5 * h, y + 0.5 * h * k2);
  k4 = f(x + h, y + h * k3);
  y = y + h * (k1 + 2.0 * k2 + 2.0 * k3 + k4) / 6.0;
  return y;
}


x86 assembly (clang, -O0):
<runge_kutta_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fstpt  -0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
fldt   -0x10(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <f@plt>
fstpt  -0x40(%rbp)
fldt   -0x10(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeae(%rip),%xmm1
movsd  %xmm1,-0x88(%rbp)
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
fldl   -0x78(%rbp)
fadd   %st,%st(1)
fldt   -0x20(%rbp)
fldt   -0x40(%rbp)
fmulp  %st,%st(2)
faddp  %st,%st(1)
mov    %rsp,%rax
fxch   %st(1)
fstpt  (%rax)
fstpt  0x10(%rax)
call   1030 <f@plt>
movsd  -0x88(%rbp),%xmm1
ff
fstpt  -0x50(%rbp)
fldt   -0x10(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
fldl   -0x80(%rbp)
fadd   %st,%st(1)
fldt   -0x20(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(2)
faddp  %st,%st(1)
mov    %rsp,%rax
fxch   %st(1)
fstpt  (%rax)
fstpt  0x10(%rax)
call   1030 <f@plt>
fstpt  -0x60(%rbp)
fldt   -0x10(%rbp)
fldl   -0x28(%rbp)
fadd   %st,%st(1)
fldt   -0x20(%rbp)
fldt   -0x60(%rbp)
fmulp  %st,%st(2)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <f@plt>
fstpt  -0x70(%rbp)
fldt   -0x20(%rbp)
fldl   -0x28(%rbp)
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fadd   %st,%st(0)
faddp  %st,%st(1)
fldt   -0x60(%rbp)
fadd   %st,%st(0)
faddp  %st,%st(1)
fldt   -0x70(%rbp)
faddp  %st,%st(1)
fmulp  %st,%st(1)
flds   0xe04(%rip)
fdivrp %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runge_kutta_4>:
sub    $0x88,%rsp
movsd  %xmm0,0x20(%rsp)
fldt   0x90(%rsp)
fld    %st(0)
fstpt  0x44(%rsp)
fldt   0xa0(%rsp)
fld    %st(0)
fstpt  0x2c(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <f@plt>
fld    %st(0)
fstpt  0x7c(%rsp)
movsd  0xeaf(%rip),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
fldl   0x50(%rsp)
fld    %st(0)
fstpt  0x64(%rsp)
fldt   0x44(%rsp)
fadd   %st(1),%st
fld    %st(0)
fstpt  0x38(%rsp)
fxch   %st(1)
fmulp  %st,%st(2)
fldt   0x2c(%rsp)
faddp  %st,%st(2)
fxch   %st(1)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <f@plt>
fld    %st(0)
fstpt  0x70(%rsp)
fldt   0x64(%rsp)
fmulp  %st,%st(1)
fldt   0x2c(%rsp)
faddp  %st,%st(1)
fstpt  0x10(%rsp)
fldt   0x38(%rsp)
fstpt  (%rsp)
call   1030 <f@plt>
fld    %st(0)
fxch   %st(1)
fstpt  0x38(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
fldl   0x58(%rsp)
fld    %st(0)
fstpt  0x20(%rsp)
fldt   0x44(%rsp)
fadd   %st(1),%st
fxch   %st(1)
fmulp  %st,%st(2)
fldt   0x2c(%rsp)
faddp  %st,%st(2)
fxch   %st(1)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <f@plt>
fldt   0x70(%rsp)
fadd   %st,%st(0)
fldt   0x7c(%rsp)
faddp  %st,%st(1)
fldt   0x38(%rsp)
fadd   %st,%st(0)
faddp  %st,%st(1)
faddp  %st,%st(1)
fldt   0x20(%rsp)
fmulp  %st,%st(1)
fdivs  0xdfd(%rip)
fldt   0x2c(%rsp)
faddp  %st,%st(1)
add    $0x88,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @runge_kutta_4(x86_fp80 %0, x86_fp80 %1, double %2) {
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca double
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
store double %2, double* %6
%11 = load x86_fp80, x86_fp80* %4
%12 = load x86_fp80, x86_fp80* %5
%13 = call x86_fp80 @f(x86_fp80 %11, x86_fp80 %12)
store x86_fp80 %13, x86_fp80* %7
%14 = load x86_fp80, x86_fp80* %4
%15 = load double, double* %6
%16 = fmul double 5.000000e-01, %15
%17 = fpext double %16 to x86_fp80
%18 = fadd x86_fp80 %14, %17
%19 = load x86_fp80, x86_fp80* %5
%20 = load double, double* %6
%21 = fmul double 5.000000e-01, %20
%22 = fpext double %21 to x86_fp80
%23 = load x86_fp80, x86_fp80* %7
%24 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %22, x86_fp80 %23, x86_fp80 %19)
%25 = call x86_fp80 @f(x86_fp80 %18, x86_fp80 %24)
store x86_fp80 %25, x86_fp80* %8
%26 = load x86_fp80, x86_fp80* %4
%27 = load double, double* %6
%28 = fmul double 5.000000e-01, %27
%29 = fpext double %28 to x86_fp80
%30 = fadd x86_fp80 %26, %29
%31 = load x86_fp80, x86_fp80* %5
%32 = load double, double* %6
%33 = fmul double 5.000000e-01, %32
%34 = fpext double %33 to x86_fp80
%35 = load x86_fp80, x86_fp80* %8
%36 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %34, x86_fp80 %35, x86_fp80 %31)
%37 = call x86_fp80 @f(x86_fp80 %30, x86_fp80 %36)
store x86_fp80 %37, x86_fp80* %9
%38 = load x86_fp80, x86_fp80* %4
%39 = load double, double* %6
%40 = fpext double %39 to x86_fp80
%41 = fadd x86_fp80 %38, %40
%42 = load x86_fp80, x86_fp80* %5
%43 = load double, double* %6
%44 = fpext double %43 to x86_fp80
%45 = load x86_fp80, x86_fp80* %9
%46 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %44, x86_fp80 %45, x86_fp80 %42)
%47 = call x86_fp80 @f(x86_fp80 %41, x86_fp80 %46)
store x86_fp80 %47, x86_fp80* %10
%48 = load x86_fp80, x86_fp80* %5
%49 = load double, double* %6
%50 = fpext double %49 to x86_fp80
%51 = load x86_fp80, x86_fp80* %7
%52 = load x86_fp80, x86_fp80* %8
%53 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40008000000000000000, x86_fp80 %52, x86_fp80 %51)
%54 = load x86_fp80, x86_fp80* %9
%55 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40008000000000000000, x86_fp80 %54, x86_fp80 %53)
%56 = load x86_fp80, x86_fp80* %10
%57 = fadd x86_fp80 %55, %56
%58 = fmul x86_fp80 %50, %57
%59 = fdiv x86_fp80 %58, 0xK4001C000000000000000
%60 = fadd x86_fp80 %48, %59
store x86_fp80 %60, x86_fp80* %5
%61 = load x86_fp80, x86_fp80* %5
ret x86_fp80 %61
}

LLVM IR (-O2):
define x86_fp80 @runge_kutta_4(x86_fp80 %0, x86_fp80 %1, double %2) {
%4 = tail call x86_fp80 @f(x86_fp80 %0, x86_fp80 %1)
%5 = fmul double %2, 5.000000e-01
%6 = fpext double %5 to x86_fp80
%7 = fadd x86_fp80 %6, %0
%8 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %6, x86_fp80 %4, x86_fp80 %1)
%9 = tail call x86_fp80 @f(x86_fp80 %7, x86_fp80 %8)
%10 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %6, x86_fp80 %9, x86_fp80 %1)
%11 = tail call x86_fp80 @f(x86_fp80 %7, x86_fp80 %10)
%12 = fpext double %2 to x86_fp80
%13 = fadd x86_fp80 %12, %0
%14 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %11, x86_fp80 %1)
%15 = tail call x86_fp80 @f(x86_fp80 %13, x86_fp80 %14)
%16 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %9, x86_fp80 0xK40008000000000000000, x86_fp80 %4)
%17 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %11, x86_fp80 0xK40008000000000000000, x86_fp80 %16)
%18 = fadd x86_fp80 %17, %15
%19 = fmul x86_fp80 %18, %12
%20 = fdiv x86_fp80 %19, 0xK4001C000000000000000
%21 = fadd x86_fp80 %20, %1
ret x86_fp80 %21
}