#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 timetable_menu(char *);
int start_timetable(char *database) {
  int choice, n = 4;
  while (1) {
    choice = timetable_menu(database);
    if (choice == n + 1)
      break;
    else if (choice == INT_MIN)
      return INT_MIN;
    else if (choice == -1)
      continue;
  }
  return 0;
}


x86 assembly (clang, -O0):
<start_timetable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x4,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <timetable_menu@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1145 <start_timetable+0x35>
jmp    1186 <start_timetable+0x76>
mov    -0x14(%rbp),%eax
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%eax
jne    1168 <start_timetable+0x58>
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118d <start_timetable+0x7d>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1177 <start_timetable+0x67>
jmp    1123 <start_timetable+0x13>
jmp    117c <start_timetable+0x6c>
jmp    1181 <start_timetable+0x71>
jmp    1123 <start_timetable+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_timetable>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eca(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <timetable_menu@plt>
cmp    $0x5,%eax
je     1134 <start_timetable+0x24>
cmp    (%r14),%eax
jne    1120 <start_timetable+0x10>
jmp    1136 <start_timetable+0x26>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @start_timetable(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 4, i32* %5
br label %6
6: ; preds = %1, %23, %26
%7 = load i8*, i8** %3
%8 = call i32 @timetable_menu(i8* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 1
%12 = icmp eq i32 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %6
br label %27
14: ; preds = %6
%15 = load i32, i32* %4
%16 = load i32, i32* @INT_MIN
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* @INT_MIN
store i32 %19, i32* %2
br label %28
20: ; preds = %14
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %20
br label %6
24: ; preds = %20
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
br label %6
27: ; preds = %13
store i32 0, i32* %2
br label %28
28: ; preds = %27, %18
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @start_timetable(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = tail call i32 @timetable_menu(i8* %0)
%4 = icmp eq i32 %3, 5
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @INT_MIN
%7 = icmp eq i32 %3, %6
br i1 %7, label %8, label %2
8: ; preds = %2, %5
%9 = phi i32 [ %3, %5 ], [ 0, %2 ]
ret i32 %9
}