#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*/ exibir_vetores();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ menu();
int /*<<< orphan*/ multiplica_vetor();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ produto_escalar();
int /*<<< orphan*/ receber_vetor();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ soma_vetor();
int /*<<< orphan*/ system(char *);
void menu_vetor() {
  system("cls");
  int op;
  printf("\t[ VETORES ]\n"
         "1. Ler vetores\n"
         "2. Somar dois vetores\n"
         "3. Multiplicar um dos vetores por um escalar\n"
         "4. Realizar o produto escalar entre dois vetores\n"
         "5. Exibir lista de vetores lidos\n"
         "6. Voltar ao menu anterior\n"
         "7. Sair do programa\n");
  do {
    printf("\nEscolha uma opcao: ");
    scanf(" %d", &op);
    if (op < 1 || op > 7)
      printf("Opcao invalida.");
    printf("\n");
  } while (op < 1 || op > 7);
  switch (op) {
  case 1:
    system("cls");
    receber_vetor();
    menu_vetor();
    break;
  case 2:
    system("cls");
    soma_vetor();
    menu_vetor();
    break;
  case 3:
    system("cls");
    multiplica_vetor();
    menu_vetor();
    break;
  case 4:
    system("cls");
    produto_escalar();
    menu_vetor();
    break;
  case 5:
    system("cls");
    exibir_vetores();
    menu_vetor();
    break;
  case 6:
    menu();
    break;
  case 7:
    exit(1);
  }
}


x86 assembly (clang, -O0):
<menu_vetor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe5d(%rip),%rdi
call   1060 <system@plt>
lea    0xe55(%rip),%rdi
call   1070 <printf@plt>
lea    0xf2a(%rip),%rdi
call   1070 <printf@plt>
lea    0xf33(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10a0 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     1200 <menu_vetor+0x50>
cmpl   $0x7,-0x4(%rbp)
jle    120c <menu_vetor+0x5c>
lea    0xf13(%rip),%rdi
call   1070 <printf@plt>
lea    0xeec(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1231 <menu_vetor+0x81>
cmpl   $0x7,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    11d0 <menu_vetor+0x20>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     130c <menu_vetor+0x15c>
mov    -0x10(%rbp),%rax
lea    0xda4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdb0(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   1050 <receber_vetor@plt>
call   1090 <menu_vetor@plt>
jmp    130c <menu_vetor+0x15c>
lea    0xd93(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   10c0 <soma_vetor@plt>
call   1090 <menu_vetor@plt>
jmp    130c <menu_vetor+0x15c>
lea    0xd76(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   1080 <multiplica_vetor@plt>
call   1090 <menu_vetor@plt>
jmp    130c <menu_vetor+0x15c>
lea    0xd59(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   10d0 <produto_escalar@plt>
call   1090 <menu_vetor@plt>
jmp    130c <menu_vetor+0x15c>
lea    0xd3c(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   1030 <exibir_vetores@plt>
call   1090 <menu_vetor@plt>
jmp    130c <menu_vetor+0x15c>
mov    $0x0,%al
call   1040 <menu@plt>
jmp    130c <menu_vetor+0x15c>
mov    $0x1,%edi
call   10b0 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_vetor>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe3d(%rip),%rdi
call   1080 <system@plt>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe29(%rip),%r14
lea    0xe37(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xe2f(%rip),%r12
jmp    1226 <menu_vetor+0x56>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
lea    -0x8(%rax),%ecx
cmp    $0xfffffff9,%ecx
jae    124f <menu_vetor+0x7f>
mov    %r14,%rdi
call   1090 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10c0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffff8,%eax
cmp    $0xfffffff8,%eax
ja     1210 <menu_vetor+0x40>
mov    %r12,%rdi
call   1090 <printf@plt>
jmp    1210 <menu_vetor+0x40>
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     12d3 <menu_vetor+0x103>
lea    0xda2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdae(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
call   1070 <receber_vetor@plt>
jmp    12ce <menu_vetor+0xfe>
lea    0xd99(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
call   10e0 <soma_vetor@plt>
jmp    12ce <menu_vetor+0xfe>
lea    0xd84(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
call   10a0 <multiplica_vetor@plt>
jmp    12ce <menu_vetor+0xfe>
lea    0xd6f(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
call   10f0 <produto_escalar@plt>
jmp    12ce <menu_vetor+0xfe>
lea    0xd5a(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
call   1050 <exibir_vetores@plt>
call   10b0 <menu_vetor@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1060 <menu@plt>
jmp    12d3 <menu_vetor+0x103>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [225 x i8] c"\09[ VETORES ]\0A1. Ler vetores\0A2. Somar dois vetores\0A3. Multiplicar um dos vetores por um escalar\0A4. Realizar o produto escalar entre dois vetores\0A5. Exibir lista de vetores lidos\0A6. Voltar ao menu anterior\0A7. Sair do programa\0A\00"
@.str.2 = [21 x i8] c"\0AEscolha uma opcao: \00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [16 x i8] c"Opcao invalida.\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @menu_vetor() {
%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 ([225 x i8], [225 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %22, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 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, 7
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 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, 7
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 %45 [
i32 1, label %26
i32 2, label %29
i32 3, label %32
i32 4, label %35
i32 5, label %38
i32 6, label %41
i32 7, label %43
]
26: ; preds = %24
%27 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%28 = call i32 (...) @receber_vetor()
br label %45
29: ; preds = %24
%30 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (...) @soma_vetor()
br label %45
32: ; preds = %24
%33 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%34 = call i32 (...) @multiplica_vetor()
br label %45
35: ; preds = %24
%36 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%37 = call i32 (...) @produto_escalar()
br label %45
38: ; preds = %24
%39 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%40 = call i32 (...) @exibir_vetores()
br label %45
41: ; preds = %24
%42 = call i32 (...) @menu()
br label %45
43: ; preds = %24
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %24, %41, %38, %35, %32, %29, %26
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.2 = [21 x i8] c"\0AEscolha uma opcao: \00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [16 x i8] c"Opcao invalida.\00"
@str = [224 x i8] c"\09[ VETORES ]\0A1. Ler vetores\0A2. Somar dois vetores\0A3. Multiplicar um dos vetores por um escalar\0A4. Realizar o produto escalar entre dois vetores\0A5. Exibir lista de vetores lidos\0A6. Voltar ao menu anterior\0A7. Sair do programa\00"
define void @menu_vetor() {
%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 ([224 x i8], [224 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %13, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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, -8
%10 = icmp ult i32 %9, -7
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, 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, -8
%17 = icmp ult i32 %16, -7
br i1 %17, label %5, label %18
18: ; preds = %13
switch i32 %15, label %38 [
i32 1, label %19
i32 2, label %22
i32 3, label %25
i32 4, label %28
i32 5, label %31
i32 6, label %34
i32 7, label %36
]
19: ; preds = %18
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (...) @receber_vetor()
br label %38
22: ; preds = %18
%23 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (...) @soma_vetor()
br label %38
25: ; preds = %18
%26 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (...) @multiplica_vetor()
br label %38
28: ; preds = %18
%29 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%30 = call i32 (...) @produto_escalar()
br label %38
31: ; preds = %18
%32 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%33 = call i32 (...) @exibir_vetores()
br label %38
34: ; preds = %18
%35 = call i32 (...) @menu()
br label %38
36: ; preds = %18
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %18, %34, %31, %28, %25, %22, %19
ret void
}