#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*/ clear();
int getch();
int /*<<< orphan*/ play();
int /*<<< orphan*/ printw(char *, char *);
int /*<<< orphan*/ ranking();
int /*<<< orphan*/ rules();
int /*<<< orphan*/ selectlevel();
void menu() {
  while (1) {
    clear();
    printw("~~~ ICE PATH ~~~\n\n"
           "[1] Play\n"
           "[2] Select level\n"
           "[3] Ranking\n"
           "[5] Rules\n"
           "[q] Quit\n\nv%s\n\n",
           "0.20");
    switch (getch()) {
    case 'q':
      return;
    case '1':
      play();
      break;
    case '2':
      selectlevel();
      break;
    case '3':
      ranking();
      break;
    case '5':
      rules();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
jmp    117d <menu+0xd>
xor    %eax,%eax
mov    %al,-0x5(%rbp)
call   1090 <clear@plt>
lea    0xe72(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1050 <printw@plt>
mov    -0x5(%rbp),%al
call   1070 <getch@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
sub    $0x31,%eax
je     11ff <menu+0x8f>
jmp    11b5 <menu+0x45>
mov    -0x4(%rbp),%eax
sub    $0x32,%eax
je     120b <menu+0x9b>
jmp    11c6 <menu+0x56>
mov    -0x4(%rbp),%eax
sub    $0x33,%eax
je     1217 <menu+0xa7>
jmp    11d7 <menu+0x67>
mov    -0x4(%rbp),%eax
sub    $0x35,%eax
je     1223 <menu+0xb3>
jmp    11e8 <menu+0x78>
mov    -0x4(%rbp),%eax
sub    $0x71,%eax
jne    122a <menu+0xba>
jmp    11f9 <menu+0x89>
add    $0x10,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1040 <play@plt>
jmp    122a <menu+0xba>
mov    $0x0,%al
call   1080 <selectlevel@plt>
jmp    122a <menu+0xba>
mov    $0x0,%al
call   1030 <ranking@plt>
jmp    122a <menu+0xba>
mov    $0x0,%al
call   1060 <rules@plt>
jmp    117d <menu+0xd>

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %rbx
lea    0xe98(%rip),%r14
lea    0xee3(%rip),%r15
lea    0xe76(%rip),%rbx
jmp    11a0 <menu+0x30>
xor    %eax,%eax
call   1060 <rules@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1090 <clear@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <printw@plt>
xor    %eax,%eax
call   1070 <getch@plt>
lea    -0x31(%rax),%ecx
cmp    $0x4,%ecx
ja     11e5 <menu+0x75>
movslq (%rbx,%rcx,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <play@plt>
jmp    11a0 <menu+0x30>
xor    %eax,%eax
call   1080 <selectlevel@plt>
jmp    11a0 <menu+0x30>
xor    %eax,%eax
call   1030 <ranking@plt>
jmp    11a0 <menu+0x30>
cmp    $0x71,%eax
jne    11a0 <menu+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [82 x i8] c"~~~ ICE PATH ~~~\0A\0A[1] Play\0A[2] Select level\0A[3] Ranking\0A[5] Rules\0A[q] Quit\0A\0Av%s\0A\0A\00"
@.str.1 = [5 x i8] c"0.20\00"
define void @menu() {
br label %1
1: ; preds = %0, %14
%2 = call i32 (...) @clear()
%3 = call i32 @printw(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (...) @getch()
switch i32 %4, label %14 [
i32 113, label %5
i32 49, label %6
i32 50, label %8
i32 51, label %10
i32 53, label %12
]
5: ; preds = %1
ret void
6: ; preds = %1
%7 = call i32 (...) @play()
br label %14
8: ; preds = %1
%9 = call i32 (...) @selectlevel()
br label %14
10: ; preds = %1
%11 = call i32 (...) @ranking()
br label %14
12: ; preds = %1
%13 = call i32 (...) @rules()
br label %14
14: ; preds = %1, %12, %10, %8, %6
br label %1
}

LLVM IR (-O2):
@.str = [82 x i8] c"~~~ ICE PATH ~~~\0A\0A[1] Play\0A[2] Select level\0A[3] Ranking\0A[5] Rules\0A[q] Quit\0A\0Av%s\0A\0A\00"
@.str.1 = [5 x i8] c"0.20\00"
define void @menu() {
br label %1
1: ; preds = %5, %0
%2 = tail call i32 (...) @clear()
%3 = tail call i32 @printw(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (...) @getch()
switch i32 %4, label %5 [
i32 113, label %6
i32 49, label %7
i32 50, label %9
i32 51, label %11
i32 53, label %13
]
5: ; preds = %1, %13, %11, %9, %7
br label %1
6: ; preds = %1
ret void
7: ; preds = %1
%8 = tail call i32 (...) @play()
br label %5
9: ; preds = %1
%10 = tail call i32 (...) @selectlevel()
br label %5
11: ; preds = %1
%12 = tail call i32 (...) @ranking()
br label %5
13: ; preds = %1
%14 = tail call i32 (...) @rules()
br label %5
}