#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int toPower(int, int);
int main(int argc, char *argv[]) {
  int baseNum, exponentNum, returnNum;
  if (argc == 3) {
    baseNum = atoi(argv[1]);
    exponentNum = atoi(argv[2]);
  } else {
    printf("\nPlease enter base number:\n");
    scanf("%d", &baseNum);
    printf("\nPlease enter exponent:\n");
    scanf("%d", &exponentNum);
  }
  returnNum = toPower(baseNum, exponentNum);
  printf("\nResult: %d\n", returnNum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1185 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11c1 <main+0x81>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <toPower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    117b <main+0x2b>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %eax,0x4(%rsp)
mov    0x10(%r14),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
mov    %eax,(%rsp)
jmp    11b9 <main+0x69>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe72(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%esi
mov    %ebx,%edi
call   1050 <toPower@plt>
lea    0xe3c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0APlease enter base number:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\0APlease enter exponent:\0A\00"
@.str.3 = [13 x i8] c"\0AResult: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
br label %25
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
br label %25
25: ; preds = %20, %11
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @toPower(i32 %26, i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [13 x i8] c"\0AResult: %d\0A\00"
@str = [27 x i8] c"\0APlease enter base number:\00"
@str.4 = [24 x i8] c"\0APlease enter exponent:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
store i32 %11, i32* %3
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* %4
br label %22
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
br label %22
22: ; preds = %15, %8
%23 = phi i32 [ %21, %15 ], [ %14, %8 ]
%24 = phi i32 [ %20, %15 ], [ %11, %8 ]
%25 = call i32 @toPower(i32 %24, i32 %23)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %25)
ret i32 0
}