#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);
double freal(double);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ system(char *);
int main() {
  double a = 0;
  double b = 2;
  double h = 0.1;
  double X[20 + 1];
  double Y[20 + 1];
  double sol[20 + 1];
  double error[20 + 1];
  int i;
  X[0] = a;
  Y[0] = 3;
  sol[0] = freal(X[0]);
  for (i = 1; i < 20 + 1; i++) {
    X[i] = X[i - 1] + h;
    Y[i] = Y[i - 1] + f(X[i - 1], Y[i - 1]) * h;
    sol[i] = freal(X[i]);
    error[i] = fabs(sol[i] - Y[i]);
  }
  printf("Para x=2:\n estimacion:%.8lf\n solucion real:%lf\n error:%lf\n",
         Y[20], sol[20], error[20]);
  system("PAUSE");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f0,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x180(%rbp)
ff
movsd  -0xd0(%rbp),%xmm0
ff
call   1030 <freal@plt>
movsd  %xmm0,-0x230(%rbp)
ff
movl   $0x1,-0x2e4(%rbp)
cmpl   $0x15,-0x2e4(%rbp)
jge    12c8 <main+0x188>
mov    -0x2e4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
addsd  -0x20(%rbp),%xmm0
movslq -0x2e4(%rbp),%rax
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
mov    -0x2e4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x180(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x2f0(%rbp)
ff
mov    -0x2e4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2e4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x180(%rbp,%rax,8),%xmm1
ff ff
call   1040 <f@plt>
movsd  -0x2f0(%rbp),%xmm1
ff
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x2e4(%rbp),%rax
movsd  %xmm0,-0x180(%rbp,%rax,8)
ff ff
movslq -0x2e4(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
call   1030 <freal@plt>
movslq -0x2e4(%rbp),%rax
movsd  %xmm0,-0x230(%rbp,%rax,8)
ff ff
movslq -0x2e4(%rbp),%rax
movsd  -0x230(%rbp,%rax,8),%xmm0
ff ff
movslq -0x2e4(%rbp),%rax
subsd  -0x180(%rbp,%rax,8),%xmm0
ff ff
movaps 0xd80(%rip),%xmm1
pand   %xmm1,%xmm0
movslq -0x2e4(%rbp),%rax
movsd  %xmm0,-0x2e0(%rbp,%rax,8)
ff ff
mov    -0x2e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2e4(%rbp)
jmp    11b0 <main+0x70>
movsd  -0xe0(%rbp),%xmm0
ff
movsd  -0x190(%rbp),%xmm1
ff
movsd  -0x240(%rbp),%xmm2
ff
lea    0xd49(%rip),%rdi
call   1060 <printf@plt>
lea    0xd78(%rip),%rdi
call   1050 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x2f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x220,%rsp
movabs $0x4008000000000000,%rax
mov    %rax,0xc0(%rsp)
xorpd  %xmm0,%xmm0
call   1030 <freal@plt>
xorpd  %xmm3,%xmm3
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%ebx
movsd  0xe86(%rip),%xmm1
xorpd  %xmm2,%xmm2
xchg   %ax,%ax
movsd  %xmm1,(%rsp)
movsd  0xe7b(%rip),%xmm0
addsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm3,%xmm0
movsd  (%rsp),%xmm1
call   1040 <f@plt>
mulsd  0xe5b(%rip),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
movsd  %xmm0,0xc0(%rsp,%rbx,8)
movsd  0x8(%rsp),%xmm0
call   1030 <freal@plt>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm1
movsd  %xmm0,0x10(%rsp,%rbx,8)
subsd  %xmm1,%xmm0
andpd  0xe1f(%rip),%xmm0
movlpd %xmm0,0x170(%rsp,%rbx,8)
add    $0x1,%rbx
movapd %xmm2,%xmm3
cmp    $0x15,%rbx
jne    1180 <main+0x40>
movsd  0x160(%rsp),%xmm0
movsd  0xb0(%rsp),%xmm1
movsd  0x210(%rsp),%xmm2
lea    0xdf2(%rip),%rdi
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [59 x i8] c"Para x=2:\0A estimacion:%.8lf\0A solucion real:%lf\0A error:%lf\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [21 x double]
%6 = alloca [21 x double]
%7 = alloca [21 x double]
%8 = alloca [21 x double]
%9 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 2.000000e+00, double* %3
store double 1.000000e-01, double* %4
%10 = load double, double* %2
%11 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 0
store double %10, double* %11
%12 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 0
store double 3.000000e+00, double* %12
%13 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 0
%14 = load double, double* %13
%15 = call double @freal(double %14)
%16 = getelementptr inbounds [21 x double], [21 x double]* %7, i64 0, i64 0
store double %15, double* %16
store i32 1, i32* %9
br label %17
17: ; preds = %73, %0
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 21
br i1 %19, label %20, label %76
20: ; preds = %17
%21 = load i32, i32* %9
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 %23
%25 = load double, double* %24
%26 = load double, double* %4
%27 = fadd double %25, %26
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 %29
store double %27, double* %30
%31 = load i32, i32* %9
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 %33
%35 = load double, double* %34
%36 = load i32, i32* %9
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 %38
%40 = load double, double* %39
%41 = load i32, i32* %9
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 %43
%45 = load double, double* %44
%46 = call double @f(double %40, double %45)
%47 = load double, double* %4
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %35)
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 %50
store double %48, double* %51
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [21 x double], [21 x double]* %5, i64 0, i64 %53
%55 = load double, double* %54
%56 = call double @freal(double %55)
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [21 x double], [21 x double]* %7, i64 0, i64 %58
store double %56, double* %59
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [21 x double], [21 x double]* %7, i64 0, i64 %61
%63 = load double, double* %62
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 %65
%67 = load double, double* %66
%68 = fsub double %63, %67
%69 = call double @llvm.fabs.f64(double %68)
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [21 x double], [21 x double]* %8, i64 0, i64 %71
store double %69, double* %72
br label %73
73: ; preds = %20
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %17
76: ; preds = %17
%77 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 20
%78 = load double, double* %77
%79 = getelementptr inbounds [21 x double], [21 x double]* %7, i64 0, i64 20
%80 = load double, double* %79
%81 = getelementptr inbounds [21 x double], [21 x double]* %8, i64 0, i64 20
%82 = load double, double* %81
%83 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), double %78, double %80, double %82)
%84 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%85 = load i32, i32* %1
ret i32 %85
}

