#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 /*<<< orphan*/ system(char *);
int menu() {
  int menuSelect = 0;
  do {
    printf(" \n [01] - VOTAR ");
    printf(" \n [02] - RESULTADOS ");
    printf(" \n [03] - ENCERRAR ");
    printf(" \n\n SELECIONE UMA OPCAO :: ");
    scanf(" %d", &menuSelect);
    if (menuSelect < 1 || menuSelect > 3) {
      system("cls");
      printf("\n Opcao inexistente, tente mais uma vez:\n");
    }
  } while (menuSelect < 1 || menuSelect > 3);
  return menuSelect;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     1193 <menu+0x63>
cmpl   $0x3,-0x4(%rbp)
jle    11ab <menu+0x7b>
lea    0xec1(%rip),%rdi
call   1030 <system@plt>
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
jmp    11b0 <menu+0x80>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11c9 <menu+0x99>
cmpl   $0x3,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    113f <menu+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xecd(%rip),%r12
lea    0xeda(%rip),%r13
lea    0xeef(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xee7(%rip),%r14
lea    0xee4(%rip),%r15
nopl   0x0(%rax,%rax,1)
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7e(%rip),%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffc,%ecx
ja     11db <menu+0x9b>
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     1180 <menu+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c" \0A [01] - VOTAR \00"
@.str.1 = [22 x i8] c" \0A [02] - RESULTADOS \00"
@.str.2 = [20 x i8] c" \0A [03] - ENCERRAR \00"
@.str.3 = [28 x i8] c" \0A\0A SELECIONE UMA OPCAO :: \00"
@.str.4 = [4 x i8] c" %d\00"
@.str.5 = [4 x i8] c"cls\00"
@.str.6 = [42 x i8] c"\0A Opcao inexistente, tente mais uma vez:\0A\00"
define i32 @menu() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %23, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %10, %2
%14 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %16
16: ; preds = %13, %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 3
br label %23
23: ; preds = %20, %17
%24 = phi i1 [ true, %17 ], [ %22, %20 ]
br i1 %24, label %2, label %25
25: ; preds = %23
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [17 x i8] c" \0A [01] - VOTAR \00"
@.str.1 = [22 x i8] c" \0A [02] - RESULTADOS \00"
@.str.2 = [20 x i8] c" \0A [03] - ENCERRAR \00"
@.str.3 = [28 x i8] c" \0A\0A SELECIONE UMA OPCAO :: \00"
@.str.4 = [4 x i8] c" %d\00"
@.str.5 = [4 x i8] c"cls\00"
@str = [41 x i8] c"\0A Opcao inexistente, tente mais uma vez:\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %12, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -4
%11 = icmp ult i32 %10, -3
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = add i32 %15, -4
%17 = icmp ult i32 %16, -3
br i1 %17, label %3, label %18
18: ; preds = %3, %12
%19 = phi i32 [ %15, %12 ], [ %9, %3 ]
ret i32 %19
}