double modifiedeuler(double initialx, double finalx, double initialy,
                     double accuracy, double (*df)(double x, double y)) {
  double interval = finalx - initialx, finalynminus1, finalyn = 0, tempy,
         ei = exp(1);
  int i = 1, j;
  printf("MODIFIED EULER "
         "METHOD:\n\ni\t|dx|\t\ty(x)\t\t|ei|\t\t|log(ei)/log(e(i-1))|\n");
  do {
    finalynminus1 = finalyn;
    finalyn = initialy;
    tempy = initialy;
    interval /= 2;
    j = 1;
    do {
      tempy += interval * df(initialx + j * interval, tempy);
      finalyn += interval / 2 *
                 (df(initialx + j * interval, finalyn) +
                  df(initialx + (j + 1) * interval, tempy));
    } while (initialx + (++j) * interval <= finalx);
    printf("%02d\t%+09g\t%+09g\t%+09g\t%+09g\n", i++, interval, finalyn,
           abslt(finalyn - finalynminus1),
           abslt(log(abslt(finalyn - finalynminus1)) / log(ei)));
    ei = abslt(finalyn - finalynminus1);
  } while (abslt(finalyn - finalynminus1) > accuracy);
  return finalyn;
}


x86 assembly (clang, -O0):
<modifiedeuler>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe7e(%rip),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x28(%rbp),%rax
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdd9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%rax
movsd  -0x8(%rbp),%xmm1
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
cvtsi2sd %ecx,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
call   *%rax
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
cvtsi2sd %eax,%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11dc <modifiedeuler+0x9c>
mov    -0x54(%rbp),%eax
mov    %eax,-0x8c(%rbp)
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %eax,-0x74(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    -0x8c(%rbp),%esi
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x80(%rbp),%xmm1
mov    -0x74(%rbp),%edx
mov    %eax,%ecx
lea    0xce1(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
cvtsi2sd %eax,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     11a1 <modifiedeuler+0x61>
movsd  -0x40(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modifiedeuler>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
movsd  %xmm3,0x38(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x48(%rsp)
movsd  %xmm0,0x28(%rsp)
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r15d
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
lea    0xe74(%rip),%r14
nopl   0x0(%rax)
movsd  %xmm1,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x50(%rsp)
mov    $0x2,%ebp
movsd  0x30(%rsp),%xmm0
movaps %xmm0,%xmm1
movsd  %xmm0,(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x18(%rsp)
lea    -0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm1
call   *%rbx
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   *%rbx
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  (%rsp),%xmm1
call   *%rbx
movapd %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
mulsd  0x50(%rsp),%xmm1
addsd  0x18(%rsp),%xmm1
add    $0x1,%ebp
movsd  0x48(%rsp),%xmm0
ucomisd 0x58(%rsp),%xmm0
jae    11e0 <modifiedeuler+0xa0>
lea    0x1(%r15),%r12d
movapd %xmm1,%xmm0
subsd  0x40(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%al
movsd  %xmm1,0x18(%rsp)
call   1030 <abslt@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <log@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
mov    %r14,%rdi
mov    %r15d,%esi
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    %ebp,%edx
mov    %eax,%ecx
mov    $0x2,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <abslt@plt>
movsd  0x18(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd 0x38(%rsp),%xmm1
movapd %xmm0,%xmm1
mov    %r12d,%r15d
ja     11a0 <modifiedeuler+0x60>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"MODIFIED EULER METHOD:\0A\0Ai\09|dx|\09\09y(x)\09\09|ei|\09\09|log(ei)/log(e(i-1))|\0A\00"
@.str.1 = [30 x i8] c"%02d\09%+09g\09%+09g\09%+09g\09%+09g\0A\00"
define double @modifiedeuler(double %0, double %1, double %2, double %3, double (double, double)* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double (double, double)*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double (double, double)* %4, double (double, double)** %10
%18 = load double, double* %7
%19 = load double, double* %6
%20 = fsub double %18, %19
store double %20, double* %11
store double 0.000000e+00, double* %13
%21 = call double @exp(double 1.000000e+00)
store double %21, double* %15
store i32 1, i32* %16
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %97, %5
%24 = load double, double* %13
store double %24, double* %12
%25 = load double, double* %8
store double %25, double* %13
%26 = load double, double* %8
store double %26, double* %14
%27 = load double, double* %11
%28 = fdiv double %27, 2.000000e+00
store double %28, double* %11
store i32 1, i32* %17
br label %29
29: ; preds = %63, %23
%30 = load double, double* %11
%31 = load double (double, double)*, double (double, double)** %10
%32 = load double, double* %6
%33 = load i32, i32* %17
%34 = sitofp i32 %33 to double
%35 = load double, double* %11
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %32)
%37 = load double, double* %14
%38 = call double %31(double %36, double %37)
%39 = load double, double* %14
%40 = call double @llvm.fmuladd.f64(double %30, double %38, double %39)
store double %40, double* %14
%41 = load double, double* %11
%42 = fdiv double %41, 2.000000e+00
%43 = load double (double, double)*, double (double, double)** %10
%44 = load double, double* %6
%45 = load i32, i32* %17
%46 = sitofp i32 %45 to double
%47 = load double, double* %11
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %44)
%49 = load double, double* %13
%50 = call double %43(double %48, double %49)
%51 = load double (double, double)*, double (double, double)** %10
%52 = load double, double* %6
%53 = load i32, i32* %17
%54 = add nsw i32 %53, 1
%55 = sitofp i32 %54 to double
%56 = load double, double* %11
%57 = call double @llvm.fmuladd.f64(double %55, double %56, double %52)
%58 = load double, double* %14
%59 = call double %51(double %57, double %58)
%60 = fadd double %50, %59
%61 = load double, double* %13
%62 = call double @llvm.fmuladd.f64(double %42, double %60, double %61)
store double %62, double* %13
br label %63
63: ; preds = %29
%64 = load double, double* %6
%65 = load i32, i32* %17
%66 = add nsw i32 %65, 1
store i32 %66, i32* %17
%67 = sitofp i32 %66 to double
%68 = load double, double* %11
%69 = call double @llvm.fmuladd.f64(double %67, double %68, double %64)
%70 = load double, double* %7
%71 = fcmp ole double %69, %70
br i1 %71, label %29, label %72
72: ; preds = %63
%73 = load i32, i32* %16
%74 = add nsw i32 %73, 1
store i32 %74, i32* %16
%75 = load double, double* %11
%76 = load double, double* %13
%77 = load double, double* %13
%78 = load double, double* %12
%79 = fsub double %77, %78
%80 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %79)
%81 = load double, double* %13
%82 = load double, double* %12
%83 = fsub double %81, %82
%84 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %83)
%85 = sitofp i32 %84 to double
%86 = call double @log(double %85)
%87 = load double, double* %15
%88 = call double @log(double %87)
%89 = fdiv double %86, %88
%90 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %89)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %73, double %75, double %76, i32 %80, i32 %90)
%92 = load double, double* %13
%93 = load double, double* %12
%94 = fsub double %92, %93
%95 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %94)
%96 = sitofp i32 %95 to double
store double %96, double* %15
br label %97
97: ; preds = %72
%98 = load double, double* %13
%99 = load double, double* %12
%100 = fsub double %98, %99
%101 = call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %100)
%102 = sitofp i32 %101 to double
%103 = load double, double* %9
%104 = fcmp ogt double %102, %103
br i1 %104, label %23, label %105
105: ; preds = %97
%106 = load double, double* %13
ret double %106
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"%02d\09%+09g\09%+09g\09%+09g\09%+09g\0A\00"
@str = [66 x i8] c"MODIFIED EULER METHOD:\0A\0Ai\09|dx|\09\09y(x)\09\09|ei|\09\09|log(ei)/log(e(i-1))|\00"
define double @modifiedeuler(double %0, double %1, double %2, double %3, double (double, double)* nocapture %4) {
%6 = fsub double %1, %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %31, %5
%9 = phi double [ %6, %5 ], [ %13, %31 ]
%10 = phi double [ 0.000000e+00, %5 ], [ %29, %31 ]
%11 = phi double [ 0x4005BF0A8B145769, %5 ], [ %43, %31 ]
%12 = phi i32 [ 1, %5 ], [ %32, %31 ]
%13 = fmul double %9, 5.000000e-01
%14 = fmul double %13, 5.000000e-01
br label %15
15: ; preds = %15, %8
%16 = phi double [ %2, %8 ], [ %29, %15 ]
%17 = phi double [ %2, %8 ], [ %22, %15 ]
%18 = phi i32 [ 1, %8 ], [ %24, %15 ]
%19 = sitofp i32 %18 to double
%20 = tail call double @llvm.fmuladd.f64(double %19, double %13, double %0)
%21 = tail call double %4(double %20, double %17)
%22 = tail call double @llvm.fmuladd.f64(double %13, double %21, double %17)
%23 = tail call double %4(double %20, double %16)
%24 = add nuw nsw i32 %18, 1
%25 = sitofp i32 %24 to double
%26 = tail call double @llvm.fmuladd.f64(double %25, double %13, double %0)
%27 = tail call double %4(double %26, double %22)
%28 = fadd double %23, %27
%29 = tail call double @llvm.fmuladd.f64(double %14, double %28, double %16)
%30 = fcmp ugt double %26, %1
br i1 %30, label %31, label %15
31: ; preds = %15
%32 = add nuw nsw i32 %12, 1
%33 = fsub double %29, %10
%34 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %33)
%35 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %33)
%36 = sitofp i32 %35 to double
%37 = tail call double @log(double %36)
%38 = tail call double @log(double %11)
%39 = fdiv double %37, %38
%40 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %39)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %12, double %13, double %29, i32 %34, i32 %40)
%42 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %33)
%43 = sitofp i32 %42 to double
%44 = tail call i32 (double, ...) bitcast (i32 (...)* @abslt to i32 (double, ...)*)(double %33)
%45 = sitofp i32 %44 to double
%46 = fcmp ogt double %45, %3
br i1 %46, label %8, label %47
47: ; preds = %31
ret double %29
}