#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 */
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t min(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ size(int /*<<< orphan*/ *);
void apply(char *cyphername, char *filename) {
  FILE *cypher = fopen(cyphername, "rb");
  if (!cypher)
    printf("CANT OPEN %s\n", cyphername);
  FILE *file = fopen(filename, "rb");
  if (!file)
    printf("CANT OPEN %s\n", filename);
  long i = 0;
  size_t num_bytes = min(size(file), size(cypher));
  for (; i < num_bytes; i++) {
    int f = fgetc(file);
    int c = fgetc(cypher);
    printf("%c", f ^ c);
  }
}


x86 assembly (clang, -O0):
<apply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1191 <apply+0x41>
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c2 <apply+0x72>
mov    -0x10(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <size@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <size@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1238 <apply+0xe8>
mov    -0x20(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%esi
xor    -0x38(%rbp),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11ed <apply+0x9d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1193 <apply+0x33>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe66(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11bb <apply+0x5b>
lea    0xe52(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1040 <size@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <size@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <min@plt>
test   %rax,%rax
je     1201 <apply+0xa1>
mov    %rax,%rbx
xchg   %ax,%ax
mov    %r12,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1070 <fgetc@plt>
xor    %eax,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jne    11e0 <apply+0x80>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [14 x i8] c"CANT OPEN %s\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define void @apply(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %2
%19 = load i8*, i8** %4
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %18
store i64 0, i64* %7
%27 = load i32*, i32** %6
%28 = call i32 @size(i32* %27)
%29 = load i32*, i32** %5
%30 = call i32 @size(i32* %29)
%31 = call i64 @min(i32 %28, i32 %30)
store i64 %31, i64* %8
br label %32
32: ; preds = %45, %26
%33 = load i64, i64* %7
%34 = load i64, i64* %8
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load i32*, i32** %6
%38 = call i32 @fgetc(i32* %37)
store i32 %38, i32* %9
%39 = load i32*, i32** %5
%40 = call i32 @fgetc(i32* %39)
store i32 %40, i32* %10
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = xor i32 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %36
%46 = load i64, i64* %7
%47 = add nsw i64 %46, 1
store i64 %47, i64* %7
br label %32
48: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [14 x i8] c"CANT OPEN %s\0A\00"
define void @apply(i8* %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %2
%8 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 @size(i32* %8)
%14 = tail call i32 @size(i32* %3)
%15 = tail call i64 @min(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %12, %17
%18 = phi i64 [ %23, %17 ], [ 0, %12 ]
%19 = tail call i32 @fgetc(i32* %8)
%20 = tail call i32 @fgetc(i32* %3)
%21 = xor i32 %20, %19
%22 = tail call i32 @putchar(i32 %21)
%23 = add nuw i64 %18, 1
%24 = icmp eq i64 %23, %15
br i1 %24, label %25, label %17
25: ; preds = %17, %12
ret void
}