#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*/ flushin();
int /*<<< orphan*/ header();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ txt_ctrd(char *, char);
int menu() {
  header();
  txt_ctrd("1. 1 player", '\n');
  txt_ctrd("2. 2 players", '\n');
  txt_ctrd("0. Quit", '\n');
  printf("\n");
  int choice;
  do {
    txt_ctrd("Your choice : ", ' ');
    scanf("%d", &choice);
    flushin();
  } while (choice < 0 || choice > 2);
  return choice;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <header@plt>
lea    0xe9a(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
lea    0xe95(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
lea    0xe91(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x20,%esi
call   1050 <txt_ctrd@plt>
lea    0xe7c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <flushin@plt>
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11df <menu+0x8f>
cmpl   $0x2,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    119e <menu+0x4e>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <header@plt>
lea    0xe99(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
lea    0xe94(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
lea    0xe90(%rip),%rdi
mov    $0xa,%esi
call   1050 <txt_ctrd@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe7d(%rip),%r14
lea    0xe85(%rip),%r15
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <txt_ctrd@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <flushin@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
ja     11b0 <menu+0x60>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"1. 1 player\00"
@.str.1 = [13 x i8] c"2. 2 players\00"
@.str.2 = [8 x i8] c"0. Quit\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [15 x i8] c"Your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
%2 = call i32 (...) @header()
%3 = call i32 @txt_ctrd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext 10)
%4 = call i32 @txt_ctrd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext 10)
%5 = call i32 @txt_ctrd(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8 signext 10)
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %17, %0
%8 = call i32 @txt_ctrd(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8 signext 32)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%10 = call i32 (...) @flushin()
br label %11
11: ; preds = %7
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 2
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %7, label %19
19: ; preds = %17
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [12 x i8] c"1. 1 player\00"
@.str.1 = [13 x i8] c"2. 2 players\00"
@.str.2 = [8 x i8] c"0. Quit\00"
@.str.4 = [15 x i8] c"Your choice : \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
%2 = tail call i32 (...) @header()
%3 = tail call i32 @txt_ctrd(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext 10)
%4 = tail call i32 @txt_ctrd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext 10)
%5 = tail call i32 @txt_ctrd(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8 signext 10)
%6 = tail call i32 @putchar(i32 10)
%7 = bitcast i32* %1 to i8*
br label %8
8: ; preds = %8, %0
%9 = call i32 @txt_ctrd(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8 signext 32)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%11 = call i32 (...) @flushin()
%12 = load i32, i32* %1
%13 = icmp ugt i32 %12, 2
br i1 %13, label %8, label %14
14: ; preds = %8
ret i32 %12
}