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


x86 assembly (clang, -O0):
<fdecrypt>:
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    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2e47(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d6 <fdecrypt+0x86>
movsbl -0x1d(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x41,%eax
sub    -0x1c(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x41,%edi
mov    -0x30(%rbp),%rsi
call   1050 <putc@plt>
jmp    118b <fdecrypt+0x3b>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdecrypt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%rbx
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <getc@plt>
mov    0x2e5a(%rip),%r12
cmp    (%r12),%al
je     11e4 <fdecrypt+0x94>
mov    $0xffffffbf,%ebp
sub    %r15d,%ebp
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <toupper@plt>
add    %ebp,%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    %rbx,%rsi
call   1050 <putc@plt>
mov    %r14,%rdi
call   1070 <getc@plt>
cmp    (%r12),%al
jne    11a0 <fdecrypt+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32* @fdecrypt(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 = %22, %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 %32
22: ; preds = %15
%23 = load i8, i8* %8
%24 = call i32 @toupper(i8 signext %23)
%25 = sub nsw i32 %24, 65
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = srem i32 %27, 26
%29 = add nsw i32 %28, 65
%30 = load i32*, i32** %10
%31 = call i32 @putc(i32 %29, i32* %30)
br label %15
32: ; preds = %15
%33 = load i32*, i32** %10
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %9
%36 = call i32 @fclose(i32* %35)
%37 = load i32*, i32** %4
ret i32* %37
}

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* @fdecrypt(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 %21, label %9
9: ; preds = %3
%10 = sub i32 -65, %2
br label %11
11: ; preds = %9, %11
%12 = phi i8 [ %6, %9 ], [ %18, %11 ]
%13 = tail call i32 @toupper(i8 signext %12)
%14 = add i32 %10, %13
%15 = srem i32 %14, 26
%16 = add nsw i32 %15, 65
%17 = tail call i32 @putc(i32 %16, i32* %5)
%18 = tail call signext i8 @getc(i32* %4)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %21, label %11
21: ; preds = %11, %3
%22 = tail call i32 @fclose(i32* %5)
%23 = tail call i32 @fclose(i32* %4)
ret i32* undef
}