#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int toupper(char);
FILE *fencrypt(char *input, char *output, int offset) {
  char p;
  FILE *plain = fopen(input, "r");
  FILE *cipher = fopen(output, "w");
  while ((p = getc(plain)) != EOF) {
    if (!isspace(p))
      putc((toupper(p) - 65 + offset) % 26 + 65, cipher);
  }
  fclose(plain);
  fclose(cipher);
}


x86 assembly (clang, -O0):
<fencrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2e37(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11f8 <fencrypt+0x98>
movsbl -0x1d(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    11f3 <fencrypt+0x93>
movsbl -0x1d(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x41,%eax
add    -0x1c(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x41,%edi
mov    -0x30(%rbp),%rsi
call   1060 <putc@plt>
jmp    119b <fencrypt+0x3b>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fencrypt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe7e(%rip),%rsi
mov    %rbp,%rdi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1080 <getc@plt>
mov    0x2e4a(%rip),%r12
cmp    (%r12),%al
jne    11bc <fencrypt+0x5c>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
add    $0xffffffbf,%r14d
jmp    11de <fencrypt+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <getc@plt>
cmp    (%r12),%al
je     11a4 <fencrypt+0x44>
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <isspace@plt>
test   %eax,%eax
jne    11d0 <fencrypt+0x70>
mov    %ebp,%edi
call   1030 <toupper@plt>
add    %r14d,%eax
movslq %eax,%rdi
imul   $0x4ec4ec4f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%edi
add    $0x41,%edi
mov    %r15,%rsi
call   1060 <putc@plt>
jmp    11d0 <fencrypt+0x70>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32* @fencrypt(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32*
%10 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %10
br label %15
15: ; preds = %36, %3
%16 = load i32*, i32** %9
%17 = call signext i8 @getc(i32* %16)
store i8 %17, i8* %8
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %37
22: ; preds = %15
%23 = load i8, i8* %8
%24 = call i32 @isspace(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %36, label %26
26: ; preds = %22
%27 = load i8, i8* %8
%28 = call i32 @toupper(i8 signext %27)
%29 = sub nsw i32 %28, 65
%30 = load i32, i32* %7
%31 = add nsw i32 %29, %30
%32 = srem i32 %31, 26
%33 = add nsw i32 %32, 65
%34 = load i32*, i32** %10
%35 = call i32 @putc(i32 %33, i32* %34)
br label %36
36: ; preds = %26, %22
br label %15
37: ; preds = %15
%38 = load i32*, i32** %9
%39 = call i32 @fclose(i32* %38)
%40 = load i32*, i32** %10
%41 = call i32 @fclose(i32* %40)
%42 = load i32*, i32** %4
ret i32* %42
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@EOF = global i8 0
define noalias i32* @fencrypt(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call signext i8 @getc(i32* %4)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %25, label %9
9: ; preds = %3
%10 = add i32 %2, -65
br label %11
11: ; preds = %9, %21
%12 = phi i8 [ %6, %9 ], [ %22, %21 ]
%13 = tail call i32 @isspace(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = tail call i32 @toupper(i8 signext %12)
%17 = add i32 %10, %16
%18 = srem i32 %17, 26
%19 = add nsw i32 %18, 65
%20 = tail call i32 @putc(i32 %19, i32* %5)
br label %21
21: ; preds = %15, %11
%22 = tail call signext i8 @getc(i32* %4)
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %25, label %11
25: ; preds = %21, %3
%26 = tail call i32 @fclose(i32* %4)
%27 = tail call i32 @fclose(i32* %5)
ret i32* undef
}