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


x86 assembly (clang, -O0):
<encriptar>:
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    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a3 <encriptar+0x53>
lea    0xe86(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bb <encriptar+0x6b>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130f <encriptar+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 <encriptar+0x1a6>
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jne    1201 <encriptar+0xb1>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12e5 <encriptar+0x195>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1225 <encriptar+0xd5>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12e0 <encriptar+0x190>
movsbl -0x19(%rbp),%eax
cmp    $0x2e,%eax
jne    1249 <encriptar+0xf9>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12db <encriptar+0x18b>
movsbl -0x19(%rbp),%eax
cmp    $0x2c,%eax
jne    126d <encriptar+0x11d>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d6 <encriptar+0x186>
movsbl -0x19(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x5a,%eax
jle    128d <encriptar+0x13d>
movsbl -0x19(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x61,%eax
jl     129d <encriptar+0x14d>
movsbl -0x19(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x7a,%eax
jle    12bb <encriptar+0x16b>
movsbl -0x19(%rbp),%eax
add    -0x20(%rbp),%eax
sub    $0x19,%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d1 <encriptar+0x181>
movsbl -0x19(%rbp),%eax
add    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    %al,-0x1a(%rbp)
jmp    12d6 <encriptar+0x186>
jmp    12db <encriptar+0x18b>
jmp    12e0 <encriptar+0x190>
jmp    12e5 <encriptar+0x195>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    11c7 <encriptar+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):
<encriptar>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edi,%r14d
lea    0xe9d(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11bb <encriptar+0x6b>
mov    %rax,%rbx
lea    0xe91(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11bb <encriptar+0x6b>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    0x2e47(%rip),%r12
cmp    (%r12),%al
jne    11d6 <encriptar+0x86>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11cc <encriptar+0x7c>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
movabs $0x500100000400,%r13
jmp    123d <encriptar+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%eax
lea    (%rax,%r14,1),%ecx
add    $0xffffffa5,%ecx
mov    %eax,%edx
add    %r14d,%edx
lea    -0x19(%rdx),%eax
cmp    $0x6,%ecx
movzbl %al,%ecx
mov    %edx,%eax
cmovb  %ecx,%eax
cmp    $0x7b,%edx
cmovge %ecx,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
je     11a7 <encriptar+0x57>
cmp    $0x2e,%al
ja     11f0 <encriptar+0xa0>
movzbl %al,%ecx
bt     %rcx,%r13
jb     1220 <encriptar+0xd0>
jmp    11f0 <encriptar+0xa0>

LLVM IR (-O0):
@.str = [12 x i8] c"entrada.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [11 x i8] c"salida.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 @encriptar(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 ([12 x i8], [12 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 ([11 x i8], [11 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 = add nsw i32 %60, %61
%63 = icmp sgt i32 %62, 90
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 = add nsw i32 %66, %67
%69 = icmp slt i32 %68, 97
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 = add nsw i32 %72, %73
%75 = icmp sgt i32 %74, 122
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 = add nsw i32 %78, %79
%81 = sub 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 = add 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 = [12 x i8] c"entrada.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [11 x i8] c"salida.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 @encriptar(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 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 ([11 x i8], [11 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 = add nsw i32 %16, %0
%18 = add i32 %17, -91
%19 = icmp ult i32 %18, 6
%20 = icmp sgt i32 %17, 122
%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
}