#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 EOF;
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ build(char *, char *, int);
int /*<<< orphan*/ buildHashTable();
int displayMenu();
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ searchStudent(int);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "Portuguese");
  int menuOption, clean, studentRegisterCode;
  buildHashTable();
  build("Leandro", "leandro@gmail.com", 30234181);
  build("Moacir", "moacir@gmail.com", 42356681);
  build("Alcides", "alcides@gmail.com", 34158689);
  build("João", "joao@gmail.com", 15953688);
  build("José", "jose@gmail.com", 96366784);
  build("Leonardo Rifeli", "leonardorifeli@gmail.com", 2136681);
  build("Marlei", "marlei@gmail.com", 5336691);
  build("Thuany", "thuany@gmail.com", 4636689);
  build("Vitória", "vitoria@gmail.com", 7936683);
  build("Valentina", "valentina@gmail.com", 1736684);
  while (1) {
    menuOption = displayMenu();
    if (menuOption < 1 || menuOption > 2) {
      printf("Invalid Option.\n\n");
      continue;
    }
    if (menuOption == 2) {
      printf("Thanks! Bye.\n");
      break;
    }
    printf("Please, key the Student's RU (register code): \n");
    scanf("%d", &studentRegisterCode);
    while ((clean = getchar()) != '\n' && clean != EOF) {
    }
    searchStudent(studentRegisterCode);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1090 <setlocale@plt>
mov    $0x0,%al
call   1060 <buildHashTable@plt>
lea    0xe59(%rip),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x1cd5645,%edx
call   1040 <build@plt>
lea    0xe5b(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x2864fc9,%edx
call   1040 <build@plt>
lea    0xe5b(%rip),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x2093861,%edx
call   1040 <build@plt>
lea    0xe5d(%rip),%rdi
lea    0xe5c(%rip),%rsi
mov    $0xf36f18,%edx
call   1040 <build@plt>
lea    0xe5a(%rip),%rdi
lea    0xe59(%rip),%rsi
mov    $0x5be70c0,%edx
call   1040 <build@plt>
lea    0xe57(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0x209a69,%edx
call   1040 <build@plt>
lea    0xe68(%rip),%rdi
lea    0xe68(%rip),%rsi
mov    $0x516e73,%edx
call   1040 <build@plt>
lea    0xe68(%rip),%rdi
lea    0xe68(%rip),%rsi
mov    $0x46c011,%edx
call   1040 <build@plt>
lea    0xe68(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x791aab,%edx
call   1040 <build@plt>
lea    0xe6b(%rip),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x1a7fec,%edx
call   1040 <build@plt>
mov    $0x0,%al
call   1030 <displayMenu@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     12b9 <main+0x139>
cmpl   $0x2,-0x8(%rbp)
jle    12ca <main+0x14a>
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
jmp    129b <main+0x11b>
cmpl   $0x2,-0x8(%rbp)
jne    12e5 <main+0x165>
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
jmp    134f <main+0x1cf>
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   10a0 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     132d <main+0x1ad>
mov    -0xc(%rbp),%eax
mov    0x2cc3(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    133d <main+0x1bd>
jmp    1342 <main+0x1c2>
jmp    1301 <main+0x181>
mov    -0x10(%rbp),%edi
call   1070 <searchStudent@plt>
jmp    129b <main+0x11b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1090 <setlocale@plt>
xor    %eax,%eax
call   1060 <buildHashTable@plt>
lea    0xe5b(%rip),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x1cd5645,%edx
call   1050 <build@plt>
lea    0xe5d(%rip),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x2864fc9,%edx
call   1050 <build@plt>
lea    0xe5d(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x2093861,%edx
call   1050 <build@plt>
lea    0xe5f(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0xf36f18,%edx
call   1050 <build@plt>
lea    0xe5c(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x5be70c0,%edx
call   1050 <build@plt>
lea    0xe59(%rip),%rdi
lea    0xe62(%rip),%rsi
mov    $0x209a69,%edx
call   1050 <build@plt>
lea    0xe6a(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x516e73,%edx
call   1050 <build@plt>
lea    0xe6a(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x46c011,%edx
call   1050 <build@plt>
lea    0xe6a(%rip),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x791aab,%edx
call   1050 <build@plt>
lea    0xe6d(%rip),%rdi
lea    0xe70(%rip),%rsi
mov    $0x1a7fec,%edx
call   1050 <build@plt>
lea    0xeb2(%rip),%r12
lea    0xe6f(%rip),%r14
lea    0xe65(%rip),%r15
lea    0xc(%rsp),%r13
mov    0x2d2e(%rip),%rbx
jmp    12c8 <main+0x148>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <displayMenu@plt>
lea    -0x3(%rax),%ecx
cmp    $0xfffffffd,%ecx
jbe    12c0 <main+0x140>
cmp    $0x2,%eax
je     130b <main+0x18b>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   10a0 <scanf@plt>
nop
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%eax
je     1300 <main+0x180>
cmp    (%rbx),%eax
jne    12f0 <main+0x170>
mov    0xc(%rsp),%edi
call   1070 <searchStudent@plt>
jmp    12c8 <main+0x148>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [8 x i8] c"Leandro\00"
@.str.2 = [18 x i8] c"leandro@gmail.com\00"
@.str.3 = [7 x i8] c"Moacir\00"
@.str.4 = [17 x i8] c"moacir@gmail.com\00"
@.str.5 = [8 x i8] c"Alcides\00"
@.str.6 = [18 x i8] c"alcides@gmail.com\00"
@.str.7 = [6 x i8] c"Jo\C3\A3o\00"
@.str.8 = [15 x i8] c"joao@gmail.com\00"
@.str.9 = [6 x i8] c"Jos\C3\A9\00"
@.str.10 = [15 x i8] c"jose@gmail.com\00"
@.str.11 = [16 x i8] c"Leonardo Rifeli\00"
@.str.12 = [25 x i8] c"leonardorifeli@gmail.com\00"
@.str.13 = [7 x i8] c"Marlei\00"
@.str.14 = [17 x i8] c"marlei@gmail.com\00"
@.str.15 = [7 x i8] c"Thuany\00"
@.str.16 = [17 x i8] c"thuany@gmail.com\00"
@.str.17 = [9 x i8] c"Vit\C3\B3ria\00"
@.str.18 = [18 x i8] c"vitoria@gmail.com\00"
@.str.19 = [10 x i8] c"Valentina\00"
@.str.20 = [20 x i8] c"valentina@gmail.com\00"
@.str.21 = [18 x i8] c"Invalid Option.\0A\0A\00"
@.str.22 = [14 x i8] c"Thanks! Bye.\0A\00"
@.str.23 = [48 x i8] c"Please, key the Student's RU (register code): \0A\00"
@.str.24 = [3 x i8] c"%d\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @buildHashTable()
%8 = call i32 @build(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 30234181)
%9 = call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 42356681)
%10 = call i32 @build(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 34158689)
%11 = call i32 @build(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 15953688)
%12 = call i32 @build(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 96366784)
%13 = call i32 @build(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 2136681)
%14 = call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 5336691)
%15 = call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i32 4636689)
%16 = call i32 @build(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i32 7936683)
%17 = call i32 @build(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i32 1736684)
br label %18
18: ; preds = %0, %25, %45
%19 = call i32 (...) @displayMenu()
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 1
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %22, %18
%26 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.21, i64 0, i64 0))
br label %18
27: ; preds = %22
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0))
br label %48
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.23, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i32* %4)
br label %35
35: ; preds = %44, %32
%36 = call i32 (...) @getchar()
store i32 %36, i32* %3
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %3
%40 = load i32, i32* @EOF
%41 = icmp ne i32 %39, %40
br label %42
42: ; preds = %38, %35
%43 = phi i1 [ false, %35 ], [ %41, %38 ]
br i1 %43, label %44, label %45
44: ; preds = %42
br label %35
45: ; preds = %42
%46 = load i32, i32* %4
%47 = call i32 @searchStudent(i32 %46)
br label %18
48: ; preds = %30
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [8 x i8] c"Leandro\00"
@.str.2 = [18 x i8] c"leandro@gmail.com\00"
@.str.3 = [7 x i8] c"Moacir\00"
@.str.4 = [17 x i8] c"moacir@gmail.com\00"
@.str.5 = [8 x i8] c"Alcides\00"
@.str.6 = [18 x i8] c"alcides@gmail.com\00"
@.str.7 = [6 x i8] c"Jo\C3\A3o\00"
@.str.8 = [15 x i8] c"joao@gmail.com\00"
@.str.9 = [6 x i8] c"Jos\C3\A9\00"
@.str.10 = [15 x i8] c"jose@gmail.com\00"
@.str.11 = [16 x i8] c"Leonardo Rifeli\00"
@.str.12 = [25 x i8] c"leonardorifeli@gmail.com\00"
@.str.13 = [7 x i8] c"Marlei\00"
@.str.14 = [17 x i8] c"marlei@gmail.com\00"
@.str.15 = [7 x i8] c"Thuany\00"
@.str.16 = [17 x i8] c"thuany@gmail.com\00"
@.str.17 = [9 x i8] c"Vit\C3\B3ria\00"
@.str.18 = [18 x i8] c"vitoria@gmail.com\00"
@.str.19 = [10 x i8] c"Valentina\00"
@.str.20 = [20 x i8] c"valentina@gmail.com\00"
@.str.24 = [3 x i8] c"%d\00"
@EOF = global i32 0
@str = [47 x i8] c"Please, key the Student's RU (register code): \00"
@str.25 = [13 x i8] c"Thanks! Bye.\00"
@str.26 = [17 x i8] c"Invalid Option.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @LC_ALL
%3 = tail call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (...) @buildHashTable()
%6 = tail call i32 @build(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 30234181)
%7 = tail call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 42356681)
%8 = tail call i32 @build(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 34158689)
%9 = tail call i32 @build(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 15953688)
%10 = tail call i32 @build(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 96366784)
%11 = tail call i32 @build(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 2136681)
%12 = tail call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i32 5336691)
%13 = tail call i32 @build(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i32 4636689)
%14 = tail call i32 @build(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0), i32 7936683)
%15 = tail call i32 @build(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i32 1736684)
br label %16
16: ; preds = %22, %0
%17 = call i32 (...) @displayMenu()
%18 = add i32 %17, -3
%19 = icmp ult i32 %18, -2
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0))
br label %22
22: ; preds = %20, %36
br label %16
23: ; preds = %16
%24 = icmp eq i32 %17, 2
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.25, i64 0, i64 0))
ret i32 0
27: ; preds = %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0), i32* %1)
br label %30
30: ; preds = %30, %27
%31 = call i32 (...) @getchar()
%32 = icmp ne i32 %31, 10
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %31, %33
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %30, label %36
36: ; preds = %30
%37 = load i32, i32* %1
%38 = call i32 @searchStudent(i32 %37)
br label %22
}