#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ cabecalho();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ menuOpcoes();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ realizaCriptografia(int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *arquivo;
  int chave, opcao;
  char nome_arquivo_saida[50];
  char conteudo_arquivo[300];
  char lixo_memoria;
  system("color F2");
  cabecalho();
  getch();
  system("cls");
  system("color F5");
  while (2) {
    menuOpcoes();
    scanf("%d", &opcao);
    while (opcao < 0 || opcao > 2) {
      printf("Opacao invalida. Digite novamente:");
      scanf("%d", &opcao);
    }
    if (opcao == 2)
      exit(0);
    printf("Digite o tipo da chave, por favor: \n");
    scanf("%d", &chave);
    realizaCriptografia(chave);
    printf("Arquivo e sua criptografia gravado com sucesso\n");
    getch();
    system("cls");
  }
  fclose(arquivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1030 <cabecalho@plt>
mov    $0x0,%al
call   1080 <getch@plt>
lea    0xe56(%rip),%rdi
call   1040 <system@plt>
lea    0xe4e(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1060 <menuOpcoes@plt>
lea    0xe44(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x182(%rbp)
jl     11fa <main+0x7a>
cmpl   $0x2,-0x18(%rbp)
setg   %al
mov    %al,-0x182(%rbp)
mov    -0x182(%rbp),%al
test   $0x1,%al
jne    120d <main+0x8d>
jmp    122e <main+0xae>
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf6(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
jmp    11db <main+0x5b>
cmpl   $0x2,-0x18(%rbp)
jne    123f <main+0xbf>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
lea    0xdc4(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <realizaCriptografia@plt>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getch@plt>
lea    0xd8c(%rip),%rdi
call   1040 <system@plt>
jmp    11c4 <main+0x44>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe5e(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1030 <cabecalho@plt>
xor    %eax,%eax
call   1090 <getch@plt>
lea    0xe4d(%rip),%rdi
call   1050 <system@plt>
lea    0xe45(%rip),%rdi
call   1050 <system@plt>
lea    0xe42(%rip),%rbx
mov    %rsp,%r15
lea    0xe3b(%rip),%r12
lea    0xe57(%rip),%r13
lea    0x4(%rsp),%rbp
lea    0xe6f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <menuOpcoes@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x3,%eax
jb     123b <main+0xab>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x2,%eax
ja     1220 <main+0x90>
cmp    $0x2,%eax
je     1279 <main+0xe9>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%edi
call   10b0 <realizaCriptografia@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <getch@plt>
lea    0xd97(%rip),%rdi
call   1050 <system@plt>
jmp    1200 <main+0x70>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"color F2\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [9 x i8] c"color F5\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [35 x i8] c"Opacao invalida. Digite novamente:\00"
@.str.5 = [37 x i8] c"Digite o tipo da chave, por favor: \0A\00"
@.str.6 = [48 x i8] c"Arquivo e sua criptografia gravado com sucesso\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [50 x i8]
%6 = alloca [300 x i8]
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @cabecalho()
%10 = call i32 (...) @getch()
%11 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %0, %32
%14 = call i32 (...) @menuOpcoes()
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
br label %16
16: ; preds = %24, %13
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 2
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
br label %16
27: ; preds = %22
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%35 = load i32, i32* %3
%36 = call i32 @realizaCriptografia(i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (...) @getch()
%39 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %13
}

LLVM IR (-O2):
@.str = [9 x i8] c"color F2\00"
@.str.1 = [4 x i8] c"cls\00"
@.str.2 = [9 x i8] c"color F5\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [35 x i8] c"Opacao invalida. Digite novamente:\00"
@str = [36 x i8] c"Digite o tipo da chave, por favor: \00"
@str.7 = [47 x i8] c"Arquivo e sua criptografia gravado com sucesso\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @cabecalho()
%7 = tail call i32 (...) @getch()
%8 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %25, %0
%11 = call i32 (...) @menuOpcoes()
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp ugt i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %10, %15
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = icmp ugt i32 %18, 2
br i1 %19, label %15, label %20
20: ; preds = %15, %10
%21 = phi i32 [ %13, %10 ], [ %18, %15 ]
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%28 = load i32, i32* %1
%29 = call i32 @realizaCriptografia(i32 %28)
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.7, i64 0, i64 0))
%31 = call i32 (...) @getch()
%32 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %10
}