#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 display_menu(char *, char *, int, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ task1_main();
int /*<<< orphan*/ task2_main();
int /*<<< orphan*/ task3_main();
int main(void) {
  int option = 0, lab_task = 0;
  while (lab_task >= 0) {
    while (lab_task == 0) {
      option = display_menu("Lab 5 Main Menu",
                            "1. Task 1 - Prime Numbers\n2. Task 2 - Employee "
                            "Pay\n3. Task 3 - Number Guess Ultra\n4. Quit",
                            4, 1);
      if (option == 1) {
        lab_task = 1;
      } else if (option == 2) {
        lab_task = 2;
      } else if (option == 3) {
        lab_task = 3;
      } else {
        lab_task = -1;
      }
    }
    while (lab_task == 1) {
      task1_main();
      system("pause");
      system("cls");
      lab_task = 0;
    }
    while (lab_task == 2) {
      task2_main();
      system("pause");
      system("cls");
      lab_task = 0;
    }
    while (lab_task == 3) {
      task3_main();
      system("pause");
      system("cls");
      lab_task = 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     12b1 <main+0x161>
jmp    117c <main+0x2c>
cmpl   $0x0,-0xc(%rbp)
jne    11fe <main+0xae>
lea    0xe73(%rip),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x4,%edx
mov    $0x1,%ecx
call   1030 <display_menu@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11bc <main+0x6c>
movl   $0x1,-0xc(%rbp)
jmp    11f9 <main+0xa9>
cmpl   $0x2,-0x8(%rbp)
jne    11d2 <main+0x82>
movl   $0x2,-0xc(%rbp)
jmp    11f4 <main+0xa4>
cmpl   $0x3,-0x8(%rbp)
jne    11e8 <main+0x98>
movl   $0x3,-0xc(%rbp)
jmp    11ef <main+0x9f>
movl   $0xffffffff,-0xc(%rbp)
jmp    11f4 <main+0xa4>
jmp    11f9 <main+0xa9>
jmp    117c <main+0x2c>
jmp    1203 <main+0xb3>
cmpl   $0x1,-0xc(%rbp)
jne    1238 <main+0xe8>
mov    $0x0,%al
call   1050 <task1_main@plt>
lea    0xe4f(%rip),%rdi
call   1040 <system@plt>
lea    0xe49(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0xc(%rbp)
jmp    1203 <main+0xb3>
jmp    123d <main+0xed>
cmpl   $0x2,-0xc(%rbp)
jne    1272 <main+0x122>
mov    $0x0,%al
call   1060 <task2_main@plt>
lea    0xe15(%rip),%rdi
call   1040 <system@plt>
lea    0xe0f(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0xc(%rbp)
jmp    123d <main+0xed>
jmp    1277 <main+0x127>
cmpl   $0x3,-0xc(%rbp)
jne    12ac <main+0x15c>
mov    $0x0,%al
call   1070 <task3_main@plt>
lea    0xddb(%rip),%rdi
call   1040 <system@plt>
lea    0xdd5(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0xc(%rbp)
jmp    1277 <main+0x127>
jmp    116d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%r14
lea    0xeaa(%rip),%r15
lea    0xefd(%rip),%r12
lea    0xefc(%rip),%rbx
jmp    1197 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <task2_main@plt>
mov    %r12,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
mov    $0x1,%ecx
call   1030 <display_menu@plt>
cmp    $0x3,%eax
je     11d0 <main+0x80>
cmp    $0x2,%eax
je     1180 <main+0x30>
cmp    $0x1,%eax
jne    11d9 <main+0x89>
xor    %eax,%eax
call   1050 <task1_main@plt>
jmp    1187 <main+0x37>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <task3_main@plt>
jmp    1187 <main+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Lab 5 Main Menu\00"
@.str.1 = [90 x i8] c"1. Task 1 - Prime Numbers\0A2. Task 2 - Employee Pay\0A3. Task 3 - Number Guess Ultra\0A4. Quit\00"
@.str.2 = [6 x i8] c"pause\00"
@.str.3 = [4 x i8] c"cls\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %52, %0
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %53
7: ; preds = %4
br label %8
8: ; preds = %27, %7
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = call i32 @display_menu(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 1)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 1, i32* %3
br label %27
16: ; preds = %11
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 2, i32* %3
br label %26
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 3, i32* %3
br label %25
24: ; preds = %20
store i32 -1, i32* %3
br label %25
25: ; preds = %24, %23
br label %26
26: ; preds = %25, %19
br label %27
27: ; preds = %26, %15
br label %8
28: ; preds = %8
br label %29
29: ; preds = %32, %28
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 (...) @task1_main()
%34 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %29
36: ; preds = %29
br label %37
37: ; preds = %40, %36
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 (...) @task2_main()
%42 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %37
44: ; preds = %37
br label %45
45: ; preds = %48, %44
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = call i32 (...) @task3_main()
%50 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %45
52: ; preds = %45
br label %4
53: ; preds = %4
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str = [16 x i8] c"Lab 5 Main Menu\00"
@.str.1 = [90 x i8] c"1. Task 1 - Prime Numbers\0A2. Task 2 - Employee Pay\0A3. Task 3 - Number Guess Ultra\0A4. Quit\00"
@.str.2 = [6 x i8] c"pause\00"
@.str.3 = [4 x i8] c"cls\00"
define i32 @main() {
br label %4
1: ; preds = %10, %8, %6
%2 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %4
4: ; preds = %0, %1
%5 = tail call i32 @display_menu(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 1)
switch i32 %5, label %12 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
]
6: ; preds = %4
%7 = tail call i32 (...) @task1_main()
br label %1
8: ; preds = %4
%9 = tail call i32 (...) @task2_main()
br label %1
10: ; preds = %4
%11 = tail call i32 (...) @task3_main()
br label %1
12: ; preds = %4
ret i32 0
}