#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*/ excluir_conta(int *);
int /*<<< orphan*/ exibe_criar_conta(int *);
int /*<<< orphan*/ gerente(int *);
int /*<<< orphan*/ logar(int *, int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sair();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void menu_principal(int *terminal) {
  int opc;
  system("cls");
  printf(
      "############### BANCO KNC - O SEU BANCO DE SUCESSO ###############\n\n");
  printf("Menu Principal - Terminal %d\n", *terminal);
  printf("1 - Efetuar Login\n");
  printf("2 - Falar com o Gerente\n");
  printf("3 - Criar usuario\n");
  printf("4 - Excluir usuario\n");
  printf("5 - Sair\n");
  opc = 0;
  while ((opc < 1) || (opc > 5)) {
    printf("\nDigite a opcao desejada: ");
    scanf("%d", &opc);
    if ((opc < 1) || (opc > 5))
      printf("\nOpcao invalida!");
  }
  if (opc == 1)
    logar(terminal, 0, 0, 0);
  else if (opc == 2)
    gerente(terminal);
  else if (opc == 3)
    exibe_criar_conta(terminal);
  else if (opc == 4)
    excluir_conta(terminal);
  else
    sair();
}


x86 assembly (clang, -O0):
<menu_principal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe6d(%rip),%rdi
call   1040 <system@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     1220 <menu_principal+0xa0>
cmpl   $0x5,-0xc(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1230 <menu_principal+0xb0>
jmp    1275 <menu_principal+0xf5>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jl     1262 <menu_principal+0xe2>
cmpl   $0x5,-0xc(%rbp)
jle    1270 <menu_principal+0xf0>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1207 <menu_principal+0x87>
cmpl   $0x1,-0xc(%rbp)
jne    1293 <menu_principal+0x113>
mov    -0x8(%rbp),%rdi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1060 <logar@plt>
jmp    12f1 <menu_principal+0x171>
cmpl   $0x2,-0xc(%rbp)
jne    12ab <menu_principal+0x12b>
mov    -0x8(%rbp),%rdi
call   1030 <gerente@plt>
jmp    12ec <menu_principal+0x16c>
cmpl   $0x3,-0xc(%rbp)
jne    12c3 <menu_principal+0x143>
mov    -0x8(%rbp),%rdi
call   10a0 <exibe_criar_conta@plt>
jmp    12e7 <menu_principal+0x167>
cmpl   $0x4,-0xc(%rbp)
jne    12db <menu_principal+0x15b>
mov    -0x8(%rbp),%rdi
call   1070 <excluir_conta@plt>
jmp    12e2 <menu_principal+0x162>
mov    $0x0,%al
call   1080 <sair@plt>
jmp    12e7 <menu_principal+0x167>
jmp    12ec <menu_principal+0x16c>
jmp    12f1 <menu_principal+0x171>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_principal>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xe69(%rip),%rdi
call   1050 <system@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
lea    0xe1e(%rip),%r15
lea    0xe32(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0xe29(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffa,%ecx
ja     1267 <menu_principal+0xd7>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffb,%ecx
jb     1230 <menu_principal+0xa0>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     128f <menu_principal+0xff>
lea    0xd8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1070 <logar@plt>
jmp    12b4 <menu_principal+0x124>
xor    %eax,%eax
call   1090 <sair@plt>
jmp    12b4 <menu_principal+0x124>
mov    %r14,%rdi
call   1040 <gerente@plt>
jmp    12b4 <menu_principal+0x124>
mov    %r14,%rdi
call   10b0 <exibe_criar_conta@plt>
jmp    12b4 <menu_principal+0x124>
mov    %r14,%rdi
call   1080 <excluir_conta@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [69 x i8] c"############### BANCO KNC - O SEU BANCO DE SUCESSO ###############\0A\0A\00"
@.str.2 = [30 x i8] c"Menu Principal - Terminal %d\0A\00"
@.str.3 = [19 x i8] c"1 - Efetuar Login\0A\00"
@.str.4 = [25 x i8] c"2 - Falar com o Gerente\0A\00"
@.str.5 = [19 x i8] c"3 - Criar usuario\0A\00"
@.str.6 = [21 x i8] c"4 - Excluir usuario\0A\00"
@.str.7 = [10 x i8] c"5 - Sair\0A\00"
@.str.8 = [27 x i8] c"\0ADigite a opcao desejada: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [17 x i8] c"\0AOpcao invalida!\00"
define void @menu_principal(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32*, i32** %2
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %14
14: ; preds = %32, %1
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 5
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ true, %14 ], [ %19, %17 ]
br i1 %21, label %22, label %33
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 5
br i1 %29, label %30, label %32
30: ; preds = %27, %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %14
33: ; preds = %20
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32*, i32** %2
%38 = call i32 @logar(i32* %37, i32 0, i32 0, i32 0)
br label %62
39: ; preds = %33
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32*, i32** %2
%44 = call i32 @gerente(i32* %43)
br label %61
45: ; preds = %39
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32*, i32** %2
%50 = call i32 @exibe_criar_conta(i32* %49)
br label %60
51: ; preds = %45
%52 = load i32, i32* %3
%53 = icmp eq i32 %52, 4
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32*, i32** %2
%56 = call i32 @excluir_conta(i32* %55)
br label %59
57: ; preds = %51
%58 = call i32 (...) @sair()
br label %59
59: ; preds = %57, %54
br label %60
60: ; preds = %59, %48
br label %61
61: ; preds = %60, %42
br label %62
62: ; preds = %61, %36
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.2 = [30 x i8] c"Menu Principal - Terminal %d\0A\00"
@.str.8 = [27 x i8] c"\0ADigite a opcao desejada: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [17 x i8] c"\0AOpcao invalida!\00"
@str = [68 x i8] c"############### BANCO KNC - O SEU BANCO DE SUCESSO ###############\0A\00"
@str.11 = [18 x i8] c"1 - Efetuar Login\00"
@str.12 = [24 x i8] c"2 - Falar com o Gerente\00"
@str.13 = [18 x i8] c"3 - Criar usuario\00"
@str.14 = [20 x i8] c"4 - Excluir usuario\00"
@str.15 = [9 x i8] c"5 - Sair\00"
define void @menu_principal(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.15, i64 0, i64 0))
store i32 0, i32* %2
br label %13
13: ; preds = %1, %19
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = add i32 %16, -6
%18 = icmp ult i32 %17, -5
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = add i32 %21, -6
%23 = icmp ult i32 %22, -5
br i1 %23, label %13, label %24
24: ; preds = %13, %19
%25 = phi i32 [ %21, %19 ], [ %16, %13 ]
switch i32 %25, label %34 [
i32 1, label %26
i32 2, label %28
i32 3, label %30
i32 4, label %32
]
26: ; preds = %24
%27 = call i32 @logar(i32* %0, i32 0, i32 0, i32 0)
br label %36
28: ; preds = %24
%29 = call i32 @gerente(i32* %0)
br label %36
30: ; preds = %24
%31 = call i32 @exibe_criar_conta(i32* %0)
br label %36
32: ; preds = %24
%33 = call i32 @excluir_conta(i32* %0)
br label %36
34: ; preds = %24
%35 = call i32 (...) @sair()
br label %36
36: ; preds = %28, %32, %34, %30, %26
ret void
}