#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 base, exponent;
  long long result = 1;
  printf("Enter a base number: ");
  scanf("%d", &base);
  printf("Enter an exponent: 4");
  scanf("%d", &exponent);
  while (exponent != 0) {
    result *= base;
    --exponent;
  }
  printf("Answer = %lld", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x18(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1198 <main+0x78>
movslq -0x8(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <main+0x53>
mov    -0x18(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
je     1183 <main+0x63>
movslq 0xc(%rsp),%rax
lea    -0x1(%rdx),%esi
mov    %edx,%ecx
and    $0x7,%ecx
cmp    $0x7,%esi
jae    118a <main+0x6a>
mov    $0x1,%esi
jmp    11c5 <main+0xa5>
mov    $0x1,%esi
jmp    11e1 <main+0xc1>
and    $0xfffffff8,%edx
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
imul   %rax,%rsi
add    $0xfffffff8,%edx
jne    11a0 <main+0x80>
test   %ecx,%ecx
je     11d9 <main+0xb9>
nopl   0x0(%rax)
imul   %rax,%rsi
add    $0xffffffff,%ecx
jne    11d0 <main+0xb0>
movl   $0x0,0x8(%rsp)
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter a base number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter an exponent: 4\00"
@.str.3 = [14 x i8] c"Answer = %lld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = load i64, i64* %4
%16 = mul nsw i64 %15, %14
store i64 %16, i64* %4
%17 = load i32, i32* %3
%18 = add nsw i32 %17, -1
store i32 %18, i32* %3
br label %9
19: ; preds = %9
%20 = load i64, i64* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i64 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter a base number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter an exponent: 4\00"
@.str.3 = [14 x i8] c"Answer = %lld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %44, label %11
11: ; preds = %0
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = add i32 %9, -1
%15 = and i32 %9, 7
%16 = icmp ult i32 %14, 7
br i1 %16, label %32, label %17
17: ; preds = %11
%18 = and i32 %9, -8
br label %19
19: ; preds = %19, %17
%20 = phi i64 [ 1, %17 ], [ %29, %19 ]
%21 = phi i32 [ 0, %17 ], [ %30, %19 ]
%22 = mul nsw i64 %20, %13
%23 = mul nsw i64 %22, %13
%24 = mul nsw i64 %23, %13
%25 = mul nsw i64 %24, %13
%26 = mul nsw i64 %25, %13
%27 = mul nsw i64 %26, %13
%28 = mul nsw i64 %27, %13
%29 = mul nsw i64 %28, %13
%30 = add i32 %21, 8
%31 = icmp eq i32 %30, %18
br i1 %31, label %32, label %19
32: ; preds = %19, %11
%33 = phi i64 [ undef, %11 ], [ %29, %19 ]
%34 = phi i64 [ 1, %11 ], [ %29, %19 ]
%35 = icmp eq i32 %15, 0
br i1 %35, label %42, label %36
36: ; preds = %32, %36
%37 = phi i64 [ %39, %36 ], [ %34, %32 ]
%38 = phi i32 [ %40, %36 ], [ 0, %32 ]
%39 = mul nsw i64 %37, %13
%40 = add i32 %38, 1
%41 = icmp eq i32 %40, %15
br i1 %41, label %42, label %36
42: ; preds = %36, %32
%43 = phi i64 [ %33, %32 ], [ %39, %36 ]
store i32 0, i32* %2
br label %44
44: ; preds = %42, %0
%45 = phi i64 [ %43, %42 ], [ 1, %0 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i64 %45)
ret i32 0
}