#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*/ menuCRUD(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
void menu(char **vet_nome, int tam_vet) {
  int opc, j;
  while (1) {
    puts("\t\tMENU DE ENTIDADES\t\t\n");
    for (j = 0; j < tam_vet; j++) {
      printf("%i- %s\n", j + 1, vet_nome[j]);
    }
    printf("0- Sair\n");
    printf(":>> ");
    scanf("%i", &opc);
    if (opc == 0) {
      break;
    } else if (opc > 0 && opc <= tam_vet) {
      menuCRUD(vet_nome[opc - 1]);
    } else {
      puts("Opcao Invalida!\n");
    }
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <menu+0x5c>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <menu+0x22>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11d7 <menu+0x97>
jmp    121e <menu+0xde>
cmpl   $0x0,-0x10(%rbp)
jle    1208 <menu+0xc8>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1208 <menu+0xc8>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <menuCRUD@plt>
jmp    1214 <menu+0xd4>
lea    0xe21(%rip),%rdi
call   1030 <puts@plt>
jmp    1219 <menu+0xd9>
jmp    114f <menu+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %esi,%r14d
lea    0xebc(%rip),%rbp
lea    0x4(%rsp),%r12
jmp    117c <menu+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
test   %r15d,%r15d
jle    11aa <menu+0x6a>
xor    %r13d,%r13d
mov    (%rbx,%r13,8),%rdx
add    $0x1,%r13
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13,%r14
jne    1190 <menu+0x50>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11f0 <menu+0xb0>
jle    1170 <menu+0x30>
cmp    %r15d,%eax
jg     1170 <menu+0x30>
add    $0xffffffff,%eax
mov    (%rbx,%rax,8),%rdi
call   1060 <menuCRUD@plt>
jmp    117c <menu+0x3c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\09\09MENU DE ENTIDADES\09\09\0A\00"
@.str.1 = [8 x i8] c"%i- %s\0A\00"
@.str.2 = [9 x i8] c"0- Sair\0A\00"
@.str.3 = [5 x i8] c":>> \00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [17 x i8] c"Opcao Invalida!\0A\00"
define void @menu(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
br label %7
7: ; preds = %2, %50
%8 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %9
9: ; preds = %22, %7
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
%16 = load i8**, i8*** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %20)
br label %22
22: ; preds = %13
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %9
25: ; preds = %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
br label %51
32: ; preds = %25
%33 = load i32, i32* %5
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = icmp sle i32 %36, %37
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i8**, i8*** %3
%41 = load i32, i32* %5
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @menuCRUD(i8* %45)
br label %49
47: ; preds = %35, %32
%48 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %39
br label %50
50: ; preds = %49
br label %7
51: ; preds = %31
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"\09\09MENU DE ENTIDADES\09\09\0A\00"
@.str.1 = [8 x i8] c"%i- %s\0A\00"
@.str.3 = [5 x i8] c":>> \00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [17 x i8] c"Opcao Invalida!\0A\00"
@str = [8 x i8] c"0- Sair\00"
define void @menu(i8** nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %1, 0
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %33, %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br i1 %5, label %9, label %17
9: ; preds = %7, %9
%10 = phi i64 [ %11, %9 ], [ 0, %7 ]
%11 = add nuw nsw i64 %10, 1
%12 = getelementptr inbounds i8*, i8** %0, i64 %10
%13 = load i8*, i8** %12
%14 = trunc i64 %11 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %13)
%16 = icmp eq i64 %11, %6
br i1 %16, label %17, label %9
17: ; preds = %9, %7
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %36, label %23
23: ; preds = %17
%24 = icmp slt i32 %21, 1
%25 = icmp sgt i32 %21, %1
%26 = or i1 %24, %25
br i1 %26, label %34, label %27
27: ; preds = %23
%28 = add nsw i32 %21, -1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @menuCRUD(i8* %31)
br label %33
33: ; preds = %27, %34
br label %7
34: ; preds = %23
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %33
36: ; preds = %17
ret void
}