#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 fabs(double);
double g(double);
int /*<<< orphan*/ printf(char *, int, double, double);
int /*<<< orphan*/ system(char *);
int main() {
  double x[101];
  double e[100];
  double d;
  double sol = 2;
  int i;
  x[0] = 1.5;
  e[0] = fabs(sol - x[0]);
  for (i = 1; i < 61; i++) {
    x[i] = g(x[i - 1]);
    d = x[i];
    e[i] = fabs(sol - d);
    printf("iter: %d\nestimacion: %lf\n En/En-1= %lf\n", i, d, e[i] / e[i - 1]);
  }
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x670,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x660(%rbp)
ff
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x330(%rbp)
ff
movsd  -0x660(%rbp),%xmm0
ff
subsd  -0x330(%rbp),%xmm0
ff
movaps 0xe87(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x650(%rbp)
ff
movl   $0x1,-0x664(%rbp)
cmpl   $0x3d,-0x664(%rbp)
jge    125a <main+0x12a>
mov    -0x664(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x330(%rbp,%rax,8),%xmm0
ff ff
call   1050 <g@plt>
movslq -0x664(%rbp),%rax
movsd  %xmm0,-0x330(%rbp,%rax,8)
ff ff
movslq -0x664(%rbp),%rax
movsd  -0x330(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x658(%rbp)
ff
movsd  -0x660(%rbp),%xmm0
ff
subsd  -0x658(%rbp),%xmm0
ff
movaps 0xe0c(%rip),%xmm1
pand   %xmm1,%xmm0
movslq -0x664(%rbp),%rax
movsd  %xmm0,-0x650(%rbp,%rax,8)
ff ff
mov    -0x664(%rbp),%esi
movsd  -0x658(%rbp),%xmm0
ff
movslq -0x664(%rbp),%rax
movsd  -0x650(%rbp,%rax,8),%xmm1
ff ff
mov    -0x664(%rbp),%eax
sub    $0x1,%eax
cltq
divsd  -0x650(%rbp,%rax,8),%xmm1
ff ff
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    118f <main+0x5f>
lea    0xde7(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  0xec1(%rip),%xmm0
movsd  0xec1(%rip),%xmm1
mov    $0xffffffffffffffc4,%rbx
lea    0xedb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x8(%rsp)
call   1050 <g@plt>
movsd  0xe9d(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm0,(%rsp)
andpd  0xe9c(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm1
divsd  0x8(%rsp),%xmm1
lea    0x3d(%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
inc    %rbx
jne    1160 <main+0x30>
lea    0xea3(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [40 x i8] c"iter: %d\0Aestimacion: %lf\0A En/En-1= %lf\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x double]
%3 = alloca [100 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
store double 2.000000e+00, double* %5
%7 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 0
store double 1.500000e+00, double* %7
%8 = load double, double* %5
%9 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 0
%10 = load double, double* %9
%11 = fsub double %8, %10
%12 = call double @llvm.fabs.f64(double %11)
%13 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
store double %12, double* %13
store i32 1, i32* %6
br label %14
14: ; preds = %51, %0
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 61
br i1 %16, label %17, label %54
17: ; preds = %14
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 %20
%22 = load double, double* %21
%23 = call double @g(double %22)
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 %25
store double %23, double* %26
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 %28
%30 = load double, double* %29
store double %30, double* %4
%31 = load double, double* %5
%32 = load double, double* %4
%33 = fsub double %31, %32
%34 = call double @llvm.fabs.f64(double %33)
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %36
store double %34, double* %37
%38 = load i32, i32* %6
%39 = load double, double* %4
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %41
%43 = load double, double* %42
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %46
%48 = load double, double* %47
%49 = fdiv double %43, %48
%50 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %38, double %39, double %49)
br label %51
51: ; preds = %17
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %14
54: ; preds = %14
%55 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"iter: %d\0Aestimacion: %lf\0A En/En-1= %lf\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 5.000000e-01, %0 ], [ %7, %1 ]
%3 = phi double [ 1.500000e+00, %0 ], [ %5, %1 ]
%4 = phi i64 [ 1, %0 ], [ %11, %1 ]
%5 = tail call double @g(double %3)
%6 = fsub double 2.000000e+00, %5
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fdiv double %7, %2
%9 = trunc i64 %4 to i32
%10 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %9, double %5, double %8)
%11 = add nuw nsw i64 %4, 1
%12 = icmp eq i64 %11, 61
br i1 %12, label %13, label %1
13: ; preds = %1
%14 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}