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


x86 assembly (clang, -O0):
<fencrypt>:
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    0xe7f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2e34(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ff <fencrypt+0x9f>
movsbl -0x21(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    11fa <fencrypt+0x9a>
movsbl -0x21(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x41,%eax
add    -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x41,%edi
mov    -0x38(%rbp),%rsi
call   1060 <putc@plt>
jmp    119e <fencrypt+0x3e>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fencrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbx
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1080 <getc@plt>
mov    0x2e44(%rip),%r13
cmp    0x0(%r13),%al
jne    11c8 <fencrypt+0x68>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
add    $0xffffffbf,%r15d
jmp    11de <fencrypt+0x7e>
xchg   %ax,%ax
mov    %rbp,%rdi
call   1080 <getc@plt>
cmp    0x0(%r13),%al
je     11aa <fencrypt+0x4a>
movsbl %al,%ebx
mov    %ebx,%edi
call   1050 <isspace@plt>
test   %eax,%eax
jne    11d0 <fencrypt+0x70>
mov    %ebx,%edi
call   1030 <toupper@plt>
add    %r15d,%eax
imul   %r14d,%eax
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    %r12,%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, 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 = %40, %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 %41
24: ; preds = %17
%25 = load i8, i8* %10
%26 = call i32 @isspace(i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %40, label %28
28: ; preds = %24
%29 = load i8, i8* %10
%30 = call i32 @toupper(i8 signext %29)
%31 = sub nsw i32 %30, 65
%32 = load i32, i32* %9
%33 = add nsw i32 %31, %32
%34 = load i32, i32* %8
%35 = mul nsw i32 %33, %34
%36 = srem i32 %35, 26
%37 = add nsw i32 %36, 65
%38 = load i32*, i32** %12
%39 = call i32 @putc(i32 %37, i32* %38)
br label %40
40: ; preds = %28, %24
br label %17
41: ; preds = %17
%42 = load i32*, i32** %11
%43 = call i32 @fclose(i32* %42)
%44 = load i32*, i32** %12
%45 = call i32 @fclose(i32* %44)
%46 = load i32*, i32** %5
ret i32* %46
}

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