#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 */
scalar_t__ contar(char *, float *);
scalar_t__ desencriptar(int);
int diferencia(float *, float *);
scalar_t__ encriptar(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int enc = 0;
  printf("Introduce clave (numero) para encriptar: ");
  scanf("%d", &enc);
  if (encriptar(enc) != 0)
    printf("Error al encriptar\n");
  else
    printf("Encriptado con exito!\n");
  float c1[26];
  float c2[26];
  int i;
  if (contar("salida.txt", c1) != 0)
    printf(
        "Error al calcular porcentaje de cada letra en fichero encriptado\n");
  else
    printf("Calculado porcentaje de cada letra en fichero encriptado\n");
  if (contar("diccionario.txt", c2) != 0)
    printf(
        "Error al calcular porcentaje de cada letra en fichero diccionario\n");
  else
    printf("Calculado porcentaje de cada letra en fichero diccionario\n");
  int difer = diferencia(c1, c2);
  printf("Calculada diferencia entre letras con mayor porcentaje de "
         "apariciones en ambos ficheros\n");
  if (desencriptar(difer) != 0)
    printf("Error al desencriptar\n");
  else
    printf("Desencriptado con exito!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1080 <encriptar@plt>
cmp    $0x0,%rax
je     11b8 <main+0x58>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
jmp    11c4 <main+0x64>
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1060 <contar@plt>
cmp    $0x0,%rax
je     11ef <main+0x8f>
lea    0xe7e(%rip),%rdi
call   1050 <printf@plt>
jmp    11fb <main+0x9b>
lea    0xeaf(%rip),%rdi
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xed6(%rip),%rdi
call   1060 <contar@plt>
cmp    $0x0,%rax
je     1229 <main+0xc9>
lea    0xed0(%rip),%rdi
call   1050 <printf@plt>
jmp    1235 <main+0xd5>
lea    0xf02(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <diferencia@plt>
mov    %eax,-0xe8(%rbp)
lea    0xf1b(%rip),%rdi
call   1050 <printf@plt>
mov    -0xe8(%rbp),%edi
call   1030 <desencriptar@plt>
cmp    $0x0,%rax
je     127d <main+0x11d>
lea    0xf53(%rip),%rdi
call   1050 <printf@plt>
jmp    1289 <main+0x129>
lea    0xf59(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe77(%rip),%rdi
call   1060 <printf@plt>
lea    0xe95(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
call   1090 <encriptar@plt>
test   %rax,%rax
lea    0xe96(%rip),%rax
lea    0x1022(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
lea    0xe64(%rip),%rdi
lea    0x80(%rsp),%r14
mov    %r14,%rsi
call   1070 <contar@plt>
test   %rax,%rax
lea    0xe7b(%rip),%rax
lea    0xfb0(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
lea    0xe3e(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <contar@plt>
test   %rax,%rax
lea    0xe86(%rip),%rax
lea    0xf40(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <diferencia@plt>
mov    %eax,%ebx
lea    0xe9c(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,%edi
call   1030 <desencriptar@plt>
test   %rax,%rax
lea    0xede(%rip),%rax
lea    0xef0(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Introduce clave (numero) para encriptar: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Error al encriptar\0A\00"
@.str.3 = [23 x i8] c"Encriptado con exito!\0A\00"
@.str.4 = [11 x i8] c"salida.txt\00"
@.str.5 = [66 x i8] c"Error al calcular porcentaje de cada letra en fichero encriptado\0A\00"
@.str.6 = [58 x i8] c"Calculado porcentaje de cada letra en fichero encriptado\0A\00"
@.str.7 = [16 x i8] c"diccionario.txt\00"
@.str.8 = [67 x i8] c"Error al calcular porcentaje de cada letra en fichero diccionario\0A\00"
@.str.9 = [59 x i8] c"Calculado porcentaje de cada letra en fichero diccionario\0A\00"
@.str.10 = [89 x i8] c"Calculada diferencia entre letras con mayor porcentaje de apariciones en ambos ficheros\0A\00"
@.str.11 = [23 x i8] c"Error al desencriptar\0A\00"
@.str.12 = [26 x i8] c"Desencriptado con exito!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [26 x float]
%4 = alloca [26 x float]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i64 @encriptar(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = getelementptr inbounds [26 x float], [26 x float]* %3, i64 0, i64 0
%18 = call i64 @contar(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), float* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0))
br label %24
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = getelementptr inbounds [26 x float], [26 x float]* %4, i64 0, i64 0
%26 = call i64 @contar(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), float* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
%33 = getelementptr inbounds [26 x float], [26 x float]* %3, i64 0, i64 0
%34 = getelementptr inbounds [26 x float], [26 x float]* %4, i64 0, i64 0
%35 = call i32 @diferencia(float* %33, float* %34)
store i32 %35, i32* %6
%36 = call i32 @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.10, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = call i64 @desencriptar(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %44
42: ; preds = %32
%43 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Introduce clave (numero) para encriptar: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"salida.txt\00"
@.str.7 = [16 x i8] c"diccionario.txt\00"
@str = [22 x i8] c"Encriptado con exito!\00"
@str.13 = [57 x i8] c"Calculado porcentaje de cada letra en fichero encriptado\00"
@str.14 = [58 x i8] c"Calculado porcentaje de cada letra en fichero diccionario\00"
@str.15 = [88 x i8] c"Calculada diferencia entre letras con mayor porcentaje de apariciones en ambos ficheros\00"
@str.16 = [25 x i8] c"Desencriptado con exito!\00"
@str.17 = [22 x i8] c"Error al desencriptar\00"
@str.18 = [66 x i8] c"Error al calcular porcentaje de cada letra en fichero diccionario\00"
@str.19 = [65 x i8] c"Error al calcular porcentaje de cada letra en fichero encriptado\00"
@str.20 = [19 x i8] c"Error al encriptar\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [26 x float]
%3 = alloca [26 x float]
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i64 @encriptar(i32 %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.20, i64 0, i64 0)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
%12 = bitcast [26 x float]* %2 to i8*
%13 = bitcast [26 x float]* %3 to i8*
%14 = getelementptr inbounds [26 x float], [26 x float]* %2, i64 0, i64 0
%15 = call i64 @contar(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), float* %14)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @str.13, i64 0, i64 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @str.19, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = getelementptr inbounds [26 x float], [26 x float]* %3, i64 0, i64 0
%20 = call i64 @contar(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), float* %19)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.14, i64 0, i64 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @str.18, i64 0, i64 0)
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = call i32 @diferencia(float* %14, float* %19)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @str.15, i64 0, i64 0))
%26 = call i64 @desencriptar(i32 %24)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.17, i64 0, i64 0)
%29 = call i32 @puts(i8* dereferenceable(1) %28)
ret i32 0
}