#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 */
double f(double, double);
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
double sol(double);
int main() {
  double y0 = 1, x0 = 0;
  double h = 0.1;
  double y1 = y0 + (h * f(x0, y0));
  double x1 = x0 + h;
  printf("x\t\ty(computed)\ty(actual)\tabs_error");
  do {
    double yact = sol(x1);
    double error = fabs(yact - y1);
    x0 = x1;
    y0 = y1;
    printf("\n%lf\t%lf\t%lf\t%lf", x1, y1, yact, error);
    y1 = y0 + h * (f(x0, y0) + f(x1, y1)) / 2;
  } while ((sol(x1) - y1));
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <f@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
call   1050 <sol@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xe45(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
lea    0xe40(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <f@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <f@plt>
movsd  -0x68(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd9d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sol@plt>
subsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bb <main+0x8b>
jp     11bb <main+0x8b>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movsd  0xeb3(%rip),%xmm1
xorpd  %xmm0,%xmm0
call   1040 <f@plt>
mulsd  0xeaa(%rip),%xmm0
addsd  0xe9a(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed3(%rip),%rbx
movsd  0xe80(%rip),%xmm0
call   1060 <sol@plt>
movapd %xmm0,%xmm2
movapd %xmm0,%xmm3
movsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
subsd  %xmm1,%xmm3
andpd  0xe75(%rip),%xmm3
mov    %rbx,%rdi
movsd  0xe52(%rip),%xmm0
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0xe43(%rip),%xmm0
movsd  (%rsp),%xmm1
call   1040 <f@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe2b(%rip),%xmm0
movsd  (%rsp),%xmm1
call   1040 <f@plt>
addsd  0x8(%rsp),%xmm0
movsd  0xe13(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  0xe0f(%rip),%xmm0
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm1,%xmm0
call   1060 <sol@plt>
subsd  (%rsp),%xmm0
ucomisd 0xdf3(%rip),%xmm0
jne    1180 <main+0x40>
jp     1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"x\09\09y(computed)\09y(actual)\09abs_error\00"
@.str.1 = [17 x i8] c"\0A%lf\09%lf\09%lf\09%lf\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 1.000000e-01, double* %4
%9 = load double, double* %2
%10 = load double, double* %4
%11 = load double, double* %3
%12 = load double, double* %2
%13 = call double @f(double %11, double %12)
%14 = call double @llvm.fmuladd.f64(double %10, double %13, double %9)
store double %14, double* %5
%15 = load double, double* %3
%16 = load double, double* %4
%17 = fadd double %15, %16
store double %17, double* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %45, %0
%20 = load double, double* %6
%21 = call double @sol(double %20)
store double %21, double* %7
%22 = load double, double* %7
%23 = load double, double* %5
%24 = fsub double %22, %23
%25 = call double @llvm.fabs.f64(double %24)
store double %25, double* %8
%26 = load double, double* %6
store double %26, double* %3
%27 = load double, double* %5
store double %27, double* %2
%28 = load double, double* %6
%29 = load double, double* %5
%30 = load double, double* %7
%31 = load double, double* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %28, double %29, double %30, double %31)
%33 = load double, double* %2
%34 = load double, double* %4
%35 = load double, double* %3
%36 = load double, double* %2
%37 = call double @f(double %35, double %36)
%38 = load double, double* %6
%39 = load double, double* %5
%40 = call double @f(double %38, double %39)
%41 = fadd double %37, %40
%42 = fmul double %34, %41
%43 = fdiv double %42, 2.000000e+00
%44 = fadd double %33, %43
store double %44, double* %5
br label %45
45: ; preds = %19
%46 = load double, double* %6
%47 = call double @sol(double %46)
%48 = load double, double* %5
%49 = fsub double %47, %48
%50 = fcmp une double %49, 0.000000e+00
br i1 %50, label %19, label %51
51: ; preds = %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"x\09\09y(computed)\09y(actual)\09abs_error\00"
@.str.1 = [17 x i8] c"\0A%lf\09%lf\09%lf\09%lf\00"
define i32 @main() {
%1 = tail call double @f(double 0.000000e+00, double 1.000000e+00)
%2 = tail call double @llvm.fmuladd.f64(double %1, double 1.000000e-01, double 1.000000e+00)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = phi double [ %2, %0 ], [ %15, %4 ]
%6 = tail call double @sol(double 1.000000e-01)
%7 = fsub double %6, %5
%8 = tail call double @llvm.fabs.f64(double %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double 1.000000e-01, double %5, double %6, double %8)
%10 = tail call double @f(double 1.000000e-01, double %5)
%11 = tail call double @f(double 1.000000e-01, double %5)
%12 = fadd double %10, %11
%13 = fmul double %12, 1.000000e-01
%14 = fmul double %13, 5.000000e-01
%15 = fadd double %5, %14
%16 = tail call double @sol(double 1.000000e-01)
%17 = fsub double %16, %15
%18 = fcmp une double %17, 0.000000e+00
br i1 %18, label %4, label %19
19: ; preds = %4
%20 = tail call i32 @putchar(i32 10)
ret i32 0
}