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


x86 assembly (clang, -O0):
<fdecrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2e44(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11dd <fdecrypt+0x8d>
movsbl -0x21(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x41,%eax
sub    -0x20(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x41,%edi
mov    -0x38(%rbp),%rsi
call   1050 <putc@plt>
jmp    118e <fdecrypt+0x3e>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdecrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbp
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
lea    0xe88(%rip),%rsi
mov    %rbp,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1070 <getc@plt>
mov    0x2e54(%rip),%r12
cmp    (%r12),%al
je     11fa <fdecrypt+0xaa>
mov    $0xffffffbf,%ebx
sub    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <toupper@plt>
add    %ebx,%eax
cltd
idiv   %r14d
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
neg    %edx
lea    (%rax,%rdx,1),%edi
add    $0x41,%edi
mov    %rbp,%rsi
call   1050 <putc@plt>
mov    %r13,%rdi
call   1070 <getc@plt>
cmp    (%r12),%al
jne    11b0 <fdecrypt+0x60>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32*
%12 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %11
%15 = load i8*, i8** %7
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %12
br label %17
17: ; preds = %24, %4
%18 = load i32*, i32** %11
%19 = call signext i8 @getc(i32* %18)
store i8 %19, i8* %10
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %36
24: ; preds = %17
%25 = load i8, i8* %10
%26 = call i32 @toupper(i8 signext %25)
%27 = sub nsw i32 %26, 65
%28 = load i32, i32* %9
%29 = sub nsw i32 %27, %28
%30 = load i32, i32* %8
%31 = sdiv i32 %29, %30
%32 = srem i32 %31, 26
%33 = add nsw i32 %32, 65
%34 = load i32*, i32** %12
%35 = call i32 @putc(i32 %33, i32* %34)
br label %17
36: ; preds = %17
%37 = load i32*, i32** %12
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** %11
%40 = call i32 @fclose(i32* %39)
%41 = load i32*, i32** %5
ret i32* %41
}

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