#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*/ matris_adjacencia();
int /*<<< orphan*/ matris_incidencia(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int main() {
  int opcao;
  do {
    puts("Digite 1 para Matris de Adjacencia\n");
    puts("Digite 2 para Matris de Incidencia Nao Ordenado\n");
    puts("Digite 3 para Matris de Incidencia Ordenado\n");
    puts("Digite 0 para Encerrar o Programa\n");
    scanf("%i", &opcao);
    limpa();
    if (opcao == 1)
      matris_adjacencia();
    else if (opcao == 2)
      matris_incidencia(1);
    else if (opcao == 3)
      matris_incidencia(2);
    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    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <limpa@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11dc <main+0x6c>
mov    $0x0,%al
call   1070 <matris_adjacencia@plt>
jmp    1255 <main+0xe5>
cmpl   $0x2,-0x8(%rbp)
jne    11f5 <main+0x85>
mov    $0x1,%edi
call   1090 <matris_incidencia@plt>
jmp    1250 <main+0xe0>
cmpl   $0x3,-0x8(%rbp)
jne    120e <main+0x9e>
mov    $0x2,%edi
call   1090 <matris_incidencia@plt>
jmp    124b <main+0xdb>
cmpl   $0x0,-0x8(%rbp)
jne    123a <main+0xca>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    1279 <main+0x109>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
jmp    124b <main+0xdb>
jmp    1250 <main+0xe0>
jmp    1255 <main+0xe5>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    $0x0,%al
call   1040 <limpa@plt>
cmpl   $0x0,-0x8(%rbp)
jne    117f <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    0xee3(%rip),%r12
lea    0xf09(%rip),%r13
lea    0xf25(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xf41(%rip),%r14
lea    0xe5d(%rip),%r15
jmp    11dd <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
call   1040 <limpa@plt>
cmpl   $0x0,0x4(%rsp)
je     1275 <main+0x105>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe44(%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   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <limpa@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11b0 <main+0x40>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <matris_adjacencia@plt>
jmp    11bc <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edi
call   1090 <matris_incidencia@plt>
jmp    11bc <main+0x4c>
nop
mov    $0x2,%edi
call   1090 <matris_incidencia@plt>
jmp    11bc <main+0x4c>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1080 <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 = [36 x i8] c"Digite 1 para Matris de Adjacencia\0A\00"
@.str.1 = [49 x i8] c"Digite 2 para Matris de Incidencia Nao Ordenado\0A\00"
@.str.2 = [45 x i8] c"Digite 3 para Matris de Incidencia Ordenado\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 ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 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 (...) @matris_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 @matris_incidencia(i32 1)
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 @matris_incidencia(i32 2)
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 = [36 x i8] c"Digite 1 para Matris de Adjacencia\0A\00"
@.str.1 = [49 x i8] c"Digite 2 para Matris de Incidencia Nao Ordenado\0A\00"
@.str.2 = [45 x i8] c"Digite 3 para Matris de Incidencia Ordenado\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 ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 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 (...) @matris_adjacencia()
br label %22
13: ; preds = %3
%14 = call i32 @matris_incidencia(i32 1)
br label %22
15: ; preds = %3
%16 = call i32 @matris_incidencia(i32 2)
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
}