#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 *);
void power() {
  int base, exp;
  long long int value = 1;
  printf("Enter base number and exponent to be raised to, respectively:\n ");
  scanf("%d %d", &base, &exp);
  while (exp != 0) {
    value *= base;
    --exp;
  }
  printf("The answer is %d", value);
}


x86 assembly (clang, -O0):
<power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x1,-0x10(%rbp)
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1177 <power+0x57>
movslq -0x4(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <power+0x32>
mov    -0x10(%rbp),%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<power>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%edx
test   %edx,%edx
je     1163 <power+0x43>
movslq 0x4(%rsp),%rax
lea    -0x1(%rdx),%esi
mov    %edx,%ecx
and    $0x7,%ecx
cmp    $0x7,%esi
jae    116a <power+0x4a>
mov    $0x1,%esi
jmp    11a5 <power+0x85>
mov    $0x1,%esi
jmp    11c0 <power+0xa0>
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    1180 <power+0x60>
test   %ecx,%ecx
je     11b9 <power+0x99>
nopl   0x0(%rax)
imul   %rax,%rsi
add    $0xffffffff,%ecx
jne    11b0 <power+0x90>
movl   $0x0,(%rsp)
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Enter base number and exponent to be raised to, respectively:\0A \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [17 x i8] c"The answer is %d\00"
define void @power() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i64 1, i64* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = load i64, i64* %3
%13 = mul nsw i64 %12, %11
store i64 %13, i64* %3
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
%17 = load i64, i64* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 %17)
ret void
}

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