#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 */
struct gamehandle {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ erase();
int getch();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ quit_game(struct gamehandle *);
int /*<<< orphan*/ refresh();
int menue(struct gamehandle *myrill) {
  int input, again = 1;
  erase();
  printw("(N)ew Game\n");
  printw("(L)oad Game\n");
  printw("(H)elp\n");
  printw("(Q)uit\n");
  printw("What do you want to do?");
  refresh();
  while (again) {
    input = getch();
    switch (input) {
    case 'n':
    case 'N':
      again = 0;
      return (1);
      break;
    case 'l':
    case 'L':
      again = 0;
      return (2);
      break;
    case 'h':
    case 'H':
      again = 0;
      return (3);
      break;
    case 'q':
    case 'Q':
      again = 0;
      quit_game(myrill);
      break;
    default:
      continue;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<menue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1030 <erase@plt>
lea    0xf37(%rip),%rdi
call   1050 <printw@plt>
lea    0xf37(%rip),%rdi
call   1050 <printw@plt>
lea    0xf38(%rip),%rdi
call   1050 <printw@plt>
lea    0xf34(%rip),%rdi
call   1050 <printw@plt>
lea    0xf30(%rip),%rdi
call   1050 <printw@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
cmpl   $0x0,-0x18(%rbp)
je     1242 <menue+0xf2>
xor    %eax,%eax
call   1070 <getch@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffb8,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x29,%eax
ja     1238 <menue+0xe8>
mov    -0x20(%rbp),%rax
lea    0xe1f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x4(%rbp)
jmp    1249 <menue+0xf9>
movl   $0x0,-0x18(%rbp)
movl   $0x2,-0x4(%rbp)
jmp    1249 <menue+0xf9>
movl   $0x0,-0x18(%rbp)
movl   $0x3,-0x4(%rbp)
jmp    1249 <menue+0xf9>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <quit_game@plt>
jmp    123d <menue+0xed>
jmp    11ad <menue+0x5d>
jmp    11ad <menue+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menue>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <erase@plt>
lea    0xf43(%rip),%rdi
call   1050 <printw@plt>
lea    0xf43(%rip),%rdi
call   1050 <printw@plt>
lea    0xf44(%rip),%rdi
call   1050 <printw@plt>
lea    0xf40(%rip),%rdi
call   1050 <printw@plt>
lea    0xf3c(%rip),%rdi
call   1050 <printw@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
lea    0xe58(%rip),%rbx
xor    %eax,%eax
call   1070 <getch@plt>
add    $0xffffffb8,%eax
cmp    $0x29,%eax
ja     11a8 <menue+0x58>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x3,%eax
jmp    11df <menue+0x8f>
mov    $0x1,%eax
jmp    11df <menue+0x8f>
mov    %r14,%rdi
call   1040 <quit_game@plt>
xor    %eax,%eax
jmp    11df <menue+0x8f>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.gamehandle = type { i32 }
@.str = [12 x i8] c"(N)ew Game\0A\00"
@.str.1 = [13 x i8] c"(L)oad Game\0A\00"
@.str.2 = [8 x i8] c"(H)elp\0A\00"
@.str.3 = [8 x i8] c"(Q)uit\0A\00"
@.str.4 = [24 x i8] c"What do you want to do?\00"
define i32 @menue(%struct.gamehandle* %0) {
%2 = alloca i32
%3 = alloca %struct.gamehandle*
%4 = alloca i32
%5 = alloca i32
store %struct.gamehandle* %0, %struct.gamehandle** %3
store i32 1, i32* %5
%6 = call i32 (...) @erase()
%7 = call i32 @printw(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printw(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (...) @refresh()
br label %13
13: ; preds = %26, %25, %1
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = call i32 (...) @getch()
store i32 %17, i32* %4
%18 = load i32, i32* %4
switch i32 %18, label %25 [
i32 110, label %19
i32 78, label %19
i32 108, label %20
i32 76, label %20
i32 104, label %21
i32 72, label %21
i32 113, label %22
i32 81, label %22
]
19: ; preds = %16, %16
store i32 0, i32* %5
store i32 1, i32* %2
br label %28
20: ; preds = %16, %16
store i32 0, i32* %5
store i32 2, i32* %2
br label %28
21: ; preds = %16, %16
store i32 0, i32* %5
store i32 3, i32* %2
br label %28
22: ; preds = %16, %16
store i32 0, i32* %5
%23 = load %struct.gamehandle*, %struct.gamehandle** %3
%24 = call i32 @quit_game(%struct.gamehandle* %23)
br label %26
25: ; preds = %16
br label %13
26: ; preds = %22
br label %13
27: ; preds = %13
store i32 0, i32* %2
br label %28
28: ; preds = %27, %21, %20, %19
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.gamehandle = type { i32 }
@.str = [12 x i8] c"(N)ew Game\0A\00"
@.str.1 = [13 x i8] c"(L)oad Game\0A\00"
@.str.2 = [8 x i8] c"(H)elp\0A\00"
@.str.3 = [8 x i8] c"(Q)uit\0A\00"
@.str.4 = [24 x i8] c"What do you want to do?\00"
define i32 @menue(%struct.gamehandle* %0) {
%2 = tail call i32 (...) @erase()
%3 = tail call i32 @printw(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printw(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @printw(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 (...) @refresh()
br label %9
9: ; preds = %9, %1
%10 = tail call i32 (...) @getch()
switch i32 %10, label %9 [
i32 110, label %13
i32 78, label %13
i32 108, label %14
i32 76, label %14
i32 104, label %15
i32 72, label %15
i32 113, label %11
i32 81, label %11
]
11: ; preds = %9, %9
%12 = tail call i32 @quit_game(%struct.gamehandle* %0)
br label %15
13: ; preds = %9, %9
br label %15
14: ; preds = %9, %9
br label %15
15: ; preds = %9, %9, %14, %13, %11
%16 = phi i32 [ 0, %11 ], [ 1, %13 ], [ 2, %14 ], [ 3, %9 ], [ 3, %9 ]
ret i32 %16
}