#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*/ carrega_entidadeGeral(char *);
int /*<<< orphan*/ changeEntity(char *);
int /*<<< orphan*/ mostraIndex(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ readFiles(char *);
int /*<<< orphan*/ removeEntity(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ writeEntity(char *);
void menuCRUD(char *nome) {
  int opc;
  carrega_entidadeGeral(nome);
  puts("\t\tMENU CRUD\t\t\n");
  puts("1- Inserir um novo elemento\n");
  puts("2- Mostrar todos os elementos da entidade\n");
  puts("3- Alterar um elemento\n");
  puts("4- Remover um elemento\n");
  puts("5- Mostrar indices ordenados\n");
  puts("0- Sair");
  printf(":>> ");
  scanf("%i", &opc);
  if (opc == 1) {
    writeEntity(nome);
  } else if (opc == 2) {
    readFiles(nome);
  } else if (opc == 3) {
    changeEntity(nome);
  } else if (opc == 4) {
    removeEntity(nome);
  } else if (opc == 5) {
    mostraIndex(nome);
  } else if (opc == 0)
    return;
  else {
    puts("Opcao Invalida!\n");
  }
}


x86 assembly (clang, -O0):
<menuCRUD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <carrega_entidadeGeral@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    122d <menuCRUD+0x9d>
mov    -0x8(%rbp),%rdi
call   10b0 <writeEntity@plt>
jmp    12c1 <menuCRUD+0x131>
cmpl   $0x2,-0xc(%rbp)
jne    1245 <menuCRUD+0xb5>
mov    -0x8(%rbp),%rdi
call   1040 <readFiles@plt>
jmp    12bc <menuCRUD+0x12c>
cmpl   $0x3,-0xc(%rbp)
jne    125d <menuCRUD+0xcd>
mov    -0x8(%rbp),%rdi
call   1060 <changeEntity@plt>
jmp    12b7 <menuCRUD+0x127>
cmpl   $0x4,-0xc(%rbp)
jne    1275 <menuCRUD+0xe5>
mov    -0x8(%rbp),%rdi
call   1070 <removeEntity@plt>
jmp    12b2 <menuCRUD+0x122>
cmpl   $0x5,-0xc(%rbp)
jne    128d <menuCRUD+0xfd>
mov    -0x8(%rbp),%rdi
call   1080 <mostraIndex@plt>
jmp    12ad <menuCRUD+0x11d>
cmpl   $0x0,-0xc(%rbp)
jne    129c <menuCRUD+0x10c>
jmp    12c1 <menuCRUD+0x131>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
jmp    12ad <menuCRUD+0x11d>
jmp    12b2 <menuCRUD+0x122>
jmp    12b7 <menuCRUD+0x127>
jmp    12bc <menuCRUD+0x12c>
jmp    12c1 <menuCRUD+0x131>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menuCRUD>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   10a0 <carrega_entidadeGeral@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xecd(%rip),%rdi
call   1050 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x5,%rax
ja     1232 <menuCRUD+0xa2>
lea    0xde1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbx,%rdi
call   10b0 <writeEntity@plt>
jmp    1266 <menuCRUD+0xd6>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
jmp    1266 <menuCRUD+0xd6>
mov    %rbx,%rdi
call   1040 <readFiles@plt>
jmp    1266 <menuCRUD+0xd6>
mov    %rbx,%rdi
call   1060 <changeEntity@plt>
jmp    1266 <menuCRUD+0xd6>
mov    %rbx,%rdi
call   1070 <removeEntity@plt>
jmp    1266 <menuCRUD+0xd6>
mov    %rbx,%rdi
call   1080 <mostraIndex@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"\09\09MENU CRUD\09\09\0A\00"
@.str.1 = [29 x i8] c"1- Inserir um novo elemento\0A\00"
@.str.2 = [43 x i8] c"2- Mostrar todos os elementos da entidade\0A\00"
@.str.3 = [24 x i8] c"3- Alterar um elemento\0A\00"
@.str.4 = [24 x i8] c"4- Remover um elemento\0A\00"
@.str.5 = [30 x i8] c"5- Mostrar indices ordenados\0A\00"
@.str.6 = [8 x i8] c"0- Sair\00"
@.str.7 = [5 x i8] c":>> \00"
@.str.8 = [3 x i8] c"%i\00"
@.str.9 = [17 x i8] c"Opcao Invalida!\0A\00"
define void @menuCRUD(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @carrega_entidadeGeral(i8* %4)
%6 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i8*, i8** %2
%19 = call i32 @writeEntity(i8* %18)
br label %55
20: ; preds = %1
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %2
%25 = call i32 @readFiles(i8* %24)
br label %54
26: ; preds = %20
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i8*, i8** %2
%31 = call i32 @changeEntity(i8* %30)
br label %53
32: ; preds = %26
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %2
%37 = call i32 @removeEntity(i8* %36)
br label %52
38: ; preds = %32
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 5
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %2
%43 = call i32 @mostraIndex(i8* %42)
br label %51
44: ; preds = %38
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
br label %55
48: ; preds = %44
%49 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48
br label %51
51: ; preds = %50, %41
br label %52
52: ; preds = %51, %35
br label %53
53: ; preds = %52, %29
br label %54
54: ; preds = %53, %23
br label %55
55: ; preds = %47, %54, %17
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"\09\09MENU CRUD\09\09\0A\00"
@.str.1 = [29 x i8] c"1- Inserir um novo elemento\0A\00"
@.str.2 = [43 x i8] c"2- Mostrar todos os elementos da entidade\0A\00"
@.str.3 = [24 x i8] c"3- Alterar um elemento\0A\00"
@.str.4 = [24 x i8] c"4- Remover um elemento\0A\00"
@.str.5 = [30 x i8] c"5- Mostrar indices ordenados\0A\00"
@.str.6 = [8 x i8] c"0- Sair\00"
@.str.7 = [5 x i8] c":>> \00"
@.str.8 = [3 x i8] c"%i\00"
@.str.9 = [17 x i8] c"Opcao Invalida!\0A\00"
define void @menuCRUD(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @carrega_entidadeGeral(i8* %0)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %25 [
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
i32 5, label %23
i32 0, label %27
]
15: ; preds = %1
%16 = call i32 @writeEntity(i8* %0)
br label %27
17: ; preds = %1
%18 = call i32 @readFiles(i8* %0)
br label %27
19: ; preds = %1
%20 = call i32 @changeEntity(i8* %0)
br label %27
21: ; preds = %1
%22 = call i32 @removeEntity(i8* %0)
br label %27
23: ; preds = %1
%24 = call i32 @mostraIndex(i8* %0)
br label %27
25: ; preds = %1
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %27
27: ; preds = %15, %19, %23, %25, %21, %17, %1
ret void
}