#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 pow, num, i = 1;
  long int sum = 1;
  printf("\nEnter a number: ");
  scanf("%d", &num);
  printf("\nEnter power: ");
  scanf("%d", &pow);
  while (i <= pow) {
    sum = sum * num;
    i++;
  }
  printf("\n%d to the power %d is: %ld", num, pow, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a4 <main+0x84>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117a <main+0x5a>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe6f(%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    0xed8(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edx
movslq 0x8(%rsp),%rsi
test   %edx,%edx
jle    1183 <main+0x63>
lea    -0x1(%rdx),%ecx
mov    %edx,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    118a <main+0x6a>
mov    $0x1,%ecx
jmp    11c5 <main+0xa5>
mov    $0x1,%ecx
jmp    11d9 <main+0xb9>
mov    %edx,%edi
and    $0xfffffff8,%edi
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
imul   %rsi,%rcx
add    $0xfffffff8,%edi
jne    11a0 <main+0x80>
test   %eax,%eax
je     11d9 <main+0xb9>
nopl   0x0(%rax)
imul   %rsi,%rcx
add    $0xffffffff,%eax
jne    11d0 <main+0xb0>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0AEnter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"\0AEnter power: \00"
@.str.3 = [28 x i8] c"\0A%d to the power %d is: %ld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
store i32 1, i32* %4
store i64 1, i64* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i64, i64* %5
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = mul nsw i64 %15, %17
store i64 %18, i64* %5
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %10
21: ; preds = %10
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = load i64, i64* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23, i64 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0AEnter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"\0AEnter power: \00"
@.str.3 = [28 x i8] c"\0A%d to the power %d is: %ld\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 ([18 x i8], [18 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* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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* %1)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
%11 = load i32, i32* %2
br i1 %10, label %42, label %12
12: ; preds = %0
%13 = sext i32 %11 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 = %12
%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, %12
%33 = phi i64 [ undef, %12 ], [ %29, %19 ]
%34 = phi i64 [ 1, %12 ], [ %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 = %32, %36, %0
%43 = phi i64 [ 1, %0 ], [ %33, %32 ], [ %39, %36 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %9, i64 %43)
ret i32 0
}