#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*/ prob1();
int /*<<< orphan*/ prob2();
int /*<<< orphan*/ prob3();
int /*<<< orphan*/ prob5();
int /*<<< orphan*/ prob6();
int /*<<< orphan*/ prob7();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  int menu;
beginning:;
  system("clear");
  printf("Please select which homework problem you would like to run:\n");
  printf("1 -- Problem 1 ( 10.7 )\n");
  printf("2 -- Problem 2 ( 10.10 )\n");
  printf("3 -- Problem 3 ( 10.30 )\n");
  printf("4 -- Problem 5 ( Matrix Multiplication )\n");
  printf("5 -- Problem 6 ( Sieve of Eratosthenes )\n");
  printf("6 -- Problem 7 ( 11.6 )\n");
  printf("7 -- Exit Program\n\n");
  printf("Enter Selection: ");
  scanf("%d", &menu);
  switch (menu) {
  case 1:
    prob1();
    goto beginning;
  case 2:
    prob2();
    goto beginning;
  case 3:
    prob3();
    goto beginning;
  case 4:
    prob5();
    goto beginning;
  case 5:
    prob6();
    goto beginning;
  case 6:
    prob7();
    goto beginning;
  case 7:
    system("clear");
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe6f(%rip),%rdi
call   1040 <system@plt>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1050 <printf@plt>
lea    0xec3(%rip),%rdi
call   1050 <printf@plt>
lea    0xee1(%rip),%rdi
call   1050 <printf@plt>
lea    0xeff(%rip),%rdi
call   1050 <printf@plt>
lea    0xf0c(%rip),%rdi
call   1050 <printf@plt>
lea    0xf14(%rip),%rdi
call   1050 <printf@plt>
lea    0xf1a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x6,%eax
ja     12b2 <main+0x122>
mov    -0x20(%rbp),%rax
lea    0xdb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10a0 <prob1@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   1060 <prob2@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   10b0 <prob3@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   1030 <prob5@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   1070 <prob6@plt>
jmp    11a6 <main+0x16>
mov    $0x0,%al
call   1090 <prob7@plt>
jmp    11a6 <main+0x16>
lea    0xd76(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf5d(%rip),%r15
lea    0xf6e(%rip),%r12
lea    0xe62(%rip),%r13
lea    0xe6d(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xe2d(%rip),%r14
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   10a0 <prob7@plt>
nopl   0x0(%rax)
lea    0xe35(%rip),%rdi
call   1050 <system@plt>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     12b4 <main+0x114>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   10b0 <prob1@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   1070 <prob2@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   10c0 <prob3@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   1030 <prob5@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
call   1080 <prob6@plt>
jmp    11e0 <main+0x40>
lea    0xd6d(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [61 x i8] c"Please select which homework problem you would like to run:\0A\00"
@.str.2 = [25 x i8] c"1 -- Problem 1 ( 10.7 )\0A\00"
@.str.3 = [26 x i8] c"2 -- Problem 2 ( 10.10 )\0A\00"
@.str.4 = [26 x i8] c"3 -- Problem 3 ( 10.30 )\0A\00"
@.str.5 = [42 x i8] c"4 -- Problem 5 ( Matrix Multiplication )\0A\00"
@.str.6 = [42 x i8] c"5 -- Problem 6 ( Sieve of Eratosthenes )\0A\00"
@.str.7 = [25 x i8] c"6 -- Problem 7 ( 11.6 )\0A\00"
@.str.8 = [20 x i8] c"7 -- Exit Program\0A\0A\00"
@.str.9 = [18 x i8] c"Enter Selection: \00"
@.str.10 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %30, %28, %26, %24, %22, %20, %2
%8 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %6)
%19 = load i32, i32* %6
switch i32 %19, label %34 [
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 4, label %26
i32 5, label %28
i32 6, label %30
i32 7, label %32
]
20: ; preds = %7
%21 = call i32 (...) @prob1()
br label %7
22: ; preds = %7
%23 = call i32 (...) @prob2()
br label %7
24: ; preds = %7
%25 = call i32 (...) @prob3()
br label %7
26: ; preds = %7
%27 = call i32 (...) @prob5()
br label %7
28: ; preds = %7
%29 = call i32 (...) @prob6()
br label %7
30: ; preds = %7
%31 = call i32 (...) @prob7()
br label %7
32: ; preds = %7
%33 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %34
34: ; preds = %32, %7
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.9 = [18 x i8] c"Enter Selection: \00"
@.str.10 = [3 x i8] c"%d\00"
@str = [60 x i8] c"Please select which homework problem you would like to run:\00"
@str.11 = [24 x i8] c"1 -- Problem 1 ( 10.7 )\00"
@str.12 = [25 x i8] c"2 -- Problem 2 ( 10.10 )\00"
@str.13 = [25 x i8] c"3 -- Problem 3 ( 10.30 )\00"
@str.14 = [41 x i8] c"4 -- Problem 5 ( Matrix Multiplication )\00"
@str.15 = [41 x i8] c"5 -- Problem 6 ( Sieve of Eratosthenes )\00"
@str.16 = [24 x i8] c"6 -- Problem 7 ( 11.6 )\00"
@str.17 = [19 x i8] c"7 -- Exit Program\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %20, %2
%6 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.14, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.15, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0))
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
switch i32 %17, label %33 [
i32 1, label %18
i32 2, label %21
i32 3, label %23
i32 4, label %25
i32 5, label %27
i32 6, label %29
i32 7, label %31
]
18: ; preds = %5
%19 = call i32 (...) @prob1()
br label %20
20: ; preds = %18, %21, %23, %25, %27, %29
br label %5
21: ; preds = %5
%22 = call i32 (...) @prob2()
br label %20
23: ; preds = %5
%24 = call i32 (...) @prob3()
br label %20
25: ; preds = %5
%26 = call i32 (...) @prob5()
br label %20
27: ; preds = %5
%28 = call i32 (...) @prob6()
br label %20
29: ; preds = %5
%30 = call i32 (...) @prob7()
br label %20
31: ; preds = %5
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %5, %31
ret i32 0
}