#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int desencriptar(int c) {
  FILE *enc, *des;
  char e, d;
  int clave = c;
  if (((enc = fopen("salida.txt", "rt")) == NULL) ||
      ((des = fopen("desencriptado.txt", "wt")) == NULL)) {
    printf("Error en la apertura de ficheros\n");
    return 1;
  }
  e = fgetc(enc);
  while (e != EOF) {
    if (e == ' ')
      d = fputc(e, des);
    else if (e == '\n')
      d = fputc(e, des);
    else if (e == '.')
      d = fputc(e, des);
    else if (e == ',')
      d = fputc(e, des);
    else {
      if (((int)e - clave < 97 && (int)e - clave > 90) || ((int)e - clave < 65))
        d = fputc(e - clave + 25, des);
      else
        d = fputc(e - clave, des);
    }
    e = fgetc(enc);
  }
  fclose(enc);
  fclose(des);
  return 0;
}


x86 assembly (clang, -O0):
<desencriptar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    0xe98(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a3 <desencriptar+0x53>
lea    0xe85(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bb <desencriptar+0x6b>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130f <desencriptar+0x1bf>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2e16(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12f6 <desencriptar+0x1a6>
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jne    1201 <desencriptar+0xb1>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12e5 <desencriptar+0x195>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1225 <desencriptar+0xd5>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12e0 <desencriptar+0x190>
movsbl -0x19(%rbp),%eax
cmp    $0x2e,%eax
jne    1249 <desencriptar+0xf9>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12db <desencriptar+0x18b>
movsbl -0x19(%rbp),%eax
cmp    $0x2c,%eax
jne    126d <desencriptar+0x11d>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d6 <desencriptar+0x186>
movsbl -0x19(%rbp),%eax
sub    -0x20(%rbp),%eax
cmp    $0x61,%eax
jge    128d <desencriptar+0x13d>
movsbl -0x19(%rbp),%eax
sub    -0x20(%rbp),%eax
cmp    $0x5a,%eax
jg     129d <desencriptar+0x14d>
movsbl -0x19(%rbp),%eax
sub    -0x20(%rbp),%eax
cmp    $0x41,%eax
jge    12bb <desencriptar+0x16b>
movsbl -0x19(%rbp),%eax
sub    -0x20(%rbp),%eax
add    $0x19,%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d1 <desencriptar+0x181>
movsbl -0x19(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d6 <desencriptar+0x186>
jmp    12db <desencriptar+0x18b>
jmp    12e0 <desencriptar+0x190>
jmp    12e5 <desencriptar+0x195>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    11c7 <desencriptar+0x77>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<desencriptar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
lea    0xe9e(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b9 <desencriptar+0x69>
mov    %rax,%rbx
lea    0xe91(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b9 <desencriptar+0x69>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    0x2e48(%rip),%r15
cmp    (%r15),%al
jne    11d3 <desencriptar+0x83>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11ca <desencriptar+0x7a>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x500100000400,%r12
jmp    1218 <desencriptar+0xc8>
nop
movsbl %al,%ecx
sub    %r14d,%ecx
lea    -0x5b(%rcx),%eax
lea    0x19(%rcx),%edx
cmp    $0x6,%eax
movzbl %dl,%edx
mov    %ecx,%eax
cmovb  %edx,%eax
cmp    $0x41,%ecx
cmovl  %edx,%eax
nopl   (%rax)
movsbl %al,%edi
mov    %rbp,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%al
je     11a5 <desencriptar+0x55>
cmp    $0x2e,%al
ja     11e0 <desencriptar+0x90>
movzbl %al,%ecx
bt     %rcx,%r12
jb     1200 <desencriptar+0xb0>
jmp    11e0 <desencriptar+0x90>

LLVM IR (-O0):
@.str = [11 x i8] c"salida.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [18 x i8] c"desencriptado.txt\00"
@.str.3 = [3 x i8] c"wt\00"
@.str.4 = [34 x i8] c"Error en la apertura de ficheros\0A\00"
@EOF = global i8 0
define i32 @desencriptar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i32 %0, i32* %3
%9 = load i32, i32* %3
store i32 %9, i32* %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %5
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12, %1
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %105
17: ; preds = %12
%18 = load i32*, i32** %4
%19 = call signext i8 @fgetc(i32* %18)
store i8 %19, i8* %6
br label %20
20: ; preds = %97, %17
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %100
26: ; preds = %20
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 32
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i8, i8* %6
%32 = load i32*, i32** %5
%33 = call signext i8 @fputc(i8 signext %31, i32* %32)
store i8 %33, i8* %7
br label %97
34: ; preds = %26
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i8, i8* %6
%40 = load i32*, i32** %5
%41 = call signext i8 @fputc(i8 signext %39, i32* %40)
store i8 %41, i8* %7
br label %96
42: ; preds = %34
%43 = load i8, i8* %6
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 46
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i8, i8* %6
%48 = load i32*, i32** %5
%49 = call signext i8 @fputc(i8 signext %47, i32* %48)
store i8 %49, i8* %7
br label %95
50: ; preds = %42
%51 = load i8, i8* %6
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 44
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i8, i8* %6
%56 = load i32*, i32** %5
%57 = call signext i8 @fputc(i8 signext %55, i32* %56)
store i8 %57, i8* %7
br label %94
58: ; preds = %50
%59 = load i8, i8* %6
%60 = sext i8 %59 to i32
%61 = load i32, i32* %8
%62 = sub nsw i32 %60, %61
%63 = icmp slt i32 %62, 97
br i1 %63, label %64, label %70
64: ; preds = %58
%65 = load i8, i8* %6
%66 = sext i8 %65 to i32
%67 = load i32, i32* %8
%68 = sub nsw i32 %66, %67
%69 = icmp sgt i32 %68, 90
br i1 %69, label %76, label %70
70: ; preds = %64, %58
%71 = load i8, i8* %6
%72 = sext i8 %71 to i32
%73 = load i32, i32* %8
%74 = sub nsw i32 %72, %73
%75 = icmp slt i32 %74, 65
br i1 %75, label %76, label %85
76: ; preds = %70, %64
%77 = load i8, i8* %6
%78 = sext i8 %77 to i32
%79 = load i32, i32* %8
%80 = sub nsw i32 %78, %79
%81 = add nsw i32 %80, 25
%82 = trunc i32 %81 to i8
%83 = load i32*, i32** %5
%84 = call signext i8 @fputc(i8 signext %82, i32* %83)
store i8 %84, i8* %7
br label %93
85: ; preds = %70
%86 = load i8, i8* %6
%87 = sext i8 %86 to i32
%88 = load i32, i32* %8
%89 = sub nsw i32 %87, %88
%90 = trunc i32 %89 to i8
%91 = load i32*, i32** %5
%92 = call signext i8 @fputc(i8 signext %90, i32* %91)
store i8 %92, i8* %7
br label %93
93: ; preds = %85, %76
br label %94
94: ; preds = %93, %54
br label %95
95: ; preds = %94, %46
br label %96
96: ; preds = %95, %38
br label %97
97: ; preds = %96, %30
%98 = load i32*, i32** %4
%99 = call signext i8 @fgetc(i32* %98)
store i8 %99, i8* %6
br label %20
100: ; preds = %20
%101 = load i32*, i32** %4
%102 = call i32 @fclose(i32* %101)
%103 = load i32*, i32** %5
%104 = call i32 @fclose(i32* %103)
store i32 0, i32* %2
br label %105
105: ; preds = %100, %15
%106 = load i32, i32* %2
ret i32 %106
}

LLVM IR (-O2):
@.str = [11 x i8] c"salida.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [18 x i8] c"desencriptado.txt\00"
@.str.3 = [3 x i8] c"wt\00"
@EOF = global i8 0
@str = [33 x i8] c"Error en la apertura de ficheros\00"
define i32 @desencriptar(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4, %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %34
9: ; preds = %4
%10 = tail call signext i8 @fgetc(i32* %2)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %31, label %13
13: ; preds = %9, %25
%14 = phi i8 [ %28, %25 ], [ %10, %9 ]
switch i8 %14, label %15 [
i8 32, label %25
i8 10, label %25
i8 46, label %25
i8 44, label %25
]
15: ; preds = %13
%16 = sext i8 %14 to i32
%17 = sub nsw i32 %16, %0
%18 = add i32 %17, -91
%19 = icmp ult i32 %18, 6
%20 = icmp slt i32 %17, 65
%21 = or i1 %20, %19
%22 = trunc i32 %17 to i8
%23 = add i8 %22, 25
%24 = select i1 %21, i8 %23, i8 %22
br label %25
25: ; preds = %13, %13, %13, %15, %13
%26 = phi i8 [ %14, %13 ], [ %24, %15 ], [ %14, %13 ], [ %14, %13 ], [ %14, %13 ]
%27 = tail call signext i8 @fputc(i8 signext %26, i32* %5)
%28 = tail call signext i8 @fgetc(i32* %2)
%29 = load i8, i8* @EOF
%30 = icmp eq i8 %28, %29
br i1 %30, label %31, label %13
31: ; preds = %25, %9
%32 = tail call i32 @fclose(i32* %2)
%33 = tail call i32 @fclose(i32* %5)
br label %34
34: ; preds = %31, %7
%35 = phi i32 [ 1, %7 ], [ 0, %31 ]
ret i32 %35
}