#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 */
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  int n = 3;
  for (i = 1; i <= 100; i++) {
    printf("%d^%d: %lld\n", n, i, (unsigned long long)pow(n, i));
    if ((unsigned long long)pow(n, i) >= 9223372036854775807) {
      printf("Too Big for an unsigned long long!");
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     11c0 <main+0xa0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <pow@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %rax,%rcx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <pow@plt>
movabs $0x7fffffffffffffff,%rcx
ff ff 7f
cmp    %rcx,%rax
jb     11ad <main+0x8d>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <main+0xa0>
jmp    11b2 <main+0x92>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%ebx
lea    0xecf(%rip),%r14
movabs $0x7fffffffffffffff,%r15
ff ff 7f
nopl   0x0(%rax,%rax,1)
mov    $0x3,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
cmp    %r15,%rax
jae    117b <main+0x5b>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <main+0x20>
jmp    1189 <main+0x69>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d^%d: %lld\0A\00"
@.str.1 = [35 x i8] c"Too Big for an unsigned long long!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %3
store i32 1, i32* %2
br label %4
4: ; preds = %21, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 100
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = call i64 @pow(i32 %10, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i64 %12)
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = call i64 @pow(i32 %14, i32 %15)
%17 = icmp uge i64 %16, 9223372036854775807
br i1 %17, label %18, label %20
18: ; preds = %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %24
20: ; preds = %7
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %4
24: ; preds = %18, %4
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d^%d: %lld\0A\00"
@.str.1 = [35 x i8] c"Too Big for an unsigned long long!\00"
define i32 @main() {
br label %4
1: ; preds = %4
%2 = add nuw nsw i32 %5, 1
%3 = icmp eq i32 %2, 101
br i1 %3, label %12, label %4
4: ; preds = %0, %1
%5 = phi i32 [ 1, %0 ], [ %2, %1 ]
%6 = tail call i64 @pow(i32 3, i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 3, i32 %5, i64 %6)
%8 = tail call i64 @pow(i32 3, i32 %5)
%9 = icmp ugt i64 %8, 9223372036854775806
br i1 %9, label %10, label %1
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %1, %10
ret i32 0
}