#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 atoi(char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
menu_selected(void) {
  char s[80];
  int c;
  printf("1. Inserir um nome \n");
  printf("2. Excluir um nome \n");
  printf("3. Listar o arquivo \n");
  printf("4. Sair \n");
  do {
    printf("\nDigite sua escolha: ");
    gets(s);
    c = atoi(s);
  } while (c < 0 || c > 4);
  return c;
}


x86 assembly (clang, -O0):
<menu_selected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x50(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x54(%rbp)
mov    %al,-0x55(%rbp)
jl     11a2 <menu_selected+0x72>
cmpl   $0x4,-0x54(%rbp)
setg   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    1168 <menu_selected+0x38>
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_selected>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe82(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
cmp    $0x4,%eax
ja     1190 <menu_selected+0x50>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"1. Inserir um nome \0A\00"
@.str.1 = [21 x i8] c"2. Excluir um nome \0A\00"
@.str.2 = [22 x i8] c"3. Listar o arquivo \0A\00"
@.str.3 = [10 x i8] c"4. Sair \0A\00"
@.str.4 = [22 x i8] c"\0ADigite sua escolha: \00"
define i32 @menu_selected() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %19, %0
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %2
br label %13
13: ; preds = %7
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 4
br label %19
19: ; preds = %16, %13
%20 = phi i1 [ true, %13 ], [ %18, %16 ]
br i1 %20, label %7, label %21
21: ; preds = %19
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str.4 = [22 x i8] c"\0ADigite sua escolha: \00"
@str = [20 x i8] c"1. Inserir um nome \00"
@str.5 = [20 x i8] c"2. Excluir um nome \00"
@str.6 = [21 x i8] c"3. Listar o arquivo \00"
@str.7 = [9 x i8] c"4. Sair \00"
define i32 @menu_selected() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @gets(i8* %2)
%10 = call i32 @atoi(i8* %2)
%11 = icmp ugt i32 %10, 4
br i1 %11, label %7, label %12
12: ; preds = %7
ret i32 %10
}