#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 general(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int a, n;
  int nearest;
  int choice;
  do {
    printf("\n\n* * * W E L C O M E * * *");
    printf("\n    1 .   Find Power");
    printf("\n    2 .   Exit");
    printf("\nEnter Choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("\nEnter a^n: ");
      scanf("%d %d", &a, &n);
      printf("\nSolution General: %d^%d = %d", a, n, general(a, n));
      break;
    case 2:
      printf("\n* * * THANKS * * *");
      break;
    default:
      printf("\nWish you knew how to count ! ! !");
      break;
    }
  } while (choice != 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xef9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     11b5 <main+0x85>
jmp    11a4 <main+0x74>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     120b <main+0xdb>
jmp    121e <main+0xee>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <general@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <main+0xfc>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <main+0xfc>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <main+0x101>
cmpl   $0x2,-0x14(%rbp)
jne    113f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed7(%rip),%r13
lea    0xee6(%rip),%r14
lea    0xeef(%rip),%rbx
lea    0xf26(%rip),%r12
lea    0xc(%rsp),%rbp
jmp    1189 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf20(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x2,0xc(%rsp)
je     125c <main+0x12c>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     1250 <main+0x120>
cmp    $0x1,%eax
jne    1170 <main+0x40>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rbp
mov    %r12,%r13
mov    %r14,%r12
mov    0x14(%rsp),%r14d
mov    0x10(%rsp),%r15d
mov    %r14d,%edi
mov    %r15d,%esi
call   1040 <general@plt>
lea    0xe46(%rip),%rdi
mov    %r14d,%esi
mov    %r12,%r14
mov    %r13,%r12
mov    %rbp,%r13
mov    %r15d,%edx
lea    0xc(%rsp),%rbp
lea    0xe08(%rip),%rbx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x2,0xc(%rsp)
jne    1189 <main+0x59>
jmp    125c <main+0x12c>
lea    0xe2c(%rip),%rdi
jmp    1177 <main+0x47>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0A\0A* * * W E L C O M E * * *\00"
@.str.1 = [22 x i8] c"\0A 1 . Find Power\00"
@.str.2 = [16 x i8] c"\0A 2 . Exit\00"
@.str.3 = [16 x i8] c"\0AEnter Choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"\0AEnter a^n: \00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [30 x i8] c"\0ASolution General: %d^%d = %d\00"
@.str.8 = [20 x i8] c"\0A* * * THANKS * * *\00"
@.str.9 = [34 x i8] c"\0AWish you knew how to count ! ! !\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %27, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
switch i32 %12, label %24 [
i32 1, label %13
i32 2, label %22
]
13: ; preds = %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %2, i32* %3)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @general(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %16, i32 %17, i32 %20)
br label %26
22: ; preds = %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %26
24: ; preds = %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %26
26: ; preds = %24, %22, %13
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 2
br i1 %29, label %6, label %30
30: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"\0A\0A* * * W E L C O M E * * *\00"
@.str.1 = [22 x i8] c"\0A 1 . Find Power\00"
@.str.2 = [16 x i8] c"\0A 2 . Exit\00"
@.str.3 = [16 x i8] c"\0AEnter Choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"\0AEnter a^n: \00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [30 x i8] c"\0ASolution General: %d^%d = %d\00"
@.str.8 = [20 x i8] c"\0A* * * THANKS * * *\00"
@.str.9 = [34 x i8] c"\0AWish you knew how to count ! ! !\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %25, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
switch i32 %13, label %23 [
i32 1, label %14
i32 2, label %21
]
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %1, i32* %2)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @general(i32 %17, i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
br label %25
21: ; preds = %7
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %25
23: ; preds = %7
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %25
25: ; preds = %14, %21, %23
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %7
28: ; preds = %25
ret i32 0
}