#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*/ exit(int);
int /*<<< orphan*/ menu_matriz();
int /*<<< orphan*/ menu_vetor();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void menu() {
  system("cls");
  int op;
  printf("\t[ MENU ]\n"
         "1. Operacoes com vetores\n"
         "2. Operacoes com matrizes\n"
         "3. Sair do programa\n\n");
  do {
    printf("Escolha uma opcao: ");
    scanf(" %d", &op);
    if (op < 1 || op > 3)
      printf("Opcao invalida.\n");
    printf("\n");
  } while (op < 1 || op > 3);
  switch (op) {
  case 1:
    menu_vetor();
    menu();
    break;
  case 2:
    menu_matriz();
    menu();
    break;
  case 3:
    exit(1);
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1050 <system@plt>
lea    0xe79(%rip),%rdi
call   1060 <printf@plt>
lea    0xec0(%rip),%rdi
call   1060 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     11c0 <menu+0x50>
cmpl   $0x3,-0x4(%rbp)
jle    11cc <menu+0x5c>
lea    0xea8(%rip),%rdi
call   1060 <printf@plt>
lea    0xe82(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11f1 <menu+0x81>
cmpl   $0x3,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1190 <menu+0x20>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1232 <menu+0xc2>
jmp    1210 <menu+0xa0>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1243 <menu+0xd3>
jmp    1221 <menu+0xb1>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     1254 <menu+0xe4>
jmp    125e <menu+0xee>
mov    $0x0,%al
call   1070 <menu_vetor@plt>
call   1030 <menu@plt>
jmp    125e <menu+0xee>
mov    $0x0,%al
call   1040 <menu_matriz@plt>
call   1030 <menu@plt>
jmp    125e <menu+0xee>
mov    $0x1,%edi
call   1090 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe61(%rip),%rdi
call   1070 <system@plt>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4d(%rip),%r14
lea    0xe5a(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xea4(%rip),%r12
jmp    11e6 <menu+0x56>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jae    120f <menu+0x7f>
mov    %r14,%rdi
call   1080 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffffc,%eax
ja     11d0 <menu+0x40>
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    11d0 <menu+0x40>
cmp    $0x1,%eax
je     1228 <menu+0x98>
cmp    $0x2,%eax
je     1231 <menu+0xa1>
cmp    $0x3,%eax
jne    123d <menu+0xad>
mov    $0x1,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
call   1090 <menu_vetor@plt>
jmp    1238 <menu+0xa8>
xor    %eax,%eax
call   1060 <menu_matriz@plt>
call   1050 <menu@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [83 x i8] c"\09[ MENU ]\0A1. Operacoes com vetores\0A2. Operacoes com matrizes\0A3. Sair do programa\0A\0A\00"
@.str.2 = [20 x i8] c"Escolha uma opcao: \00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [17 x i8] c"Opcao invalida.\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @menu() {
%1 = alloca i32
%2 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %22, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %14
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, 3
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
br i1 %23, label %4, label %24
24: ; preds = %22
%25 = load i32, i32* %1
switch i32 %25, label %32 [
i32 1, label %26
i32 2, label %28
i32 3, label %30
]
26: ; preds = %24
%27 = call i32 (...) @menu_vetor()
br label %32
28: ; preds = %24
%29 = call i32 (...) @menu_matriz()
br label %32
30: ; preds = %24
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24, %28, %26
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.2 = [20 x i8] c"Escolha uma opcao: \00"
@.str.3 = [4 x i8] c" %d\00"
@str = [82 x i8] c"\09[ MENU ]\0A1. Operacoes com vetores\0A2. Operacoes com matrizes\0A3. Sair do programa\0A\00"
@str.6 = [16 x i8] c"Opcao invalida.\00"
define void @menu() {
%1 = alloca i32
%2 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %13, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -4
%10 = icmp ult i32 %9, -3
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
br label %13
13: ; preds = %5, %11
%14 = call i32 @putchar(i32 10)
%15 = load i32, i32* %1
%16 = add i32 %15, -4
%17 = icmp ult i32 %16, -3
br i1 %17, label %5, label %18
18: ; preds = %13
switch i32 %15, label %26 [
i32 1, label %19
i32 2, label %21
i32 3, label %23
]
19: ; preds = %18
%20 = call i32 (...) @menu_vetor()
br label %25
21: ; preds = %18
%22 = call i32 (...) @menu_matriz()
br label %25
23: ; preds = %18
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %19, %21
br label %26
26: ; preds = %25, %18
ret void
}