#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 dwalltime();
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char *argv[]) {
  double x = 2;
  double timetick, timeend;
  double resultado;
  long long int i;
  printf("Funcion calculada...\n");
  timetick = dwalltime();
  double fx = ((x * x) + (3 * x) + 2) / ((x * x) + 1);
  for (i = 0; i < 100000000; i++) {
    resultado += 2 * fx - i;
  }
  timeend = dwalltime();
  printf(" Tiempo total en segundos %.10lf \n", (timeend - timetick));
  printf(" Tiempo promedio en segundos %.10lf \n",
         (timeend - timetick) / 100000000);
  printf("Funcion calculada cada vez...\n");
  timetick = dwalltime();
  for (i = 0; i < 100000000; i++) {
    resultado += 2 * (((x * x) + (3 * x) + 2) / ((x * x) + 1)) - i;
  }
  timeend = dwalltime();
  printf(" Tiempo total en segundos %.10lf \n", (timeend - timetick));
  printf(" Tiempo promedio en segundos %.10lf \n",
         (timeend - timetick) / 100000000);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <dwalltime@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xea1(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe84(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe62(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x5f5e100,-0x38(%rbp)
05
jge    1206 <main+0xe6>
movsd  -0x40(%rbp),%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11b3 <main+0x93>
mov    $0x0,%al
call   1040 <dwalltime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xddc(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe12(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <dwalltime@plt>
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x5f5e100,-0x38(%rbp)
05
jge    1307 <main+0x1e7>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xd80(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd63(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd41(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1270 <main+0x150>
mov    $0x0,%al
call   1040 <dwalltime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xd12(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xcdb(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xd11(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <dwalltime@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <dwalltime@plt>
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xea4(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
divsd  0xe85(%rip),%xmm0
lea    0xea9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <dwalltime@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <dwalltime@plt>
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
divsd  0xe34(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [35 x i8] c" Tiempo total en segundos %.10lf \0A\00"
@.str.2 = [38 x i8] c" Tiempo promedio en segundos %.10lf \0A\00"
@str = [21 x i8] c"Funcion calculada...\00"
@str.4 = [30 x i8] c"Funcion calculada cada vez...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @dwalltime()
%5 = tail call double (...) @dwalltime()
%6 = fsub double %5, %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %6)
%8 = fdiv double %6, 1.000000e+08
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%11 = tail call double (...) @dwalltime()
%12 = tail call double (...) @dwalltime()
%13 = fsub double %12, %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = fdiv double %13, 1.000000e+08
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}