#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 fabs(double);
double fp(double *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  double x[6];
  int i;
  x[0] = 0.5;
  x[1] = 0.9;
  double a = 0;
  double b = 1;
  double error;
  double s;
  double minFp = 1;
  printf("Estimacion de una solucion por el Metodo de la Secante\n\n\n");
  printf("iteracion 0\n estimacion:%lf\n", x[0]);
  printf("iteracion 1\n estimacion:%lf\n", x[1]);
  for (i = 2; i < 6; i++) {
    x[i] = x[i - 1] - (f(x[i - 1]) / fp(x, i));
    printf("iteracion %d\n estimacion:%.15lf\n", i, x[i]);
    s = x[i];
    error = fabs((f(s))) / (minFp);
    printf("error<= %.18lf\n", error);
  }
  system("PAUSE");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe84(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xec2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xecc(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movl   $0x2,-0x44(%rbp)
cmpl   $0x6,-0x44(%rbp)
jge    1293 <main+0x153>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x40(%rbp,%rax,8),%xmm0
call   1040 <f@plt>
movsd  %xmm0,-0x80(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <fp@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x44(%rbp),%esi
movslq -0x44(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movslq -0x44(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1040 <f@plt>
movaps 0xdbc(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c9 <main+0x89>
lea    0xe3b(%rip),%rdi
call   1050 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xf35(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb8(%rip),%rdi
movsd  0xea0(%rip),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xebf(%rip),%rdi
movsd  0xe92(%rip),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0xe83(%rip),%xmm0
call   1050 <f@plt>
movsd  %xmm0,(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <fp@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xe87(%rip),%r15
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x20(%rsp),%xmm0
call   1050 <f@plt>
andps  0xe0c(%rip),%xmm0
lea    0xe80(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <f@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <fp@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %r15,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x28(%rsp),%xmm0
call   1050 <f@plt>
andps  0xd9e(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <f@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <fp@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x30(%rsp),%xmm0
call   1050 <f@plt>
andps  0xd37(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <f@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <fp@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x38(%rsp)
mov    %r15,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x38(%rsp),%xmm0
call   1050 <f@plt>
andps  0xcd0(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xd4a(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Estimacion de una solucion por el Metodo de la Secante\0A\0A\0A\00"
@.str.1 = [29 x i8] c"iteracion 0\0A estimacion:%lf\0A\00"
@.str.2 = [29 x i8] c"iteracion 1\0A estimacion:%lf\0A\00"
@.str.3 = [33 x i8] c"iteracion %d\0A estimacion:%.15lf\0A\00"
@.str.4 = [16 x i8] c"error<= %.18lf\0A\00"
@.str.5 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x double]
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
%9 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
store double 5.000000e-01, double* %9
%10 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 1
store double 9.000000e-01, double* %10
store double 0.000000e+00, double* %4
store double 1.000000e+00, double* %5
store double 1.000000e+00, double* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%13 = load double, double* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 1
%16 = load double, double* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %16)
store i32 2, i32* %3
br label %18
18: ; preds = %58, %0
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 6
br i1 %20, label %21, label %61
21: ; preds = %18
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 %24
%26 = load double, double* %25
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 %29
%31 = load double, double* %30
%32 = call double @f(double %31)
%33 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%34 = load i32, i32* %3
%35 = call double @fp(double* %33, i32 %34)
%36 = fdiv double %32, %35
%37 = fsub double %26, %36
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 %39
store double %37, double* %40
%41 = load i32, i32* %3
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 %43
%45 = load double, double* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %41, double %45)
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 %48
%50 = load double, double* %49
store double %50, double* %7
%51 = load double, double* %7
%52 = call double @f(double %51)
%53 = call double @llvm.fabs.f64(double %52)
%54 = load double, double* %8
%55 = fdiv double %53, %54
store double %55, double* %6
%56 = load double, double* %6
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %56)
br label %58
58: ; preds = %21
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 1
store i32 %60, i32* %3
br label %18
61: ; preds = %18
%62 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"iteracion 0\0A estimacion:%lf\0A\00"
@.str.2 = [29 x i8] c"iteracion 1\0A estimacion:%lf\0A\00"
@.str.3 = [33 x i8] c"iteracion %d\0A estimacion:%.15lf\0A\00"
@.str.4 = [16 x i8] c"error<= %.18lf\0A\00"
@.str.5 = [6 x i8] c"PAUSE\00"
@str = [57 x i8] c"Estimacion de una solucion por el Metodo de la Secante\0A\0A\00"
define i32 @main() {
%1 = alloca [6 x double]
%2 = bitcast [6 x double]* %1 to i8*
%3 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 0
%4 = bitcast [6 x double]* %1 to <2 x double>*
store <2 x double> <double 5.000000e-01, double 9.000000e-01>, <2 x double>* %4
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double 9.000000e-01)
%8 = call double @f(double 9.000000e-01)
%9 = call double @fp(double* %3, i32 2)
%10 = fdiv double %8, %9
%11 = fsub double 9.000000e-01, %10
%12 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 2
store double %11, double* %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 2, double %11)
%14 = load double, double* %12
%15 = call double @f(double %14)
%16 = call double @llvm.fabs.f64(double %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %16)
%18 = load double, double* %12
%19 = call double @f(double %18)
%20 = call double @fp(double* %3, i32 3)
%21 = fdiv double %19, %20
%22 = fsub double %18, %21
%23 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 3
store double %22, double* %23
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 3, double %22)
%25 = load double, double* %23
%26 = call double @f(double %25)
%27 = call double @llvm.fabs.f64(double %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %27)
%29 = load double, double* %23
%30 = call double @f(double %29)
%31 = call double @fp(double* %3, i32 4)
%32 = fdiv double %30, %31
%33 = fsub double %29, %32
%34 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
store double %33, double* %34
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 4, double %33)
%36 = load double, double* %34
%37 = call double @f(double %36)
%38 = call double @llvm.fabs.f64(double %37)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %38)
%40 = load double, double* %34
%41 = call double @f(double %40)
%42 = call double @fp(double* %3, i32 5)
%43 = fdiv double %41, %42
%44 = fsub double %40, %43
%45 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 5
store double %44, double* %45
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 5, double %44)
%47 = load double, double* %45
%48 = call double @f(double %47)
%49 = call double @llvm.fabs.f64(double %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %49)
%51 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}