#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*/ alphabeticSort(char **, double *, int *, int);
int /*<<< orphan*/ exitMenu();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getData(int *, double *, char **, int);
int numStudents();
int /*<<< orphan*/ printInfo(int *, double *, char **, int);
int /*<<< orphan*/ printMenu();
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int /*<<< orphan*/ sortGPA(double *, int *, char **, int);
int /*<<< orphan*/ sortNumber(char **, double *, int *, int);
int /*<<< orphan*/ stdin;
int main(void) {
  int id[10];
  double gpa[10];
  char name[10][31];
  int num, result, menu;
  num = numStudents();
  getData(id, gpa, name, num);
  do {
    do {
      printMenu();
      printf("Enter a menu option>");
      fflush(stdin);
      result = scanf("%d", &menu);
      if ((result != 1) || (menu < 1) || (menu > 6)) {
        printf("Invalid input, please enter one of the menu choices\n");
      }
    } while ((result != 1) || (menu < 1) || (menu > 6));
    switch (menu) {
    case 1:
      alphabeticSort(name, gpa, id, num);
      printInfo(id, gpa, name, num);
      break;
    case 2:
      sortNumber(name, gpa, id, num);
      printInfo(id, gpa, name, num);
      break;
    case 3:
      sortGPA(gpa, id, name, num);
      printInfo(id, gpa, name, num);
      break;
    case 4:
      num = numStudents();
      getData(id, gpa, name, num);
      break;
    case 5:
      printInfo(id, gpa, name, num);
      break;
    case 6:
      exitMenu();
      break;
    }
  } while (1);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <numStudents@plt>
mov    %eax,-0x1c4(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   1030 <getData@plt>
jmp    11ee <main+0x3e>
mov    $0x0,%al
call   1070 <printMenu@plt>
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe17(%rip),%rdi
lea    -0x1cc(%rbp),%rsi
call   1080 <scanf@plt>
mov    %eax,-0x1c8(%rbp)
cmpl   $0x1,-0x1c8(%rbp)
jne    124f <main+0x9f>
cmpl   $0x1,-0x1cc(%rbp)
jl     124f <main+0x9f>
cmpl   $0x6,-0x1cc(%rbp)
jle    125b <main+0xab>
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
jmp    1260 <main+0xb0>
mov    $0x1,%al
cmpl   $0x1,-0x1c8(%rbp)
mov    %al,-0x1cd(%rbp)
jne    129a <main+0xea>
mov    $0x1,%al
cmpl   $0x1,-0x1cc(%rbp)
mov    %al,-0x1cd(%rbp)
jl     129a <main+0xea>
cmpl   $0x6,-0x1cc(%rbp)
setg   %al
mov    %al,-0x1cd(%rbp)
mov    -0x1cd(%rbp),%al
test   $0x1,%al
jne    11ee <main+0x3e>
mov    -0x1cc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x1d8(%rbp)
sub    $0x5,%eax
ja     13d7 <main+0x227>
mov    -0x1d8(%rbp),%rax
lea    0xd2f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x1c0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10c0 <alphabeticSort@plt>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10d0 <printInfo@plt>
jmp    13d7 <main+0x227>
lea    -0x1c0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10b0 <sortNumber@plt>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10d0 <printInfo@plt>
jmp    13d7 <main+0x227>
lea    -0x80(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   1050 <sortGPA@plt>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10d0 <printInfo@plt>
jmp    13d7 <main+0x227>
mov    $0x0,%al
call   1090 <numStudents@plt>
mov    %eax,-0x1c4(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   1030 <getData@plt>
jmp    13d7 <main+0x227>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x1c4(%rbp),%ecx
call   10d0 <printInfo@plt>
jmp    13d7 <main+0x227>
mov    $0x0,%al
call   10a0 <exitMenu@plt>
jmp    13dc <main+0x22c>
mov    $0x1,%al
test   $0x1,%al
jne    11e9 <main+0x39>
jmp    13eb <main+0x23b>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
xor    %eax,%eax
call   10a0 <numStudents@plt>
lea    0x10(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x90(%rsp),%rdx
mov    %eax,0x8(%rsp)
mov    %eax,%ecx
call   1030 <getData@plt>
lea    0xe1c(%rip),%rbx
mov    0x2de5(%rip),%r13
lea    0xe23(%rip),%rbp
lea    0xc(%rsp),%r14
lea    0xe1a(%rip),%r15
jmp    1260 <main+0xa0>
lea    0x90(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    0x8(%rsp),%r12d
mov    %r12d,%ecx
call   10d0 <alphabeticSort@plt>
lea    0x10(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x90(%rsp),%rdx
mov    %r12d,%ecx
call   10e0 <printInfo@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <printMenu@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    %eax,%r12d
cmp    $0x1,%eax
jne    1298 <main+0xd8>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1298 <main+0xd8>
cmp    $0x7,%eax
jl     12a4 <main+0xe4>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%r12d
jne    1260 <main+0xa0>
test   %eax,%eax
jle    1260 <main+0xa0>
cmp    $0x6,%eax
jg     1260 <main+0xa0>
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     1260 <main+0xa0>
lea    0xd3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x90(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    0x8(%rsp),%r12d
mov    %r12d,%ecx
call   10c0 <sortNumber@plt>
jmp    1237 <main+0x77>
lea    0x40(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x90(%rsp),%rdx
mov    0x8(%rsp),%r12d
mov    %r12d,%ecx
call   1060 <sortGPA@plt>
jmp    1237 <main+0x77>
lea    0x10(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x90(%rsp),%rdx
mov    0x8(%rsp),%ecx
call   10e0 <printInfo@plt>
jmp    1260 <main+0xa0>
xor    %eax,%eax
call   10b0 <exitMenu@plt>
jmp    1260 <main+0xa0>
xor    %eax,%eax
call   10a0 <numStudents@plt>
lea    0x10(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0x90(%rsp),%rdx
mov    %eax,0x8(%rsp)
mov    %eax,%ecx
call   1030 <getData@plt>
jmp    1260 <main+0xa0>

LLVM IR (-O0):
@.str = [21 x i8] c"Enter a menu option>\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [53 x i8] c"Invalid input, please enter one of the menu choices\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x double]
%4 = alloca [10 x [31 x i8]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @numStudents()
store i32 %8, i32* %5
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%11 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%12 = bitcast [31 x i8]* %11 to i8**
%13 = load i32, i32* %5
%14 = call i32 @getData(i32* %9, double* %10, i8** %12, i32 %13)
br label %15
15: ; preds = %103, %0
br label %16
16: ; preds = %42, %15
%17 = call i32 (...) @printMenu()
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32 @fflush(i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 1
br i1 %23, label %30, label %24
24: ; preds = %16
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 6
br i1 %29, label %30, label %32
30: ; preds = %27, %24, %16
%31 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 1
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 1
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* %7
%41 = icmp sgt i32 %40, 6
br label %42
42: ; preds = %39, %36, %33
%43 = phi i1 [ true, %36 ], [ true, %33 ], [ %41, %39 ]
br i1 %43, label %16, label %44
44: ; preds = %42
%45 = load i32, i32* %7
switch i32 %45, label %102 [
i32 1, label %46
i32 2, label %59
i32 3, label %72
i32 4, label %85
i32 5, label %93
i32 6, label %100
]
46: ; preds = %44
%47 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%48 = bitcast [31 x i8]* %47 to i8**
%49 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%51 = load i32, i32* %5
%52 = call i32 @alphabeticSort(i8** %48, double* %49, i32* %50, i32 %51)
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%54 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%55 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%56 = bitcast [31 x i8]* %55 to i8**
%57 = load i32, i32* %5
%58 = call i32 @printInfo(i32* %53, double* %54, i8** %56, i32 %57)
br label %102
59: ; preds = %44
%60 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%61 = bitcast [31 x i8]* %60 to i8**
%62 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%64 = load i32, i32* %5
%65 = call i32 @sortNumber(i8** %61, double* %62, i32* %63, i32 %64)
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%67 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%68 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%69 = bitcast [31 x i8]* %68 to i8**
%70 = load i32, i32* %5
%71 = call i32 @printInfo(i32* %66, double* %67, i8** %69, i32 %70)
br label %102
72: ; preds = %44
%73 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%74 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%75 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%76 = bitcast [31 x i8]* %75 to i8**
%77 = load i32, i32* %5
%78 = call i32 @sortGPA(double* %73, i32* %74, i8** %76, i32 %77)
%79 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%80 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%81 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%82 = bitcast [31 x i8]* %81 to i8**
%83 = load i32, i32* %5
%84 = call i32 @printInfo(i32* %79, double* %80, i8** %82, i32 %83)
br label %102
85: ; preds = %44
%86 = call i32 (...) @numStudents()
store i32 %86, i32* %5
%87 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%88 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%89 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%90 = bitcast [31 x i8]* %89 to i8**
%91 = load i32, i32* %5
%92 = call i32 @getData(i32* %87, double* %88, i8** %90, i32 %91)
br label %102
93: ; preds = %44
%94 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%95 = getelementptr inbounds [10 x double], [10 x double]* %3, i64 0, i64 0
%96 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %4, i64 0, i64 0
%97 = bitcast [31 x i8]* %96 to i8**
%98 = load i32, i32* %5
%99 = call i32 @printInfo(i32* %94, double* %95, i8** %97, i32 %98)
br label %102
100: ; preds = %44
%101 = call i32 (...) @exitMenu()
br label %102
102: ; preds = %44, %100, %93, %85, %72, %59, %46
br label %103
103: ; preds = %102
br i1 true, label %15, label %104
104: ; preds = %103
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter a menu option>\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@str = [52 x i8] c"Invalid input, please enter one of the menu choices\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x double]
%3 = alloca [10 x [31 x i8]]
%4 = alloca i32
%5 = bitcast [10 x i32]* %1 to i8*
%6 = bitcast [10 x double]* %2 to i8*
%7 = getelementptr inbounds [10 x [31 x i8]], [10 x [31 x i8]]* %3, i64 0, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (...) @numStudents()
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%11 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 0
%12 = bitcast [10 x [31 x i8]]* %3 to i8**
%13 = call i32 @getData(i32* %10, double* %11, i8** %12, i32 %9)
br label %14
14: ; preds = %49, %0
%15 = phi i32 [ %50, %49 ], [ %9, %0 ]
br label %16
16: ; preds = %42, %14
br label %17
17: ; preds = %32, %16
%18 = call i32 (...) @printMenu()
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdin
%21 = call i32 @fflush(i32 %20)
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%23 = icmp ne i32 %22, 1
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 1
%26 = select i1 %23, i1 true, i1 %25
%27 = icmp sgt i32 %24, 6
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %29, label %32
29: ; preds = %17
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%31 = load i32, i32* %4
br label %32
32: ; preds = %29, %17
%33 = phi i32 [ %31, %29 ], [ %24, %17 ]
%34 = icmp slt i32 %33, 1
%35 = select i1 %23, i1 true, i1 %34
%36 = icmp sgt i32 %33, 6
%37 = select i1 %35, i1 true, i1 %36
br i1 %37, label %17, label %38
38: ; preds = %32
switch i32 %33, label %42 [
i32 1, label %39
i32 2, label %43
i32 3, label %46
i32 4, label %49
i32 5, label %52
i32 6, label %54
]
39: ; preds = %38
%40 = call i32 @alphabeticSort(i8** %12, double* %11, i32* %10, i32 %15)
%41 = call i32 @printInfo(i32* %10, double* %11, i8** %12, i32 %15)
br label %42
42: ; preds = %39, %43, %46, %52, %54, %38
br label %16
43: ; preds = %38
%44 = call i32 @sortNumber(i8** %12, double* %11, i32* %10, i32 %15)
%45 = call i32 @printInfo(i32* %10, double* %11, i8** %12, i32 %15)
br label %42
46: ; preds = %38
%47 = call i32 @sortGPA(double* %11, i32* %10, i8** %12, i32 %15)
%48 = call i32 @printInfo(i32* %10, double* %11, i8** %12, i32 %15)
br label %42
49: ; preds = %38
%50 = call i32 (...) @numStudents()
%51 = call i32 @getData(i32* %10, double* %11, i8** %12, i32 %50)
br label %14
52: ; preds = %38
%53 = call i32 @printInfo(i32* %10, double* %11, i8** %12, i32 %15)
br label %42
54: ; preds = %38
%55 = call i32 (...) @exitMenu()
br label %42
}