#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  int option = -1;
  bool valid = false;
  puts("\n\n Option | Description");
  puts("   1    | Las vegas Fountain");
  puts("   2    | RVndom Stroves");
  puts("   3    | Fast and Furious Speed Racing");
  puts("   4    | Crazy Binary Lights Counter");
  puts("   0    | Exit\n");
  while (!valid) {
    puts("Which option do you want? (type the number): \n");
    scanf("%d", &option);
    if (option >= 0 && option <= 4)
      valid = true;
    else
      puts("Wrong option! Try again\n");
  }
  return option;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
lea    0xf23(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1194 <menu+0x74>
jmp    11e1 <menu+0xc1>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf34(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jl     11d0 <menu+0xb0>
cmpl   $0x4,-0x4(%rbp)
jg     11d0 <menu+0xb0>
movl   $0x1,-0x8(%rbp)
jmp    11dc <menu+0xbc>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
jmp    117e <menu+0x5e>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf29(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf50(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x5,0x4(%rsp)
jb     11e2 <menu+0xc2>
lea    0xf3b(%rip),%r14
lea    0xf02(%rip),%r15
lea    0xf2a(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x4,0x4(%rsp)
ja     11c0 <menu+0xa0>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A\0A Option | Description\00"
@.str.1 = [29 x i8] c" 1 | Las vegas Fountain\00"
@.str.2 = [25 x i8] c" 2 | RVndom Stroves\00"
@.str.3 = [40 x i8] c" 3 | Fast and Furious Speed Racing\00"
@.str.4 = [38 x i8] c" 4 | Crazy Binary Lights Counter\00"
@.str.5 = [16 x i8] c" 0 | Exit\0A\00"
@.str.6 = [47 x i8] c"Which option do you want? (type the number): \0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [25 x i8] c"Wrong option! Try again\0A\00"
define i32 @menu() {
%1 = alloca i32
%2 = alloca i32
store i32 -1, i32* %1
store i32 0, i32* %2
%3 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %1
%20 = icmp sle i32 %19, 4
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %2
br label %24
22: ; preds = %18, %13
%23 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
br label %9
25: ; preds = %9
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0A\0A Option | Description\00"
@.str.1 = [29 x i8] c" 1 | Las vegas Fountain\00"
@.str.2 = [25 x i8] c" 2 | RVndom Stroves\00"
@.str.3 = [40 x i8] c" 3 | Fast and Furious Speed Racing\00"
@.str.4 = [38 x i8] c" 4 | Crazy Binary Lights Counter\00"
@.str.5 = [16 x i8] c" 0 | Exit\0A\00"
@.str.6 = [47 x i8] c"Which option do you want? (type the number): \0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [25 x i8] c"Wrong option! Try again\0A\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp ult i32 %11, 5
br i1 %12, label %19, label %13
13: ; preds = %0, %13
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = icmp ult i32 %17, 5
br i1 %18, label %19, label %13
19: ; preds = %13, %0
%20 = load i32, i32* %1
ret i32 %20
}