#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 INT_MIN;
int show_database_menu(char *);
int start_alloc(char *);
int start_batch(char *);
int start_room(char *);
int start_subject(char *);
int start_teacher(char *);
int start_timetable(char *);
int database_menu(char *database) {
  int n = 6, choice, exit;
  while (1) {
    choice = show_database_menu(database);
    if (choice == 0)
      exit = start_teacher(database);
    if (choice == 1)
      exit = start_subject(database);
    if (choice == 2)
      exit = start_batch(database);
    if (choice == 3)
      exit = start_room(database);
    if (choice == 4)
      exit = start_alloc(database);
    if (choice == 5)
      exit = start_timetable(database);
    if (choice == n + 1)
      return 0;
    if (exit == INT_MIN || choice == INT_MIN)
      return INT_MIN;
  }
}


x86 assembly (clang, -O0):
<database_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x6,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <show_database_menu@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11a5 <database_menu+0x35>
mov    -0x10(%rbp),%rdi
call   1060 <start_teacher@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11bb <database_menu+0x4b>
mov    -0x10(%rbp),%rdi
call   1040 <start_subject@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    11d1 <database_menu+0x61>
mov    -0x10(%rbp),%rdi
call   1070 <start_batch@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x18(%rbp)
jne    11e7 <database_menu+0x77>
mov    -0x10(%rbp),%rdi
call   1050 <start_room@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0x18(%rbp)
jne    11fd <database_menu+0x8d>
mov    -0x10(%rbp),%rdi
call   1080 <start_alloc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x5,-0x18(%rbp)
jne    1213 <database_menu+0xa3>
mov    -0x10(%rbp),%rdi
call   1030 <start_timetable@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1230 <database_menu+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    126a <database_menu+0xfa>
mov    -0x1c(%rbp),%eax
mov    0x2dae(%rip),%rcx
cmp    (%rcx),%eax
je     1254 <database_menu+0xe4>
mov    -0x18(%rbp),%eax
mov    0x2d9c(%rip),%rcx
cmp    (%rcx),%eax
jne    1265 <database_menu+0xf5>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    126a <database_menu+0xfa>
jmp    1183 <database_menu+0x13>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_menu>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2e66(%rip),%r15
lea    0xe77(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1090 <show_database_menu@plt>
mov    %eax,%ebp
cmp    $0x7,%eax
ja     11f2 <database_menu+0x82>
xor    %eax,%eax
mov    %ebp,%ecx
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    %r14,%rdi
call   1060 <start_teacher@plt>
jmp    11f0 <database_menu+0x80>
mov    %r14,%rdi
call   1040 <start_subject@plt>
jmp    11f0 <database_menu+0x80>
mov    %r14,%rdi
call   1070 <start_batch@plt>
jmp    11f0 <database_menu+0x80>
mov    %r14,%rdi
call   1050 <start_room@plt>
jmp    11f0 <database_menu+0x80>
mov    %r14,%rdi
call   1080 <start_alloc@plt>
jmp    11f0 <database_menu+0x80>
mov    %r14,%rdi
call   1030 <start_timetable@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ebx
mov    (%r15),%eax
cmp    %eax,%ebx
je     11fd <database_menu+0x8d>
cmp    %eax,%ebp
jne    1190 <database_menu+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @database_menu(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 6, i32* %4
br label %7
7: ; preds = %1, %61
%8 = load i8*, i8** %3
%9 = call i32 @show_database_menu(i8* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @start_teacher(i8* %13)
store i32 %14, i32* %6
br label %15
15: ; preds = %12, %7
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = call i32 @start_subject(i8* %19)
store i32 %20, i32* %6
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %3
%26 = call i32 @start_batch(i8* %25)
store i32 %26, i32* %6
br label %27
27: ; preds = %24, %21
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = call i32 @start_room(i8* %31)
store i32 %32, i32* %6
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %3
%38 = call i32 @start_alloc(i8* %37)
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 5
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i8*, i8** %3
%44 = call i32 @start_timetable(i8* %43)
store i32 %44, i32* %6
br label %45
45: ; preds = %42, %39
%46 = load i32, i32* %5
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
%49 = icmp eq i32 %46, %48
br i1 %49, label %50, label %51
50: ; preds = %45
store i32 0, i32* %2
br label %62
51: ; preds = %45
%52 = load i32, i32* %6
%53 = load i32, i32* @INT_MIN
%54 = icmp eq i32 %52, %53
br i1 %54, label %59, label %55
55: ; preds = %51
%56 = load i32, i32* %5
%57 = load i32, i32* @INT_MIN
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55, %51
%60 = load i32, i32* @INT_MIN
store i32 %60, i32* %2
br label %62
61: ; preds = %55
br label %7
62: ; preds = %59, %50
%63 = load i32, i32* %2
ret i32 %63
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @database_menu(i8* %0) {
br label %2
2: ; preds = %17, %1
%3 = phi i32 [ undef, %1 ], [ %18, %17 ]
%4 = tail call i32 @show_database_menu(i8* %0)
switch i32 %4, label %17 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
i32 7, label %23
]
5: ; preds = %2
%6 = tail call i32 @start_teacher(i8* %0)
br label %17
7: ; preds = %2
%8 = tail call i32 @start_subject(i8* %0)
br label %17
9: ; preds = %2
%10 = tail call i32 @start_batch(i8* %0)
br label %17
11: ; preds = %2
%12 = tail call i32 @start_room(i8* %0)
br label %17
13: ; preds = %2
%14 = tail call i32 @start_alloc(i8* %0)
br label %17
15: ; preds = %2
%16 = tail call i32 @start_timetable(i8* %0)
br label %17
17: ; preds = %2, %7, %5, %9, %11, %13, %15
%18 = phi i32 [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %6, %5 ], [ %8, %7 ], [ %3, %2 ]
%19 = load i32, i32* @INT_MIN
%20 = icmp eq i32 %18, %19
%21 = icmp eq i32 %4, %19
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %23, label %2
23: ; preds = %2, %17
%24 = phi i32 [ %19, %17 ], [ 0, %2 ]
ret i32 %24
}