#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*/ calcCPI();
int /*<<< orphan*/ executionTime();
int /*<<< orphan*/ insertParams();
int /*<<< orphan*/ mips();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice;
  while (choice != 5) {
    printf("\nMenu of Options");
    printf("\n---------------");
    printf("\n1) Enter parameters");
    printf("\n2) Calculate average CPI of a sequence of instructions");
    printf("\n3) Calculate total execution time of a sequence of instructions");
    printf("\n4) Calculate MIPS of a sequence of instructions");
    printf("\n5) Quit\n\n");
    printf("Enter selection: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      insertParams();
      break;
    case 2:
      calcCPI();
      break;
    case 3:
      executionTime();
      break;
    case 4:
      mips();
      break;
    case 5:
      break;
    default:
      printf("\nPlease enter a valid input (1-5)");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1258 <main+0xf8>
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1050 <printf@plt>
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
lea    0xed3(%rip),%rdi
call   1050 <printf@plt>
lea    0xf08(%rip),%rdi
call   1050 <printf@plt>
lea    0xf2d(%rip),%rdi
call   1050 <printf@plt>
lea    0xf2c(%rip),%rdi
call   1050 <printf@plt>
lea    0xf32(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1247 <main+0xe7>
mov    -0x10(%rbp),%rax
lea    0xdf7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <insertParams@plt>
jmp    1253 <main+0xf3>
mov    $0x0,%al
call   1060 <calcCPI@plt>
jmp    1253 <main+0xf3>
mov    $0x0,%al
call   1040 <executionTime@plt>
jmp    1253 <main+0xf3>
mov    $0x0,%al
call   1030 <mips@plt>
jmp    1253 <main+0xf3>
jmp    1253 <main+0xf3>
lea    0xec7(%rip),%rdi
call   1050 <printf@plt>
jmp    116f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf42(%rip),%rbp
lea    0xfa3(%rip),%r14
lea    0xf65(%rip),%r15
lea    0xf70(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe5d(%rip),%rbx
jmp    11cb <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xf53(%rip),%rdi
call   1060 <printf@plt>
nopl   0x0(%rax)
cmpl   $0x5,0x4(%rsp)
je     127c <main+0x10c>
lea    0xe42(%rip),%rdi
call   1060 <printf@plt>
lea    0xe47(%rip),%rdi
call   1060 <printf@plt>
lea    0xe4c(%rip),%rdi
call   1060 <printf@plt>
lea    0xe55(%rip),%rdi
call   1060 <printf@plt>
lea    0xe81(%rip),%rdi
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11b0 <main+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <insertParams@plt>
jmp    11c0 <main+0x50>
nop
xor    %eax,%eax
call   1070 <calcCPI@plt>
jmp    11c0 <main+0x50>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <executionTime@plt>
jmp    11c0 <main+0x50>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <mips@plt>
jmp    11c0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AMenu of Options\00"
@.str.1 = [17 x i8] c"\0A---------------\00"
@.str.2 = [21 x i8] c"\0A1) Enter parameters\00"
@.str.3 = [56 x i8] c"\0A2) Calculate average CPI of a sequence of instructions\00"
@.str.4 = [65 x i8] c"\0A3) Calculate total execution time of a sequence of instructions\00"
@.str.5 = [49 x i8] c"\0A4) Calculate MIPS of a sequence of instructions\00"
@.str.6 = [11 x i8] c"\0A5) Quit\0A\0A\00"
@.str.7 = [18 x i8] c"Enter selection: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [34 x i8] c"\0APlease enter a valid input (1-5)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %28, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 5
br i1 %5, label %6, label %29
6: ; preds = %3
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
switch i32 %16, label %26 [
i32 1, label %17
i32 2, label %19
i32 3, label %21
i32 4, label %23
i32 5, label %25
]
17: ; preds = %6
%18 = call i32 (...) @insertParams()
br label %28
19: ; preds = %6
%20 = call i32 (...) @calcCPI()
br label %28
21: ; preds = %6
%22 = call i32 (...) @executionTime()
br label %28
23: ; preds = %6
%24 = call i32 (...) @mips()
br label %28
25: ; preds = %6
br label %28
26: ; preds = %6
%27 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %28
28: ; preds = %26, %25, %23, %21, %19, %17
br label %3
29: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0AMenu of Options\00"
@.str.1 = [17 x i8] c"\0A---------------\00"
@.str.2 = [21 x i8] c"\0A1) Enter parameters\00"
@.str.3 = [56 x i8] c"\0A2) Calculate average CPI of a sequence of instructions\00"
@.str.4 = [65 x i8] c"\0A3) Calculate total execution time of a sequence of instructions\00"
@.str.5 = [49 x i8] c"\0A4) Calculate MIPS of a sequence of instructions\00"
@.str.7 = [18 x i8] c"Enter selection: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [34 x i8] c"\0APlease enter a valid input (1-5)\00"
@str = [10 x i8] c"\0A5) Quit\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %24
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
switch i32 %13, label %22 [
i32 1, label %14
i32 2, label %16
i32 3, label %18
i32 4, label %20
i32 5, label %27
]
14: ; preds = %3
%15 = call i32 (...) @insertParams()
br label %24
16: ; preds = %3
%17 = call i32 (...) @calcCPI()
br label %24
18: ; preds = %3
%19 = call i32 (...) @executionTime()
br label %24
20: ; preds = %3
%21 = call i32 (...) @mips()
br label %24
22: ; preds = %3
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 5
br i1 %26, label %27, label %3
27: ; preds = %3, %24
ret i32 0
}