#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*/ scanf(char *, int *);
int main() {
  int exponente, i, resultado;
  resultado = 2;
  printf("\nIngrese el exponente de 2: ");
  scanf("%d", &exponente);
  if (exponente == 0)
    printf("\n2^%d es 1\n\n", exponente);
  else if (exponente == 1)
    printf("\n2^%d es %d\n\n", exponente, resultado);
  else {
    for (i = 2; i <= exponente; i++)
      resultado = resultado * 2;
    printf("\n2^%d es %d\n\n", exponente, resultado);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1174 <main+0x54>
mov    -0x8(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <main+0xba>
cmpl   $0x1,-0x8(%rbp)
jne    1197 <main+0x77>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <main+0xb5>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c1 <main+0xa1>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x7e>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <main+0xba>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1160 <main+0x40>
cmp    $0x1,%esi
jne    1172 <main+0x52>
lea    0xed9(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
jmp    11be <main+0x9e>
lea    0xeb9(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
mov    $0x2,%edx
jle    11b7 <main+0x97>
lea    -0x1(%rsi),%ecx
lea    -0x2(%rsi),%edx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%edx
jae    1190 <main+0x70>
mov    $0x2,%edx
jmp    11a8 <main+0x88>
and    $0xfffffff8,%ecx
mov    $0x2,%edx
nopl   0x0(%rax,%rax,1)
shl    $0x8,%edx
add    $0xfffffff8,%ecx
jne    11a0 <main+0x80>
test   %eax,%eax
je     11b7 <main+0x97>
nopl   0x0(%rax)
add    %edx,%edx
add    $0xffffffff,%eax
jne    11b0 <main+0x90>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0AIngrese el exponente de 2: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"\0A2^%d es 1\0A\0A\00"
@.str.3 = [14 x i8] c"\0A2^%d es %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %35
12: ; preds = %0
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %17)
br label %34
19: ; preds = %12
store i32 2, i32* %3
br label %20
20: ; preds = %27, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %4
%26 = mul nsw i32 %25, 2
store i32 %26, i32* %4
br label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %20
30: ; preds = %20
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %32)
br label %34
34: ; preds = %30, %15
br label %35
35: ; preds = %34, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0AIngrese el exponente de 2: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"\0A2^%d es 1\0A\0A\00"
@.str.3 = [14 x i8] c"\0A2^%d es %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
switch i32 %5, label %6 [
i32 0, label %15
i32 1, label %17
]
6: ; preds = %0
%7 = icmp slt i32 %5, 2
br i1 %7, label %35, label %8
8: ; preds = %6
%9 = add i32 %5, -1
%10 = add i32 %5, -2
%11 = and i32 %9, 7
%12 = icmp ult i32 %10, 7
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = and i32 %9, -8
br label %19
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %38
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 2)
br label %38
19: ; preds = %19, %13
%20 = phi i32 [ 2, %13 ], [ %22, %19 ]
%21 = phi i32 [ 0, %13 ], [ %23, %19 ]
%22 = shl i32 %20, 8
%23 = add i32 %21, 8
%24 = icmp eq i32 %23, %14
br i1 %24, label %25, label %19
25: ; preds = %19, %8
%26 = phi i32 [ undef, %8 ], [ %22, %19 ]
%27 = phi i32 [ 2, %8 ], [ %22, %19 ]
%28 = icmp eq i32 %11, 0
br i1 %28, label %35, label %29
29: ; preds = %25, %29
%30 = phi i32 [ %32, %29 ], [ %27, %25 ]
%31 = phi i32 [ %33, %29 ], [ 0, %25 ]
%32 = shl nsw i32 %30, 1
%33 = add i32 %31, 1
%34 = icmp eq i32 %33, %11
br i1 %34, label %35, label %29
35: ; preds = %25, %29, %6
%36 = phi i32 [ 2, %6 ], [ %26, %25 ], [ %32, %29 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %36)
br label %38
38: ; preds = %17, %35, %15
ret i32 0
}