LLVM IR (-O2):
@.str = [59 x i8] c"Para x=2:\0A estimacion:%.8lf\0A solucion real:%lf\0A error:%lf\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca [21 x double]
%2 = alloca [21 x double]
%3 = alloca [21 x double]
%4 = bitcast [21 x double]* %1 to i8*
%5 = bitcast [21 x double]* %2 to i8*
%6 = bitcast [21 x double]* %3 to i8*
%7 = getelementptr inbounds [21 x double], [21 x double]* %1, i64 0, i64 0
store double 3.000000e+00, double* %7
%8 = tail call double @freal(double 0.000000e+00)
%9 = getelementptr inbounds [21 x double], [21 x double]* %2, i64 0, i64 0
store double %8, double* %9
br label %10
10: ; preds = %0, %10
%11 = phi double [ 3.000000e+00, %0 ], [ %16, %10 ]
%12 = phi double [ 0.000000e+00, %0 ], [ %14, %10 ]
%13 = phi i64 [ 1, %0 ], [ %23, %10 ]
%14 = fadd double %12, 1.000000e-01
%15 = tail call double @f(double %12, double %11)
%16 = tail call double @llvm.fmuladd.f64(double %15, double 1.000000e-01, double %11)
%17 = getelementptr inbounds [21 x double], [21 x double]* %1, i64 0, i64 %13
store double %16, double* %17
%18 = tail call double @freal(double %14)
%19 = getelementptr inbounds [21 x double], [21 x double]* %2, i64 0, i64 %13
store double %18, double* %19
%20 = fsub double %18, %16
%21 = tail call double @llvm.fabs.f64(double %20)
%22 = getelementptr inbounds [21 x double], [21 x double]* %3, i64 0, i64 %13
store double %21, double* %22
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, 21
br i1 %24, label %25, label %10
25: ; preds = %10
%26 = getelementptr inbounds [21 x double], [21 x double]* %1, i64 0, i64 20
%27 = load double, double* %26
%28 = getelementptr inbounds [21 x double], [21 x double]* %2, i64 0, i64 20
%29 = load double, double* %28
%30 = getelementptr inbounds [21 x double], [21 x double]* %3, i64 0, i64 20
%31 = load double, double* %30
%32 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), double %27, double %29, double %31)
%33 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}