#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  clock_t begin, end;
  double time_spent;
  begin = clock();
  int n, x;
  float sum = 0;
  printf("Ingrese el valor de x: ");
  scanf("%d", &x);
  printf("Ingrese el valor de n: ");
  scanf("%d", &n);
  int fact = 1;
  int pot = 1;
  for (int i = 1; i <= n; i++) {
    pot = pot * x;
    fact = fact * i;
    sum = sum + pot / fact;
  }
  printf("El resultado de la sumatoria es: %.2f", sum);
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("\nEl tiemo de ejecución fue de %f", time_spent);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11ea <main+0xba>
mov    -0x34(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
imul   -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
mov    -0x34(%rbp),%eax
cltd
idivl  -0x30(%rbp)
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11a3 <main+0x73>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2dc8(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r8d
test   %r8d,%r8d
jle    11a1 <main+0x71>
mov    (%rsp),%r10d
cmp    $0x1,%r8d
jne    11a9 <main+0x79>
xorps  %xmm0,%xmm0
mov    $0x1,%ecx
mov    $0x1,%esi
mov    $0x1,%ebx
jmp    121a <main+0xea>
xorps  %xmm0,%xmm0
jmp    123c <main+0x10c>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
neg    %r9d
xorps  %xmm0,%xmm0
mov    $0x1,%r11d
mov    $0x1,%esi
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
imul   %r10d,%esi
imul   %r11d,%edi
mov    %esi,%eax
cltd
idiv   %edi
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
addss  %xmm0,%xmm1
lea    0x1(%r11),%ebx
imul   %r10d,%esi
imul   %edi,%ebx
mov    %esi,%eax
cltd
idiv   %ebx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  %xmm1,%xmm0
mov    %r11d,%ecx
add    $0x2,%ecx
lea    (%r9,%r11,1),%eax
add    $0x2,%eax
mov    %ecx,%r11d
mov    %ebx,%edi
cmp    $0x1,%eax
jne    11d0 <main+0xa0>
test   $0x1,%r8b
je     1238 <main+0x108>
imul   %esi,%r10d
imul   %ebx,%ecx
mov    %r10d,%eax
cltd
idiv   %ecx
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2d85(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdeb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Ingrese el valor de x: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Ingrese el valor de n: \00"
@.str.3 = [38 x i8] c"El resultado de la sumatoria es: %.2f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.4 = [34 x i8] c"\0AEl tiemo de ejecuci\C3\B3n fue de %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i64 (...) @clock()
store i64 %11, i64* %2
store float 0.000000e+00, float* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 1, i32* %8
store i32 1, i32* %9
store i32 1, i32* %10
br label %16
16: ; preds = %33, %0
%17 = load i32, i32* %10
%18 = load i32, i32* %5
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = mul nsw i32 %21, %22
store i32 %23, i32* %9
%24 = load i32, i32* %8
%25 = load i32, i32* %10
%26 = mul nsw i32 %24, %25
store i32 %26, i32* %8
%27 = load float, float* %7
%28 = load i32, i32* %9
%29 = load i32, i32* %8
%30 = sdiv i32 %28, %29
%31 = sitofp i32 %30 to float
%32 = fadd float %27, %31
store float %32, float* %7
br label %33
33: ; preds = %20
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %16
36: ; preds = %16
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %38)
%40 = call i64 (...) @clock()
store i64 %40, i64* %3
%41 = load i64, i64* %3
%42 = load i64, i64* %2
%43 = sub nsw i64 %41, %42
%44 = sitofp i64 %43 to double
%45 = load double, double* @CLOCKS_PER_SEC
%46 = fdiv double %44, %45
store double %46, double* %4
%47 = load double, double* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %47)
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [24 x i8] c"Ingrese el valor de x: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Ingrese el valor de n: \00"
@.str.3 = [38 x i8] c"El resultado de la sumatoria es: %.2f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.4 = [34 x i8] c"\0AEl tiemo de ejecuci\C3\B3n fue de %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i64 (...) @clock()
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %34, label %12
12: ; preds = %0
%13 = load i32, i32* %2
%14 = and i32 %10, 1
%15 = icmp eq i32 %10, 1
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = and i32 %10, -2
br label %43
18: ; preds = %43, %12
%19 = phi float [ undef, %12 ], [ %59, %43 ]
%20 = phi i32 [ 1, %12 ], [ %60, %43 ]
%21 = phi i32 [ 1, %12 ], [ %55, %43 ]
%22 = phi i32 [ 1, %12 ], [ %56, %43 ]
%23 = phi float [ 0.000000e+00, %12 ], [ %59, %43 ]
%24 = icmp eq i32 %14, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = mul nsw i32 %13, %21
%27 = mul nuw nsw i32 %20, %22
%28 = sdiv i32 %26, %27
%29 = sitofp i32 %28 to float
%30 = fadd float %23, %29
br label %31
31: ; preds = %18, %25
%32 = phi float [ %19, %18 ], [ %30, %25 ]
%33 = fpext float %32 to double
br label %34
34: ; preds = %31, %0
%35 = phi double [ 0.000000e+00, %0 ], [ %33, %31 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %35)
%37 = call i64 (...) @clock()
%38 = sub nsw i64 %37, %3
%39 = sitofp i64 %38 to double
%40 = load double, double* @CLOCKS_PER_SEC
%41 = fdiv double %39, %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), double %41)
ret i32 0
43: ; preds = %43, %16
%44 = phi i32 [ 1, %16 ], [ %60, %43 ]
%45 = phi i32 [ 1, %16 ], [ %55, %43 ]
%46 = phi i32 [ 1, %16 ], [ %56, %43 ]
%47 = phi float [ 0.000000e+00, %16 ], [ %59, %43 ]
%48 = phi i32 [ 0, %16 ], [ %61, %43 ]
%49 = mul nsw i32 %13, %45
%50 = mul nuw nsw i32 %44, %46
%51 = sdiv i32 %49, %50
%52 = sitofp i32 %51 to float
%53 = fadd float %47, %52
%54 = add nuw i32 %44, 1
%55 = mul nsw i32 %13, %49
%56 = mul nuw nsw i32 %54, %50
%57 = sdiv i32 %55, %56
%58 = sitofp i32 %57 to float
%59 = fadd float %53, %58
%60 = add nuw i32 %44, 2
%61 = add i32 %48, 2
%62 = icmp eq i32 %61, %17
br i1 %62, label %18, label %43
}