#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*/ adicionarEntidade(int);
int /*<<< orphan*/ atualizarEntidade(int);
int /*<<< orphan*/ lerEntidade(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ removerEntidade(int, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void menuOperacao(int entidade) {
  int operacao, id;
  do {
    printf("escolha a operacao desejada:\n");
    printf("1-Adicionar\n");
    printf("2-Atualizar\n");
    printf("3-Ler\n");
    printf("4-Deletar\n");
    printf("0-Voltar ao meu anterior\n");
    scanf("%d", &operacao);
    system("cls");
    switch (operacao) {
    case 1:
      if (adicionarEntidade(entidade) == 0) {
        printf("operacao realizada com sucesso!\n");
        system("PAUSE");
        system("cls");
      } else {
        printf("operacao falhou!\n");
        system("PAUSE");
        system("cls");
      }
      break;
    case 2:
      if (atualizarEntidade(entidade) == 0) {
        printf("operacao realizada com sucesso!\n");
        system("PAUSE");
        system("cls");
      } else {
        printf("operacao falhou!\n");
        system("PAUSE");
        system("cls");
      }
      break;
    case 3:
      printf("Informe o ID da entidade a ser lida ou 0 para listar todas:  \n");
      scanf("%d", &id);
      if (lerEntidade(entidade, id) == 0) {
        printf("operacao realizada com sucesso!\n");
        system("PAUSE");
        system("cls");
      } else {
        printf("operacao falhou!\n");
        system("PAUSE");
        system("cls");
      }
      break;
    case 4:
      printf("Informe o ID da entidade a ser removida:  \n");
      scanf("%d", &id);
      if (removerEntidade(entidade, id) == 0) {
        printf("operacao realizada com sucesso!\n");
        system("PAUSE");
        system("cls");
      } else {
        printf("operacao falhou!\n");
        system("PAUSE");
        system("cls");
      }
      break;
    }
  } while (operacao != 0);
}


x86 assembly (clang, -O0):
<menuOperacao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1060 <printf@plt>
lea    0xea0(%rip),%rdi
call   1060 <printf@plt>
lea    0xea1(%rip),%rdi
call   1060 <printf@plt>
lea    0xea2(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9d(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1060 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xe9d(%rip),%rdi
call   1040 <system@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     13d2 <menuOperacao+0x262>
mov    -0x18(%rbp),%rax
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
call   1070 <adicionarEntidade@plt>
cmp    $0x0,%eax
jne    1242 <menuOperacao+0xd2>
lea    0xe5b(%rip),%rdi
call   1060 <printf@plt>
lea    0xe70(%rip),%rdi
call   1040 <system@plt>
lea    0xe3f(%rip),%rdi
call   1040 <system@plt>
jmp    1266 <menuOperacao+0xf6>
lea    0xe59(%rip),%rdi
call   1060 <printf@plt>
lea    0xe47(%rip),%rdi
call   1040 <system@plt>
lea    0xe16(%rip),%rdi
call   1040 <system@plt>
jmp    13d2 <menuOperacao+0x262>
mov    -0x4(%rbp),%edi
call   1090 <atualizarEntidade@plt>
cmp    $0x0,%eax
jne    12a5 <menuOperacao+0x135>
lea    0xdf8(%rip),%rdi
call   1060 <printf@plt>
lea    0xe0d(%rip),%rdi
call   1040 <system@plt>
lea    0xddc(%rip),%rdi
call   1040 <system@plt>
jmp    12c9 <menuOperacao+0x159>
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
lea    0xde4(%rip),%rdi
call   1040 <system@plt>
lea    0xdb3(%rip),%rdi
call   1040 <system@plt>
jmp    13d2 <menuOperacao+0x262>
lea    0xddf(%rip),%rdi
call   1060 <printf@plt>
lea    0xd93(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <lerEntidade@plt>
cmp    $0x0,%eax
jne    1327 <menuOperacao+0x1b7>
lea    0xd76(%rip),%rdi
call   1060 <printf@plt>
lea    0xd8b(%rip),%rdi
call   1040 <system@plt>
lea    0xd5a(%rip),%rdi
call   1040 <system@plt>
jmp    134b <menuOperacao+0x1db>
lea    0xd74(%rip),%rdi
call   1060 <printf@plt>
lea    0xd62(%rip),%rdi
call   1040 <system@plt>
lea    0xd31(%rip),%rdi
call   1040 <system@plt>
jmp    13d2 <menuOperacao+0x262>
lea    0xd9c(%rip),%rdi
call   1060 <printf@plt>
lea    0xd11(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <removerEntidade@plt>
cmp    $0x0,%eax
jne    13a9 <menuOperacao+0x239>
lea    0xcf4(%rip),%rdi
call   1060 <printf@plt>
lea    0xd09(%rip),%rdi
call   1040 <system@plt>
lea    0xcd8(%rip),%rdi
call   1040 <system@plt>
jmp    13cd <menuOperacao+0x25d>
lea    0xcf2(%rip),%rdi
call   1060 <printf@plt>
lea    0xce0(%rip),%rdi
call   1040 <system@plt>
lea    0xcaf(%rip),%rdi
call   1040 <system@plt>
jmp    13d2 <menuOperacao+0x262>
jmp    13d7 <menuOperacao+0x267>
cmpl   $0x0,-0x8(%rbp)
jne    117b <menuOperacao+0xb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menuOperacao>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xede(%rip),%r14
lea    0xe85(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe7c(%rip),%r13
lea    0xe62(%rip),%rbp
jmp    11fa <menuOperacao+0x8a>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%esi
mov    %ebx,%edi
call   1040 <removerEntidade@plt>
test   %eax,%eax
lea    0xf1a(%rip),%rdi
lea    0xf24(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe36(%rip),%rdi
call   1050 <system@plt>
mov    %r13,%rdi
call   1050 <system@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     12b6 <menuOperacao+0x146>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    %r13,%rdi
call   1050 <system@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     11f2 <menuOperacao+0x82>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %ebx,%edi
call   1070 <adicionarEntidade@plt>
jmp    11c1 <menuOperacao+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1090 <atualizarEntidade@plt>
jmp    11c1 <menuOperacao+0x51>
nopl   0x0(%rax)
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%esi
mov    %ebx,%edi
call   1060 <lerEntidade@plt>
jmp    11c1 <menuOperacao+0x51>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"escolha a operacao desejada:\0A\00"
@.str.1 = [13 x i8] c"1-Adicionar\0A\00"
@.str.2 = [13 x i8] c"2-Atualizar\0A\00"
@.str.3 = [7 x i8] c"3-Ler\0A\00"
@.str.4 = [11 x i8] c"4-Deletar\0A\00"
@.str.5 = [26 x i8] c"0-Voltar ao meu anterior\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"cls\00"
@.str.8 = [33 x i8] c"operacao realizada com sucesso!\0A\00"
@.str.9 = [6 x i8] c"PAUSE\00"
@.str.10 = [18 x i8] c"operacao falhou!\0A\00"
@.str.11 = [63 x i8] c"Informe o ID da entidade a ser lida ou 0 para listar todas: \0A\00"
@.str.12 = [44 x i8] c"Informe o ID da entidade a ser removida: \0A\00"
define void @menuOperacao(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
br label %5
5: ; preds = %74, %1
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%13 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%14 = load i32, i32* %3
switch i32 %14, label %73 [
i32 1, label %15
i32 2, label %28
i32 3, label %41
i32 4, label %57
]
15: ; preds = %5
%16 = load i32, i32* %2
%17 = call i32 @adicionarEntidade(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %27
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%25 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %23, %19
br label %73
28: ; preds = %5
%29 = load i32, i32* %2
%30 = call i32 @atualizarEntidade(i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %40
36: ; preds = %28
%37 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%38 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%39 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %36, %32
br label %73
41: ; preds = %5
%42 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.11, i64 0, i64 0))
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%44 = load i32, i32* %2
%45 = load i32, i32* %4
%46 = call i32 @lerEntidade(i32 %44, i32 %45)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %41
%49 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%50 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%51 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %56
52: ; preds = %41
%53 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%54 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%55 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %56
56: ; preds = %52, %48
br label %73
57: ; preds = %5
%58 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0))
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%60 = load i32, i32* %2
%61 = load i32, i32* %4
%62 = call i32 @removerEntidade(i32 %60, i32 %61)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %57
%65 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%66 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%67 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %72
68: ; preds = %57
%69 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%70 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%71 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %72
72: ; preds = %68, %64
br label %73
73: ; preds = %5, %72, %56, %40, %27
br label %74
74: ; preds = %73
%75 = load i32, i32* %3
%76 = icmp ne i32 %75, 0
br i1 %76, label %5, label %77
77: ; preds = %74
ret void
}

LLVM IR (-O2):
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"cls\00"
@.str.9 = [6 x i8] c"PAUSE\00"
@str = [29 x i8] c"escolha a operacao desejada:\00"
@str.13 = [12 x i8] c"1-Adicionar\00"
@str.14 = [12 x i8] c"2-Atualizar\00"
@str.15 = [6 x i8] c"3-Ler\00"
@str.16 = [10 x i8] c"4-Deletar\00"
@str.17 = [25 x i8] c"0-Voltar ao meu anterior\00"
@str.18 = [43 x i8] c"Informe o ID da entidade a ser removida: \00"
@str.21 = [62 x i8] c"Informe o ID da entidade a ser lida ou 0 para listar todas: \00"
@str.26 = [17 x i8] c"operacao falhou!\00"
@str.27 = [32 x i8] c"operacao realizada com sucesso!\00"
define void @menuOperacao(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %44, %1
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.14, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.16, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%14 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%15 = load i32, i32* %2
switch i32 %15, label %44 [
i32 1, label %16
i32 2, label %20
i32 3, label %24
i32 4, label %31
]
16: ; preds = %6
%17 = call i32 @adicionarEntidade(i32 %0)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0)
br label %38
20: ; preds = %6
%21 = call i32 @atualizarEntidade(i32 %0)
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0)
br label %38
24: ; preds = %6
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.21, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %3
%28 = call i32 @lerEntidade(i32 %0, i32 %27)
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0)
br label %38
31: ; preds = %6
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.18, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%34 = load i32, i32* %3
%35 = call i32 @removerEntidade(i32 %0, i32 %34)
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.26, i64 0, i64 0)
br label %38
38: ; preds = %31, %24, %20, %16
%39 = phi i8* [ %19, %16 ], [ %23, %20 ], [ %30, %24 ], [ %37, %31 ]
%40 = call i32 @puts(i8* dereferenceable(1) %39)
%41 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%42 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%43 = load i32, i32* %2
br label %44
44: ; preds = %38, %6
%45 = phi i32 [ %43, %38 ], [ %15, %6 ]
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %6
47: ; preds = %44
ret void
}