#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*/ add();
int /*<<< orphan*/ busca();
int /*<<< orphan*/ exibe();
int /*<<< orphan*/ gera();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ system(char *);
void menu(void) {
  char op;
  do {
    printf("\nMenu de opcoes:\n");
    printf("------------------------------\n");
    printf("1 - Gerar arquivo\n");
    printf("2 - Exibir o arquivo\n");
    printf("3 - Buscar um codigo no arquivo\n");
    printf("4 - Adiciona ao arquivo\n");
    printf("5 - Sair do programa\n");
    printf("Entre com o codigo da opcao: ");
    scanf("%d", &op);
    system("cls");
  } while (op < 1 || op > 5);
  if (op == 1) {
    gera();
  }
  if (op == 2) {
    exibe();
  }
  if (op == 3) {
    busca();
  }
  if (op == 4) {
    add();
  }
  puts("\nEncerrando...");
  system("pause>NULL");
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe71(%rip),%rdi
call   1070 <printf@plt>
lea    0xe77(%rip),%rdi
call   1070 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1070 <printf@plt>
lea    0xe92(%rip),%rdi
call   1070 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1070 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1070 <printf@plt>
lea    0xebe(%rip),%rdi
call   1070 <printf@plt>
lea    0xec8(%rip),%rdi
call   1070 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xecd(%rip),%rdi
call   1060 <system@plt>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x2(%rbp)
jl     1223 <menu+0xa3>
movsbl -0x1(%rbp),%eax
cmp    $0x5,%eax
setg   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1188 <menu+0x8>
movsbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1242 <menu+0xc2>
mov    $0x0,%al
call   10a0 <gera@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    1256 <menu+0xd6>
mov    $0x0,%al
call   1030 <exibe@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    126a <menu+0xea>
mov    $0x0,%al
call   1080 <busca@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x4,%eax
jne    127e <menu+0xfe>
mov    $0x0,%al
call   1040 <add@plt>
lea    0xe4b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4e(%rip),%rdi
call   1060 <system@plt>
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
lea    0xf24(%rip),%rbp
lea    0xf35(%rip),%r14
lea    0xe60(%rip),%r15
lea    0xe77(%rip),%r12
lea    0x7(%rsp),%r13
lea    0xe6e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe78(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1050 <puts@plt>
lea    0xe90(%rip),%rdi
call   1050 <puts@plt>
lea    0xe96(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
movzbl 0x7(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfb,%cl
jb     11c0 <menu+0x40>
cmp    $0x1,%al
je     1272 <menu+0xf2>
cmp    $0x2,%al
je     1281 <menu+0x101>
cmp    $0x3,%al
je     1290 <menu+0x110>
cmp    $0x4,%al
jne    124b <menu+0xcb>
xor    %eax,%eax
call   1040 <add@plt>
lea    0xdd3(%rip),%rdi
call   1050 <puts@plt>
lea    0xdd6(%rip),%rdi
call   1060 <system@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10a0 <gera@plt>
mov    0x7(%rsp),%al
cmp    $0x2,%al
jne    123c <menu+0xbc>
xor    %eax,%eax
call   1030 <exibe@plt>
mov    0x7(%rsp),%al
cmp    $0x3,%al
jne    1240 <menu+0xc0>
xor    %eax,%eax
call   1080 <busca@plt>
mov    0x7(%rsp),%al
cmp    $0x4,%al
je     1244 <menu+0xc4>
jmp    124b <menu+0xcb>

LLVM IR (-O0):
@.str = [18 x i8] c"\0AMenu de opcoes:\0A\00"
@.str.1 = [32 x i8] c"------------------------------\0A\00"
@.str.2 = [19 x i8] c"1 - Gerar arquivo\0A\00"
@.str.3 = [22 x i8] c"2 - Exibir o arquivo\0A\00"
@.str.4 = [33 x i8] c"3 - Buscar um codigo no arquivo\0A\00"
@.str.5 = [25 x i8] c"4 - Adiciona ao arquivo\0A\00"
@.str.6 = [22 x i8] c"5 - Sair do programa\0A\00"
@.str.7 = [30 x i8] c"Entre com o codigo da opcao: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [4 x i8] c"cls\00"
@.str.10 = [15 x i8] c"\0AEncerrando...\00"
@.str.11 = [11 x i8] c"pause>NULL\00"
define void @menu() {
%1 = alloca i8
br label %2
2: ; preds = %21, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %1)
%12 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
br label %13
13: ; preds = %2
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
%16 = icmp slt i32 %15, 1
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8, i8* %1
%19 = sext i8 %18 to i32
%20 = icmp sgt i32 %19, 5
br label %21
21: ; preds = %17, %13
%22 = phi i1 [ true, %13 ], [ %20, %17 ]
br i1 %22, label %2, label %23
23: ; preds = %21
%24 = load i8, i8* %1
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @gera()
br label %29
29: ; preds = %27, %23
%30 = load i8, i8* %1
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 (...) @exibe()
br label %35
35: ; preds = %33, %29
%36 = load i8, i8* %1
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (...) @busca()
br label %41
41: ; preds = %39, %35
%42 = load i8, i8* %1
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 4
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (...) @add()
br label %47
47: ; preds = %45, %41
%48 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%49 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.7 = [30 x i8] c"Entre com o codigo da opcao: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [4 x i8] c"cls\00"
@.str.10 = [15 x i8] c"\0AEncerrando...\00"
@.str.11 = [11 x i8] c"pause>NULL\00"
@str = [17 x i8] c"\0AMenu de opcoes:\00"
@str.12 = [31 x i8] c"------------------------------\00"
@str.13 = [18 x i8] c"1 - Gerar arquivo\00"
@str.14 = [21 x i8] c"2 - Exibir o arquivo\00"
@str.15 = [32 x i8] c"3 - Buscar um codigo no arquivo\00"
@str.16 = [24 x i8] c"4 - Adiciona ao arquivo\00"
@str.17 = [21 x i8] c"5 - Sair do programa\00"
define void @menu() {
%1 = alloca i8
br label %2
2: ; preds = %2, %0
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.15, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.17, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %1)
%12 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%13 = load i8, i8* %1
%14 = add i8 %13, -6
%15 = icmp ult i8 %14, -5
br i1 %15, label %2, label %16
16: ; preds = %2
%17 = icmp eq i8 %13, 1
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = call i32 (...) @gera()
%20 = load i8, i8* %1
br label %21
21: ; preds = %18, %16
%22 = phi i8 [ %20, %18 ], [ %13, %16 ]
%23 = icmp eq i8 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 (...) @exibe()
%26 = load i8, i8* %1
br label %27
27: ; preds = %24, %21
%28 = phi i8 [ %26, %24 ], [ %22, %21 ]
%29 = icmp eq i8 %28, 3
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = call i32 (...) @busca()
%32 = load i8, i8* %1
br label %33
33: ; preds = %30, %27
%34 = phi i8 [ %32, %30 ], [ %28, %27 ]
%35 = icmp eq i8 %34, 4
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (...) @add()
br label %38
38: ; preds = %36, %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
%40 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
ret void
}