#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float x;
  int n;
  float p = 1;
  printf("Ingrese un float x: ");
  scanf("%f", &x);
  printf("Ingrese un int n: ");
  scanf("%d", &n);
  if (x == 0 && n <= 0) {
    puts("Error: x debe ser positivo para n no positivo");
    return -1;
  }
  printf("%f ^ %d == ", x, n);
  if (n < 0) {
    x = 1 / x;
    n = -n;
  }
  for (; n != 0; n >>= 1) {
    if (n & 1) {
      p *= x;
    }
    x *= x;
  }
  printf("%f\n", p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xeb9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c5 <main+0x95>
jp     11c5 <main+0x95>
cmpl   $0x0,-0xc(%rbp)
jg     11c5 <main+0x95>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126b <main+0x13b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    1203 <main+0xd3>
movss  0xe0f(%rip),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1208 <main+0xd8>
cmpl   $0x0,-0xc(%rbp)
je     124d <main+0x11d>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1230 <main+0x100>
movss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1208 <main+0xd8>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
mov    (%rsp),%esi
jne    119b <main+0x6b>
jp     119b <main+0x6b>
test   %esi,%esi
jg     119b <main+0x6b>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
cvtss2sd %xmm0,%xmm0
lea    0xec2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    (%rsp),%eax
movss  0x4(%rsp),%xmm0
test   %eax,%eax
js     11c6 <main+0x96>
jne    11d7 <main+0xa7>
movsd  0xe3c(%rip),%xmm0
jmp    121f <main+0xef>
movss  0xe3a(%rip),%xmm1
divss  %xmm0,%xmm1
neg    %eax
movaps %xmm1,%xmm0
movss  0xe29(%rip),%xmm2
movaps %xmm2,%xmm1
jmp    1203 <main+0xd3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mulss  %xmm3,%xmm1
mulss  %xmm0,%xmm0
mov    %eax,%ecx
sar    %ecx
cmp    $0x1,%eax
mov    %ecx,%eax
jbe    120f <main+0xdf>
movaps %xmm2,%xmm3
test   $0x1,%al
je     11f0 <main+0xc0>
movaps %xmm0,%xmm3
jmp    11f0 <main+0xc0>
movss  %xmm0,0x4(%rsp)
mov    %ecx,(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe4e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Ingrese un float x: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [19 x i8] c"Ingrese un int n: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"Error: x debe ser positivo para n no positivo\00"
@.str.5 = [12 x i8] c"%f ^ %d == \00"
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%9 = load float, float* %2
%10 = fcmp oeq float %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @puts(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %51
16: ; preds = %11, %0
%17 = load float, float* %2
%18 = fpext float %17 to double
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %18, i32 %19)
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load float, float* %2
%25 = fdiv float 1.000000e+00, %24
store float %25, float* %2
%26 = load i32, i32* %3
%27 = sub nsw i32 0, %26
store i32 %27, i32* %3
br label %28
28: ; preds = %23, %16
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load i32, i32* %3
%34 = and i32 %33, 1
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load float, float* %2
%38 = load float, float* %4
%39 = fmul float %38, %37
store float %39, float* %4
br label %40
40: ; preds = %36, %32
%41 = load float, float* %2
%42 = load float, float* %2
%43 = fmul float %42, %41
store float %43, float* %2
br label %44
44: ; preds = %40
%45 = load i32, i32* %3
%46 = ashr i32 %45, 1
store i32 %46, i32* %3
br label %29
47: ; preds = %29
%48 = load float, float* %4
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %49)
store i32 0, i32* %1
br label %51
51: ; preds = %47, %14
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [21 x i8] c"Ingrese un float x: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [19 x i8] c"Ingrese un int n: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"Error: x debe ser positivo para n no positivo\00"
@.str.5 = [12 x i8] c"%f ^ %d == \00"
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = load float, float* %1
%10 = fcmp oeq float %9, 0.000000e+00
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
br label %46
16: ; preds = %0
%17 = fpext float %9 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %17, i32 %11)
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
%21 = load float, float* %1
br i1 %20, label %22, label %25
22: ; preds = %16
%23 = fdiv float 1.000000e+00, %21
%24 = sub nsw i32 0, %19
br label %27
25: ; preds = %16
%26 = icmp eq i32 %19, 0
br i1 %26, label %43, label %27
27: ; preds = %22, %25
%28 = phi i32 [ %19, %25 ], [ %24, %22 ]
%29 = phi float [ %21, %25 ], [ %23, %22 ]
br label %30
30: ; preds = %27, %30
%31 = phi float [ %37, %30 ], [ 1.000000e+00, %27 ]
%32 = phi i32 [ %39, %30 ], [ %28, %27 ]
%33 = phi float [ %38, %30 ], [ %29, %27 ]
%34 = and i32 %32, 1
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, float 1.000000e+00, float %33
%37 = fmul float %31, %36
%38 = fmul float %33, %33
%39 = ashr i32 %32, 1
%40 = icmp ult i32 %32, 2
br i1 %40, label %41, label %30
41: ; preds = %30
store float %38, float* %1
store i32 %39, i32* %2
%42 = fpext float %37 to double
br label %43
43: ; preds = %41, %25
%44 = phi double [ %42, %41 ], [ 1.000000e+00, %25 ]
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %44)
br label %46
46: ; preds = %43, %14
%47 = phi i32 [ -1, %14 ], [ 0, %43 ]
ret i32 %47
}