#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*/ room_form(char *);
int room_menu(char *);
int room_number(char *);
int show_room_info(char *, int);
int start_room(char *database) {
  int choice, n, sub_choice;
  while (1) {
    choice = room_menu(database);
    n = room_number(database);
    if (choice == n + 1)
      break;
    else if (choice == n + 2)
      room_form(database);
    else if (choice == INT_MIN)
      return INT_MIN;
    else if (choice == -1)
      continue;
    else {
      while (1) {
        sub_choice = show_room_info(database, choice);
        if (sub_choice == 1)
          break;
        if (sub_choice == INT_MIN)
          return INT_MIN;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<start_room>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <room_menu@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <room_number@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    117a <start_room+0x3a>
jmp    122f <start_room+0xef>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jne    1199 <start_room+0x59>
mov    -0x10(%rbp),%rdi
call   1050 <room_form@plt>
jmp    1225 <start_room+0xe5>
mov    -0x14(%rbp),%eax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%eax
jne    11bc <start_room+0x7c>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <start_room+0xf6>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11cb <start_room+0x8b>
jmp    114c <start_room+0xc>
jmp    11d0 <start_room+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <show_room_info@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11ee <start_room+0xae>
jmp    1216 <start_room+0xd6>
mov    -0x1c(%rbp),%eax
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
jne    1211 <start_room+0xd1>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <start_room+0xf6>
jmp    11d0 <start_room+0x90>
jmp    121b <start_room+0xdb>
jmp    1220 <start_room+0xe0>
jmp    1225 <start_room+0xe5>
jmp    122a <start_room+0xea>
jmp    114c <start_room+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_room>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <room_menu@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <room_number@plt>
lea    0x1(%rax),%ecx
cmp    %ecx,%ebp
jne    1161 <start_room+0x21>
xor    %eax,%eax
jmp    11c4 <start_room+0x84>
mov    0x2e80(%rip),%r14
jmp    1193 <start_room+0x53>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <room_form@plt>
mov    %rbx,%rdi
call   1030 <room_menu@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <room_number@plt>
mov    %eax,%ecx
add    $0x1,%ecx
cmp    %ecx,%ebp
je     115d <start_room+0x1d>
add    $0x2,%eax
cmp    %eax,%ebp
je     1170 <start_room+0x30>
cmp    (%r14),%ebp
je     11c9 <start_room+0x89>
cmp    $0xffffffff,%ebp
je     1178 <start_room+0x38>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <show_room_info@plt>
cmp    $0x1,%eax
je     1178 <start_room+0x38>
cmp    (%r14),%eax
jne    11b0 <start_room+0x70>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebp,%eax
jmp    11c4 <start_room+0x84>

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @start_room(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, %54
%8 = load i8*, i8** %3
%9 = call i32 @room_menu(i8* %8)
store i32 %9, i32* %4
%10 = load i8*, i8** %3
%11 = call i32 @room_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 %55
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 @room_form(i8* %23)
br label %53
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 %56
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, %49
%37 = load i8*, i8** %3
%38 = load i32, i32* %4
%39 = call i32 @show_room_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 %50
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 %56
49: ; preds = %43
br label %36
50: ; preds = %42
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52, %22
br label %54
54: ; preds = %53
br label %7
55: ; preds = %16
store i32 0, i32* %2
br label %56
56: ; preds = %55, %47, %29
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @start_room(i8* %0) {
%2 = tail call i32 @room_menu(i8* %0)
%3 = tail call i32 @room_number(i8* %0)
%4 = add nsw i32 %3, 1
%5 = icmp eq i32 %2, %4
br i1 %5, label %29, label %6
6: ; preds = %1, %24
%7 = phi i32 [ %26, %24 ], [ %3, %1 ]
%8 = phi i32 [ %25, %24 ], [ %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 @room_form(i8* %0)
br label %24
13: ; preds = %6
%14 = load i32, i32* @INT_MIN
%15 = icmp eq i32 %8, %14
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = icmp eq i32 %8, -1
br i1 %17, label %24, label %18
18: ; preds = %16, %21
%19 = tail call i32 @show_room_info(i8* %0, i32 %8)
%20 = icmp eq i32 %19, 1
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* @INT_MIN
%23 = icmp eq i32 %19, %22
br i1 %23, label %29, label %18
24: ; preds = %18, %11, %16
%25 = tail call i32 @room_menu(i8* %0)
%26 = tail call i32 @room_number(i8* %0)
%27 = add nsw i32 %26, 1
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %6
29: ; preds = %13, %24, %21, %1
%30 = phi i32 [ 0, %1 ], [ %19, %21 ], [ %8, %13 ], [ 0, %24 ]
ret i32 %30
}