#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 *);
int main(void) {
  int base, exp, i;
  short int negative_exponent = 0;
  unsigned long int result = 1;
  printf("Please, enter a base and an exponent in the format \"b^e\":  ");
  scanf("%d ^ %d", &base, &exp);
  if (exp < 0) {
    negative_exponent = 1;
    exp = -exp;
  } else if (exp == 0) {
    result = 1;
    printf("Result: %ld\n", result);
    return 0;
  }
  printf("\n%d^0:\t1\n", base);
  while (i <= exp) {
    result *= base;
    if (negative_exponent == 0) {
      printf("%d^%d:\t%ld\n", base, i, result);
    } else {
      printf("%d^%d:\t1/%ld\n", base, i, result);
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x0,-0x12(%rbp)
movq   $0x1,-0x20(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    117c <main+0x5c>
movw   $0x1,-0x12(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11b1 <main+0x91>
cmpl   $0x0,-0xc(%rbp)
jne    11ac <main+0x8c>
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1232 <main+0x112>
jmp    11b1 <main+0x91>
mov    -0x8(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     122b <main+0x10b>
movslq -0x8(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
movswl -0x12(%rbp),%eax
cmp    $0x0,%eax
jne    1205 <main+0xe5>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121d <main+0xfd>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <main+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     116d <main+0x4d>
je     119c <main+0x7c>
mov    (%rsp),%esi
lea    0xefa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%eax
movslq %eax,%rcx
lea    0xef0(%rip),%rdi
jmp    1191 <main+0x71>
neg    %eax
mov    %eax,0x4(%rsp)
mov    (%rsp),%esi
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%eax
movslq %eax,%rcx
lea    0xed6(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11af <main+0x8f>
lea    0xea1(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Please, enter a base and an exponent in the format \22b^e\22: \00"
@.str.1 = [8 x i8] c"%d ^ %d\00"
@.str.2 = [13 x i8] c"Result: %ld\0A\00"
@.str.3 = [10 x i8] c"\0A%d^0:\091\0A\00"
@.str.4 = [12 x i8] c"%d^%d:\09%ld\0A\00"
@.str.5 = [14 x i8] c"%d^%d:\091/%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16
%6 = alloca i64
store i32 0, i32* %1
store i16 0, i16* %5
store i64 1, i64* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
store i16 1, i16* %5
%12 = load i32, i32* %3
%13 = sub nsw i32 0, %12
store i32 %13, i32* %3
br label %21
14: ; preds = %0
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
store i64 1, i64* %6
%18 = load i64, i64* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %18)
store i32 0, i32* %1
br label %50
20: ; preds = %14
br label %21
21: ; preds = %20, %11
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %46, %21
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %49
28: ; preds = %24
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = load i64, i64* %6
%32 = mul i64 %31, %30
store i64 %32, i64* %6
%33 = load i16, i16* %5
%34 = sext i16 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %28
%37 = load i32, i32* %2
%38 = load i32, i32* %4
%39 = load i64, i64* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %38, i64 %39)
br label %46
41: ; preds = %28
%42 = load i32, i32* %2
%43 = load i32, i32* %4
%44 = load i64, i64* %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %42, i32 %43, i64 %44)
br label %46
46: ; preds = %41, %36
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %24
49: ; preds = %24
store i32 0, i32* %1
br label %50
50: ; preds = %49, %17
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [60 x i8] c"Please, enter a base and an exponent in the format \22b^e\22: \00"
@.str.1 = [8 x i8] c"%d ^ %d\00"
@.str.2 = [13 x i8] c"Result: %ld\0A\00"
@.str.3 = [10 x i8] c"\0A%d^0:\091\0A\00"
@.str.4 = [12 x i8] c"%d^%d:\09%ld\0A\00"
@.str.5 = [14 x i8] c"%d^%d:\091/%ld\0A\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 ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %0
%10 = icmp eq i32 %7, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 1)
br label %26
13: ; preds = %9
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 undef, i64 %17)
br label %26
19: ; preds = %0
%20 = sub nsw i32 0, %7
store i32 %20, i32* %2
%21 = load i32, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 undef, i64 %24)
br label %26
26: ; preds = %13, %19, %11
ret i32 0
}