#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*/ clr_scr();
int /*<<< orphan*/ display_bootstrap_menu(char const **, char);
int /*<<< orphan*/ exit(int);
char getchar();
int /*<<< orphan*/ kbhit();
unsigned char bootstrap_menu(void) {
  const char *menu[3] = {"     Start game     ", "     Load game      ",
                         "       Exit         "};
  char current = 0, answer;
  do {
    display_bootstrap_menu(menu, current);
    while (!kbhit())
      ;
    if ((answer = getchar()) == 119)
      current = (current < 1) ? 2 : current - 1;
    else if (answer == 115)
      current = (current > 1) ? 0 : current + 1;
    else if (answer == 10) {
      clr_scr();
      if (current > 1 || current < 0)
        exit(-1);
      return current;
    }
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<bootstrap_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2ca1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c9b(%rip),%rax
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x21(%rbp)
lea    -0x20(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1060 <display_bootstrap_menu@plt>
mov    $0x0,%al
call   1030 <kbhit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a6 <bootstrap_menu+0x56>
jmp    11ab <bootstrap_menu+0x5b>
jmp    118a <bootstrap_menu+0x3a>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x22(%rbp)
movsbl %al,%eax
cmp    $0x77,%eax
jne    11f0 <bootstrap_menu+0xa0>
movsbl -0x21(%rbp),%eax
cmp    $0x1,%eax
jge    11db <bootstrap_menu+0x8b>
mov    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    11e5 <bootstrap_menu+0x95>
movsbl -0x21(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %al,-0x21(%rbp)
jmp    1276 <bootstrap_menu+0x126>
movsbl -0x22(%rbp),%eax
cmp    $0x73,%eax
jne    1229 <bootstrap_menu+0xd9>
movsbl -0x21(%rbp),%eax
cmp    $0x1,%eax
jle    1214 <bootstrap_menu+0xc4>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    121e <bootstrap_menu+0xce>
movsbl -0x21(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %al,-0x21(%rbp)
jmp    1271 <bootstrap_menu+0x121>
movsbl -0x22(%rbp),%eax
cmp    $0xa,%eax
jne    126c <bootstrap_menu+0x11c>
mov    $0x0,%al
call   1070 <clr_scr@plt>
movsbl -0x21(%rbp),%eax
cmp    $0x1,%eax
jg     1257 <bootstrap_menu+0x107>
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
jge    1261 <bootstrap_menu+0x111>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x21(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    128e <bootstrap_menu+0x13e>
jmp    1271 <bootstrap_menu+0x121>
jmp    1276 <bootstrap_menu+0x126>
jmp    127b <bootstrap_menu+0x12b>
mov    $0x1,%al
test   $0x1,%al
jne    117d <bootstrap_menu+0x2d>
jmp    128a <bootstrap_menu+0x13a>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bootstrap_menu>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2caf(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2c93(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %r15d,%r15d
mov    %rsp,%r14
mov    $0x2,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl %bl,%esi
mov    %r14,%rdi
call   1060 <display_bootstrap_menu@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <kbhit@plt>
test   %eax,%eax
je     1190 <bootstrap_menu+0x40>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     11ca <bootstrap_menu+0x7a>
cmp    $0x73,%al
je     11bb <bootstrap_menu+0x6b>
cmp    $0x77,%al
jne    1180 <bootstrap_menu+0x30>
lea    -0x1(%rbx),%eax
test   %bl,%bl
movzbl %al,%ebx
cmovle %ebp,%ebx
jmp    1180 <bootstrap_menu+0x30>
lea    0x1(%rbx),%eax
cmp    $0x2,%bl
movzbl %al,%ebx
cmovge %r15d,%ebx
jmp    1180 <bootstrap_menu+0x30>
xor    %eax,%eax
call   1070 <clr_scr@plt>
cmp    $0x2,%bl
jae    11e3 <bootstrap_menu+0x93>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c" Start game \00"
@.str.1 = [21 x i8] c" Load game \00"
@.str.2 = [21 x i8] c" Exit \00"
@__const.bootstrap_menu.menu = [3 x i8*] [i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0)]
define zeroext i8 @bootstrap_menu() {
%1 = alloca i8
%2 = alloca [3 x i8*]
%3 = alloca i8
%4 = alloca i8
%5 = bitcast [3 x i8*]* %2 to i8*
store i8 0, i8* %3
br label %6
6: ; preds = %67, %0
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%8 = load i8, i8* %3
%9 = call i32 @display_bootstrap_menu(i8** %7, i8 signext %8)
br label %10
10: ; preds = %14, %6
%11 = call i32 (...) @kbhit()
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = call signext i8 (...) @getchar()
store i8 %16, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 119
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %19
br label %28
24: ; preds = %19
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 1
br label %28
28: ; preds = %24, %23
%29 = phi i32 [ 2, %23 ], [ %27, %24 ]
%30 = trunc i32 %29 to i8
store i8 %30, i8* %3
br label %66
31: ; preds = %15
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 115
br i1 %34, label %35, label %47
35: ; preds = %31
%36 = load i8, i8* %3
%37 = sext i8 %36 to i32
%38 = icmp sgt i32 %37, 1
br i1 %38, label %39, label %40
39: ; preds = %35
br label %44
40: ; preds = %35
%41 = load i8, i8* %3
%42 = sext i8 %41 to i32
%43 = add nsw i32 %42, 1
br label %44
44: ; preds = %40, %39
%45 = phi i32 [ 0, %39 ], [ %43, %40 ]
%46 = trunc i32 %45 to i8
store i8 %46, i8* %3
br label %65
47: ; preds = %31
%48 = load i8, i8* %4
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %64
51: ; preds = %47
%52 = call i32 (...) @clr_scr()
%53 = load i8, i8* %3
%54 = sext i8 %53 to i32
%55 = icmp sgt i32 %54, 1
br i1 %55, label %60, label %56
56: ; preds = %51
%57 = load i8, i8* %3
%58 = sext i8 %57 to i32
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56, %51
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %56
%63 = load i8, i8* %3
store i8 %63, i8* %1
br label %69
64: ; preds = %47
br label %65
65: ; preds = %64, %44
br label %66
66: ; preds = %65, %28
br label %67
67: ; preds = %66
br i1 true, label %6, label %68
68: ; preds = %67
store i8 0, i8* %1
br label %69
69: ; preds = %68, %62
%70 = load i8, i8* %1
ret i8 %70
}

LLVM IR (-O2):
@.str = [21 x i8] c" Start game \00"
@.str.1 = [21 x i8] c" Load game \00"
@.str.2 = [21 x i8] c" Exit \00"
@__const.bootstrap_menu.menu = [3 x i8*] [i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0)]
define zeroext i8 @bootstrap_menu() {
%1 = alloca [3 x i8*]
%2 = bitcast [3 x i8*]* %1 to i8*
%3 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
br label %4
4: ; preds = %17, %0
%5 = phi i8 [ 0, %0 ], [ %18, %17 ]
br label %6
6: ; preds = %4, %11
%7 = call i32 @display_bootstrap_menu(i8** %3, i8 signext %5)
br label %8
8: ; preds = %8, %6
%9 = call i32 (...) @kbhit()
%10 = icmp eq i32 %9, 0
br i1 %10, label %8, label %11
11: ; preds = %8
%12 = call signext i8 (...) @getchar()
switch i8 %12, label %6 [
i8 119, label %13
i8 115, label %19
i8 10, label %23
]
13: ; preds = %11
%14 = icmp slt i8 %5, 1
%15 = add i8 %5, -1
%16 = select i1 %14, i8 2, i8 %15
br label %17
17: ; preds = %13, %19
%18 = phi i8 [ %22, %19 ], [ %16, %13 ]
br label %4
19: ; preds = %11
%20 = icmp sgt i8 %5, 1
%21 = add i8 %5, 1
%22 = select i1 %20, i8 0, i8 %21
br label %17
23: ; preds = %11
%24 = call i32 (...) @clr_scr()
%25 = icmp ugt i8 %5, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %23
ret i8 %5
}