#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*/ getch();
int /*<<< orphan*/ limpa();
int /*<<< orphan*/ lista_adjacencia();
int /*<<< orphan*/ lista_adjacencia_pesos();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ vetor_adjacencia();
int main() {
  int opcao;
  do {
    puts("Digite 1 para Lista de Adjacencia sem pesos\n");
    puts("Digite 2 para Lista de Adjacencia com pesos\n");
    puts("Digite 3 para Vetor de Adjacencia\n");
    puts("Digite 0 para Encerrar o Programa\n");
    scanf("%i", &opcao);
    limpa();
    if (opcao == 1)
      lista_adjacencia();
    else if (opcao == 2)
      lista_adjacencia_pesos();
    else if (opcao == 3)
      vetor_adjacencia();
    else if (opcao == 0) {
      puts("Fim do programa\n");
      sleep(3);
      return 0;
    } else
      puts("Entrada Inválida!\n");
    puts("Digite algo para continuar...");
    getch();
    limpa();
  } while (opcao != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <limpa@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11ec <main+0x6c>
mov    $0x0,%al
call   1050 <lista_adjacencia@plt>
jmp    125f <main+0xdf>
cmpl   $0x2,-0x8(%rbp)
jne    1202 <main+0x82>
mov    $0x0,%al
call   1090 <lista_adjacencia_pesos@plt>
jmp    125a <main+0xda>
cmpl   $0x3,-0x8(%rbp)
jne    1218 <main+0x98>
mov    $0x0,%al
call   1040 <vetor_adjacencia@plt>
jmp    1255 <main+0xd5>
cmpl   $0x0,-0x8(%rbp)
jne    1244 <main+0xc4>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   10a0 <sleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    1283 <main+0x103>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
jmp    1255 <main+0xd5>
jmp    125a <main+0xda>
jmp    125f <main+0xdf>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1080 <getch@plt>
mov    $0x0,%al
call   1060 <limpa@plt>
cmpl   $0x0,-0x8(%rbp)
jne    118f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed8(%rip),%r12
lea    0xef4(%rip),%r13
lea    0xf10(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xf2c(%rip),%r14
lea    0xe4d(%rip),%r15
jmp    11ed <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getch@plt>
xor    %eax,%eax
call   1060 <limpa@plt>
cmpl   $0x0,0x4(%rsp)
je     1282 <main+0x102>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <limpa@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11c0 <main+0x40>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <lista_adjacencia@plt>
jmp    11cc <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1090 <lista_adjacencia_pesos@plt>
jmp    11cc <main+0x4c>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <vetor_adjacencia@plt>
jmp    11cc <main+0x4c>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Digite 1 para Lista de Adjacencia sem pesos\0A\00"
@.str.1 = [45 x i8] c"Digite 2 para Lista de Adjacencia com pesos\0A\00"
@.str.2 = [35 x i8] c"Digite 3 para Vetor de Adjacencia\0A\00"
@.str.3 = [35 x i8] c"Digite 0 para Encerrar o Programa\0A\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [17 x i8] c"Fim do programa\0A\00"
@.str.6 = [20 x i8] c"Entrada Inv\C3\A1lida!\0A\00"
@.str.7 = [30 x i8] c"Digite algo para continuar...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %39, %0
%4 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%9 = call i32 (...) @limpa()
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (...) @lista_adjacencia()
br label %35
14: ; preds = %3
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (...) @lista_adjacencia_pesos()
br label %34
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @vetor_adjacencia()
br label %33
24: ; preds = %19
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @sleep(i32 3)
store i32 0, i32* %1
br label %42
30: ; preds = %24
%31 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30
br label %33
33: ; preds = %32, %22
br label %34
34: ; preds = %33, %17
br label %35
35: ; preds = %34, %12
%36 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%37 = call i32 (...) @getch()
%38 = call i32 (...) @limpa()
br label %39
39: ; preds = %35
%40 = load i32, i32* %2
%41 = icmp ne i32 %40, 0
br i1 %41, label %3, label %42
42: ; preds = %27, %39
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [45 x i8] c"Digite 1 para Lista de Adjacencia sem pesos\0A\00"
@.str.1 = [45 x i8] c"Digite 2 para Lista de Adjacencia com pesos\0A\00"
@.str.2 = [35 x i8] c"Digite 3 para Vetor de Adjacencia\0A\00"
@.str.3 = [35 x i8] c"Digite 0 para Encerrar o Programa\0A\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [17 x i8] c"Fim do programa\0A\00"
@.str.6 = [20 x i8] c"Entrada Inv\C3\A1lida!\0A\00"
@.str.7 = [30 x i8] c"Digite algo para continuar...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %22, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = call i32 (...) @limpa()
%10 = load i32, i32* %1
switch i32 %10, label %20 [
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 0, label %17
]
11: ; preds = %3
%12 = call i32 (...) @lista_adjacencia()
br label %22
13: ; preds = %3
%14 = call i32 (...) @lista_adjacencia_pesos()
br label %22
15: ; preds = %3
%16 = call i32 (...) @vetor_adjacencia()
br label %22
17: ; preds = %3
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @sleep(i32 3)
br label %28
20: ; preds = %3
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %13, %20, %15, %11
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 (...) @getch()
%25 = call i32 (...) @limpa()
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %3
28: ; preds = %22, %17
ret i32 0
}