#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 /*<<< orphan*/ alloc_form_teacher(char *, int);
int show_teacher_info(char *, int);
int /*<<< orphan*/ teacher_form(char *);
int teacher_menu(char *);
int teacher_number(char *);
int start_teacher(char *database) {
  int choice, n, sub_choice;
  while (1) {
    choice = teacher_menu(database);
    n = teacher_number(database);
    if (choice == n + 1)
      break;
    else if (choice == n + 2)
      teacher_form(database);
    else if (choice == INT_MIN)
      return INT_MIN;
    else if (choice == -1)
      continue;
    else {
      while (1) {
        sub_choice = show_teacher_info(database, choice);
        if (sub_choice == 1)
          break;
        if (sub_choice == INT_MIN)
          return INT_MIN;
        if (sub_choice == 2)
          alloc_form_teacher(database, choice);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<start_teacher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <teacher_menu@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <teacher_number@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    118a <start_teacher+0x3a>
jmp    1255 <start_teacher+0x105>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jne    11a9 <start_teacher+0x59>
mov    -0x10(%rbp),%rdi
call   1070 <teacher_form@plt>
jmp    124b <start_teacher+0xfb>
mov    -0x14(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
jne    11cc <start_teacher+0x7c>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125c <start_teacher+0x10c>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11db <start_teacher+0x8b>
jmp    115c <start_teacher+0xc>
jmp    11e0 <start_teacher+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <show_teacher_info@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11fe <start_teacher+0xae>
jmp    123c <start_teacher+0xec>
mov    -0x1c(%rbp),%eax
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
jne    1221 <start_teacher+0xd1>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125c <start_teacher+0x10c>
cmpl   $0x2,-0x1c(%rbp)
jne    1237 <start_teacher+0xe7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <alloc_form_teacher@plt>
jmp    11e0 <start_teacher+0x90>
jmp    1241 <start_teacher+0xf1>
jmp    1246 <start_teacher+0xf6>
jmp    124b <start_teacher+0xfb>
jmp    1250 <start_teacher+0x100>
jmp    115c <start_teacher+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_teacher>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <teacher_menu@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <teacher_number@plt>
lea    0x1(%rax),%ecx
xor    %r14d,%r14d
cmp    %ecx,%ebp
je     11e8 <start_teacher+0x98>
mov    0x2e6e(%rip),%r15
jmp    11a3 <start_teacher+0x53>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <teacher_form@plt>
mov    %rbx,%rdi
call   1030 <teacher_menu@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <teacher_number@plt>
mov    %eax,%ecx
add    $0x1,%ecx
cmp    %ecx,%ebp
je     11e8 <start_teacher+0x98>
add    $0x2,%eax
cmp    %eax,%ebp
je     1180 <start_teacher+0x30>
cmp    (%r15),%ebp
je     11f6 <start_teacher+0xa6>
cmp    $0xffffffff,%ebp
je     1188 <start_teacher+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <show_teacher_info@plt>
cmp    $0x1,%eax
je     1188 <start_teacher+0x38>
cmp    (%r15),%eax
je     11e5 <start_teacher+0x95>
cmp    $0x2,%eax
jne    11c0 <start_teacher+0x70>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <alloc_form_teacher@plt>
jmp    11c0 <start_teacher+0x70>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%r14d
jmp    11e8 <start_teacher+0x98>

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

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @start_teacher(i8* %0) {
%2 = tail call i32 @teacher_menu(i8* %0)
%3 = tail call i32 @teacher_number(i8* %0)
%4 = add nsw i32 %3, 1
%5 = icmp eq i32 %2, %4
br i1 %5, label %37, label %6
6: ; preds = %1, %32
%7 = phi i32 [ %34, %32 ], [ %3, %1 ]
%8 = phi i32 [ %33, %32 ], [ %2, %1 ]
%9 = add nsw i32 %7, 2
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @teacher_form(i8* %0)
br label %32
13: ; preds = %6
%14 = load i32, i32* @INT_MIN
%15 = icmp eq i32 %8, %14
br i1 %15, label %37, label %16
16: ; preds = %13
%17 = icmp eq i32 %8, -1
br i1 %17, label %32, label %18
18: ; preds = %16
%19 = tail call i32 @show_teacher_info(i8* %0, i32 %8)
%20 = icmp eq i32 %19, 1
br i1 %20, label %32, label %21
21: ; preds = %18, %29
%22 = phi i32 [ %30, %29 ], [ %19, %18 ]
%23 = load i32, i32* @INT_MIN
%24 = icmp eq i32 %22, %23
br i1 %24, label %37, label %25
25: ; preds = %21
%26 = icmp eq i32 %22, 2
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = tail call i32 @alloc_form_teacher(i8* %0, i32 %8)
br label %29
29: ; preds = %27, %25
%30 = tail call i32 @show_teacher_info(i8* %0, i32 %8)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %21
32: ; preds = %29, %11, %18, %16
%33 = tail call i32 @teacher_menu(i8* %0)
%34 = tail call i32 @teacher_number(i8* %0)
%35 = add nsw i32 %34, 1
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %6
37: ; preds = %13, %32, %21, %1
%38 = phi i32 [ 0, %1 ], [ %22, %21 ], [ %8, %13 ], [ 0, %32 ]
ret i32 %38
}