#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*/ doPlay();
int /*<<< orphan*/ doRegister();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ readn(char *, int);
void menu() {
  while (1) {
    puts("[1] Register");
    puts("[2] Play");
    puts("[3] Exit");
    char minibuf[3];
    minibuf[0] = 0;
    readn(minibuf, 3);
    switch (minibuf[0]) {
    case '1':
      doRegister();
      break;
    case '2':
      doPlay();
      break;
    case '3':
      exit(0);
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,-0x3(%rbp)
lea    -0x3(%rbp),%rdi
mov    $0x3,%esi
call   1060 <readn@plt>
movsbl -0x3(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x31,%eax
je     11c5 <menu+0x75>
jmp    11a3 <menu+0x53>
mov    -0x8(%rbp),%eax
sub    $0x32,%eax
je     11d1 <menu+0x81>
jmp    11b4 <menu+0x64>
mov    -0x8(%rbp),%eax
sub    $0x33,%eax
je     11dd <menu+0x8d>
jmp    11e4 <menu+0x94>
mov    $0x0,%al
call   1040 <doRegister@plt>
jmp    11e9 <menu+0x99>
mov    $0x0,%al
call   1050 <doPlay@plt>
jmp    11e9 <menu+0x99>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    11e9 <menu+0x99>
jmp    1158 <menu+0x8>

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%r14
lea    0xea7(%rip),%r15
lea    0xea9(%rip),%r12
lea    0x5(%rsp),%rbx
jmp    1187 <menu+0x37>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <doPlay@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
movb   $0x0,0x5(%rsp)
mov    %rbx,%rdi
mov    $0x3,%esi
call   1060 <readn@plt>
movsbl 0x5(%rsp),%eax
cmp    $0x31,%eax
je     11d0 <menu+0x80>
cmp    $0x32,%eax
je     1180 <menu+0x30>
cmp    $0x33,%eax
jne    1187 <menu+0x37>
jmp    11d9 <menu+0x89>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <doRegister@plt>
jmp    1187 <menu+0x37>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"[1] Register\00"
@.str.1 = [9 x i8] c"[2] Play\00"
@.str.2 = [9 x i8] c"[3] Exit\00"
define void @menu() {
%1 = alloca [3 x i8]
br label %2
2: ; preds = %0, %19
%3 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
store i8 0, i8* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%8 = call i32 @readn(i8* %7, i32 3)
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %18 [
i32 49, label %12
i32 50, label %14
i32 51, label %16
]
12: ; preds = %2
%13 = call i32 (...) @doRegister()
br label %19
14: ; preds = %2
%15 = call i32 (...) @doPlay()
br label %19
16: ; preds = %2
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
br label %19
19: ; preds = %18, %14, %12
br label %2
}

LLVM IR (-O2):
@.str = [13 x i8] c"[1] Register\00"
@.str.1 = [9 x i8] c"[2] Play\00"
@.str.2 = [9 x i8] c"[3] Exit\00"
define void @menu() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %16
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i8 0, i8* %2
%7 = call i32 @readn(i8* %2, i32 3)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
switch i32 %9, label %16 [
i32 49, label %10
i32 50, label %12
i32 51, label %14
]
10: ; preds = %3
%11 = call i32 (...) @doRegister()
br label %16
12: ; preds = %3
%13 = call i32 (...) @doPlay()
br label %16
14: ; preds = %3
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %3, %12, %10
br label %3
}