#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 */
float dy(float, float);
double fabs(float);
float fx(float);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  float x0, x1, y0, y10, y11;
  float h = 0.1;
  x1 = 0;
  y11 = 1;
  printf("\n    X\t|\tY-computed\t|\tY-Actual\t|\tAbs. Error\t|\n");
  printf("---------------------------------------------------------------------"
         "------------\n");
  printf("%f|\t%f\t|\t%f\t|\t%f\t|\n", x1, y11, fx(x1), fabs(y11 - fx(x1)));
  while (x1 <= 1) {
    x0 = x1;
    x1 += h;
    y0 = y11;
    y11 = y0 + h * dy(x0, y0);
    do {
      y10 = y11;
      y11 = y0 + h / 2 * (dy(x0, y0) + dy(x1, y10));
    } while (fabs(y10 - y11) >= 0.00005);
    printf("%f|\t%f\t|\t%f\t|\t%f\t|\n", x1, y11, fx(x1), fabs(y11 - fx(x1)));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xead(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe94(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fx@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fx@plt>
movaps %xmm0,%xmm1
movss  -0x3c(%rbp),%xmm0
subss  %xmm1,%xmm0
call   1060 <fabs@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
lea    0xea0(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movss  0xdf7(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     137d <main+0x23d>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1050 <dy@plt>
movss  -0x44(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x40(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xd74(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1050 <dy@plt>
movss  %xmm0,-0x50(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1050 <dy@plt>
movss  -0x50(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
movaps %xmm0,%xmm3
movss  -0x48(%rbp),%xmm0
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
call   1060 <fabs@plt>
movsd  0xd16(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1273 <main+0x133>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fx@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fx@plt>
movaps %xmm0,%xmm1
movss  -0x6c(%rbp),%xmm0
subss  %xmm1,%xmm0
call   1060 <fabs@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
lea    0xd29(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
jmp    1201 <main+0xc1>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
call   1040 <fx@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
call   1040 <fx@plt>
movss  0xe68(%rip),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1070 <fabs@plt>
movaps %xmm0,%xmm3
lea    0xe72(%rip),%rbx
movsd  0xe5a(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movsd  0x10(%rsp),%xmm2
mov    $0x4,%al
call   1050 <printf@plt>
movss  0xe2f(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
nop
movss  0xe1c(%rip),%xmm1
movss  (%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
movss  0x18(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1060 <dy@plt>
movaps %xmm0,%xmm1
mulss  0xdf2(%rip),%xmm1
addss  0x8(%rsp),%xmm1
nopl   0x0(%rax,%rax,1)
movss  %xmm1,0x10(%rsp)
movss  0x18(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1060 <dy@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
movss  0x10(%rsp),%xmm1
call   1060 <dy@plt>
movaps %xmm0,%xmm1
addss  0x4(%rsp),%xmm1
mulss  0xdaa(%rip),%xmm1
addss  0x8(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x10(%rsp),%xmm0
subss  %xmm1,%xmm0
call   1070 <fabs@plt>
movss  0x4(%rsp),%xmm1
ucomisd 0xd91(%rip),%xmm0
jae    1220 <main+0xd0>
movss  (%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
call   1040 <fx@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
movss  (%rsp),%xmm0
call   1040 <fx@plt>
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1070 <fabs@plt>
movaps %xmm0,%xmm3
mov    %rbx,%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mov    $0x4,%al
call   1050 <printf@plt>
movss  0xd06(%rip),%xmm0
movss  (%rsp),%xmm1
ucomiss %xmm1,%xmm0
movss  %xmm1,0x18(%rsp)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
jae    11e0 <main+0x90>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0A X\09|\09Y-computed\09|\09Y-Actual\09|\09Abs. Error\09|\0A\00"
@.str.1 = [83 x i8] c"---------------------------------------------------------------------------------\0A\00"
@.str.2 = [20 x i8] c"%f|\09%f\09|\09%f\09|\09%f\09|\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
store float 0x3FB99999A0000000, float* %7
store float 0.000000e+00, float* %3
store float 1.000000e+00, float* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
%10 = load float, float* %3
%11 = fpext float %10 to double
%12 = load float, float* %6
%13 = fpext float %12 to double
%14 = load float, float* %3
%15 = call float @fx(float %14)
%16 = fpext float %15 to double
%17 = load float, float* %6
%18 = load float, float* %3
%19 = call float @fx(float %18)
%20 = fsub float %17, %19
%21 = call double @fabs(float %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %11, double %13, double %16, double %21)
br label %23
23: ; preds = %57, %0
%24 = load float, float* %3
%25 = fcmp ole float %24, 1.000000e+00
br i1 %25, label %26, label %71
26: ; preds = %23
%27 = load float, float* %3
store float %27, float* %2
%28 = load float, float* %7
%29 = load float, float* %3
%30 = fadd float %29, %28
store float %30, float* %3
%31 = load float, float* %6
store float %31, float* %4
%32 = load float, float* %4
%33 = load float, float* %7
%34 = load float, float* %2
%35 = load float, float* %4
%36 = call float @dy(float %34, float %35)
%37 = call float @llvm.fmuladd.f32(float %33, float %36, float %32)
store float %37, float* %6
br label %38
38: ; preds = %51, %26
%39 = load float, float* %6
store float %39, float* %5
%40 = load float, float* %4
%41 = load float, float* %7
%42 = fdiv float %41, 2.000000e+00
%43 = load float, float* %2
%44 = load float, float* %4
%45 = call float @dy(float %43, float %44)
%46 = load float, float* %3
%47 = load float, float* %5
%48 = call float @dy(float %46, float %47)
%49 = fadd float %45, %48
%50 = call float @llvm.fmuladd.f32(float %42, float %49, float %40)
store float %50, float* %6
br label %51
51: ; preds = %38
%52 = load float, float* %5
%53 = load float, float* %6
%54 = fsub float %52, %53
%55 = call double @fabs(float %54)
%56 = fcmp oge double %55, 5.000000e-05
br i1 %56, label %38, label %57
57: ; preds = %51
%58 = load float, float* %3
%59 = fpext float %58 to double
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = load float, float* %3
%63 = call float @fx(float %62)
%64 = fpext float %63 to double
%65 = load float, float* %6
%66 = load float, float* %3
%67 = call float @fx(float %66)
%68 = fsub float %65, %67
%69 = call double @fabs(float %68)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %59, double %61, double %64, double %69)
br label %23
71: ; preds = %23
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"%f|\09%f\09|\09%f\09|\09%f\09|\0A\00"
@str = [46 x i8] c"\0A X\09|\09Y-computed\09|\09Y-Actual\09|\09Abs. Error\09|\00"
@str.3 = [82 x i8] c"---------------------------------------------------------------------------------\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.3, i64 0, i64 0))
%3 = tail call float @fx(float 0.000000e+00)
%4 = fpext float %3 to double
%5 = tail call float @fx(float 0.000000e+00)
%6 = fsub float 1.000000e+00, %5
%7 = tail call double @fabs(float %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double 0.000000e+00, double 1.000000e+00, double %4, double %7)
br label %9
9: ; preds = %0, %24
%10 = phi float [ 0.000000e+00, %0 ], [ %12, %24 ]
%11 = phi float [ 1.000000e+00, %0 ], [ %20, %24 ]
%12 = fadd float %10, 0x3FB99999A0000000
%13 = tail call float @dy(float %10, float %11)
%14 = tail call float @llvm.fmuladd.f32(float %13, float 0x3FB99999A0000000, float %11)
br label %15
15: ; preds = %15, %9
%16 = phi float [ %14, %9 ], [ %20, %15 ]
%17 = tail call float @dy(float %10, float %11)
%18 = tail call float @dy(float %12, float %16)
%19 = fadd float %17, %18
%20 = tail call float @llvm.fmuladd.f32(float %19, float 0x3FA99999A0000000, float %11)
%21 = fsub float %16, %20
%22 = tail call double @fabs(float %21)
%23 = fcmp ult double %22, 5.000000e-05
br i1 %23, label %24, label %15
24: ; preds = %15
%25 = fpext float %12 to double
%26 = fpext float %20 to double
%27 = tail call float @fx(float %12)
%28 = fpext float %27 to double
%29 = tail call float @fx(float %12)
%30 = fsub float %20, %29
%31 = tail call double @fabs(float %30)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %25, double %26, double %28, double %31)
%33 = fcmp ugt float %12, 1.000000e+00
br i1 %33, label %34, label %9
34: ; preds = %24
ret i32 0
}