#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*/ AddStudent();
int /*<<< orphan*/ ChangeStudent();
int /*<<< orphan*/ DeleteStudent();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ putMenu();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  setbuf(stdin, 0);
  setbuf(stdout, 0);
  setbuf(stderr, 0);
  char ch;
  puts("Welcome to my student database.\n");
  while (1) {
    putMenu();
    ch = getchar();
    while (getchar() != '\n')
      ;
    if (ch == 'a') {
      AddStudent();
    } else if (ch == 'd') {
      DeleteStudent();
    } else if (ch == 'c') {
      ChangeStudent();
    } else {
      puts("See you.");
      exit(0);
    }
  }
  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)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
lea    0xe33(%rip),%rdi
call   1060 <puts@plt>
mov    $0x0,%al
call   1030 <putMenu@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x11(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11fb <main+0x7b>
jmp    11e3 <main+0x63>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jne    1214 <main+0x94>
mov    $0x0,%al
call   1050 <AddStudent@plt>
jmp    1263 <main+0xe3>
movsbl -0x11(%rbp),%eax
cmp    $0x64,%eax
jne    122d <main+0xad>
mov    $0x0,%al
call   1040 <DeleteStudent@plt>
jmp    125e <main+0xde>
movsbl -0x11(%rbp),%eax
cmp    $0x63,%eax
jne    1246 <main+0xc6>
mov    $0x0,%al
call   1090 <ChangeStudent@plt>
jmp    1259 <main+0xd9>
lea    0xdd4(%rip),%rdi
call   1060 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
jmp    125e <main+0xde>
jmp    1263 <main+0xe3>
jmp    11d2 <main+0x52>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
lea    0xe48(%rip),%rdi
call   1060 <puts@plt>
jmp    11c7 <main+0x47>
nop
xor    %eax,%eax
call   1090 <ChangeStudent@plt>
xor    %eax,%eax
call   1030 <putMenu@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %eax,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
jne    11e0 <main+0x60>
cmp    $0x64,%bl
je     1210 <main+0x90>
cmp    $0x63,%bl
je     11c0 <main+0x40>
cmp    $0x61,%bl
jne    1219 <main+0x99>
xor    %eax,%eax
call   1050 <AddStudent@plt>
jmp    11c7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <DeleteStudent@plt>
jmp    11c7 <main+0x47>
lea    0xe01(%rip),%rdi
call   1060 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [33 x i8] c"Welcome to my student database.\0A\00"
@.str.1 = [9 x i8] c"See you.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @stdin
%8 = call i32 @setbuf(i32 %7, i32 0)
%9 = load i32, i32* @stdout
%10 = call i32 @setbuf(i32 %9, i32 0)
%11 = load i32, i32* @stderr
%12 = call i32 @setbuf(i32 %11, i32 0)
%13 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %2, %45
%15 = call i32 (...) @putMenu()
%16 = call signext i8 (...) @getchar()
store i8 %16, i8* %6
br label %17
17: ; preds = %21, %14
%18 = call signext i8 (...) @getchar()
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %17
br label %17
22: ; preds = %17
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 97
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (...) @AddStudent()
br label %45
28: ; preds = %22
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 100
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (...) @DeleteStudent()
br label %44
34: ; preds = %28
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 99
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (...) @ChangeStudent()
br label %43
40: ; preds = %34
%41 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %38
br label %44
44: ; preds = %43, %32
br label %45
45: ; preds = %44, %26
br label %14
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [33 x i8] c"Welcome to my student database.\0A\00"
@.str.1 = [9 x i8] c"See you.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @setbuf(i32 %3, i32 0)
%5 = load i32, i32* @stdout
%6 = tail call i32 @setbuf(i32 %5, i32 0)
%7 = load i32, i32* @stderr
%8 = tail call i32 @setbuf(i32 %7, i32 0)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %21, %2
%11 = tail call i32 (...) @putMenu()
%12 = tail call signext i8 (...) @getchar()
br label %13
13: ; preds = %13, %10
%14 = tail call signext i8 (...) @getchar()
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %13
16: ; preds = %13
switch i8 %12, label %24 [
i8 97, label %17
i8 100, label %19
i8 99, label %22
]
17: ; preds = %16
%18 = tail call i32 (...) @AddStudent()
br label %21
19: ; preds = %16
%20 = tail call i32 (...) @DeleteStudent()
br label %21
21: ; preds = %19, %22, %17
br label %10
22: ; preds = %16
%23 = tail call i32 (...) @ChangeStudent()
br label %21
24: ; preds = %16
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @exit(i32 0)
unreachable
}