#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  printf("[1] Iniciar juego\n");
  printf("[2] Salir\n");
  int n;
  do {
    printf("Opcion: ");
    scanf("%d", &n);
  } while (n < 1 || n > 2);
  printf("\n");
  return n;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1175 <menu+0x55>
cmpl   $0x2,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1140 <menu+0x20>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe98(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffffd,%eax
cmp    $0xfffffffe,%eax
jb     1180 <menu+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.2 = [9 x i8] c"Opcion: \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [18 x i8] c"[1] Iniciar juego\00"
@str.5 = [10 x i8] c"[2] Salir\00"
define i32 @menu() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
br label %5
5: ; preds = %5, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -3
%10 = icmp ult i32 %9, -2
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = call i32 @putchar(i32 10)
%13 = load i32, i32* %1
ret i32 %13
}