#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 */
scalar_t__ encryptDecrypt(int /*<<< orphan*/, unsigned short, unsigned short);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ keygen(unsigned short, unsigned short *, unsigned short *);
int /*<<< orphan*/ perror(char *);
scalar_t__ powerOf2(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char usage[] = "sdes by Jason Giancono\nUSAGE: sdes <FLAG> <input filename> "
                 "<output filename> <seed key (in base 2)>\nFLAGS:\t\t-d: "
                 "decrypt\n\t\t-e: encrypt\n";
  if (argc != 5)
    printf("%s", usage);
  else {
    unsigned short seedkey, kOne, kTwo, ii, error;
    FILE *output, *input;
    char temp;
    error = 0;
    seedkey = 0;
    for (ii = 0; ii < 10; ii++) {
      if (argv[4][ii] == '1') {
        seedkey += powerOf2(9 - ii);
      }
    }
    keygen(seedkey, &kOne, &kTwo);
    input = fopen(argv[2], "r");
    if ((input != 0) && ((output = fopen(argv[3], "w")) != 0)) {
      if (!strcmp(argv[1], "-e")) {
        printf("\n-----\nEncoding\n-----\n");
        while ((feof(input) == 0) && (ferror(input) == 0) &&
               (ferror(output) == 0)) {
          temp = (char)(encryptDecrypt(fgetc(input), kOne, kTwo));
          if (feof(input) == 0)
            fputc(temp, output);
        }
      } else if (!strcmp(argv[1], "-d")) {
        printf("\n-----\nDecoding\n-----\n");
        while ((feof(input) == 0) && (ferror(input) == 0) &&
               (ferror(output) == 0)) {
          temp = (char)(encryptDecrypt(fgetc(input), kTwo, kOne));
          if (feof(input) == 0)
            fputc(temp, output);
        }
      } else
        printf("%s", usage);
      printf("\n-----\nDone\n-----\n");
    } else {
      error = 1;
      printf("%s", usage);
    }
    if ((error == 1) || (ferror(input) != 0) || (ferror(output) != 0))
      perror("A read/write error occurred");
    if (output != 0)
      fclose(output);
    if (input != 0)
      fclose(input);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x87,%edx
call   10c0 <memcpy@plt>
cmpl   $0x5,-0x8(%rbp)
je     1225 <main+0x55>
lea    -0xa0(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15d3 <main+0x403>
movw   $0x0,-0xaa(%rbp)
movw   $0x0,-0xa2(%rbp)
movw   $0x0,-0xa8(%rbp)
movzwl -0xa8(%rbp),%eax
cmp    $0xa,%eax
jge    12af <main+0xdf>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzwl -0xa8(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    1293 <main+0xc3>
movzwl -0xa8(%rbp),%eax
mov    $0x9,%edi
sub    %eax,%edi
call   10d0 <powerOf2@plt>
mov    %rax,%rcx
movzwl -0xa2(%rbp),%eax
add    %rcx,%rax
mov    %ax,-0xa2(%rbp)
jmp    1298 <main+0xc8>
mov    -0xa8(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa8(%rbp)
jmp    1240 <main+0x70>
lea    -0xa4(%rbp),%rsi
lea    -0xa6(%rbp),%rdx
movzwl -0xa2(%rbp),%edi
call   1060 <keygen@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb2(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xc0(%rbp)
cmpq   $0x0,-0xc0(%rbp)
je     1534 <main+0x364>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd8b(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
je     1534 <main+0x364>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd68(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    140f <main+0x23f>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc0(%rbp),%rdi
call   10b0 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc2(%rbp)
jne    139d <main+0x1cd>
mov    -0xc0(%rbp),%rdi
call   1030 <ferror@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc2(%rbp)
jne    139d <main+0x1cd>
mov    -0xb8(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0xc2(%rbp)
mov    -0xc2(%rbp),%al
test   $0x1,%al
jne    13b0 <main+0x1e0>
jmp    140a <main+0x23a>
mov    -0xc0(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,%edi
mov    -0xa4(%rbp),%ax
movzwl %ax,%esi
movzwl -0xa6(%rbp),%edx
call   1040 <encryptDecrypt@plt>
mov    %al,-0xc1(%rbp)
mov    -0xc0(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%rax
jne    1405 <main+0x235>
mov    -0xc1(%rbp),%al
mov    -0xb8(%rbp),%rsi
movsbl %al,%edi
call   1090 <fputc@plt>
jmp    1342 <main+0x172>
jmp    1521 <main+0x351>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc8a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1507 <main+0x337>
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc0(%rbp),%rdi
call   10b0 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc3(%rbp)
jne    1495 <main+0x2c5>
mov    -0xc0(%rbp),%rdi
call   1030 <ferror@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xc3(%rbp)
jne    1495 <main+0x2c5>
mov    -0xb8(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0xc3(%rbp)
mov    -0xc3(%rbp),%al
test   $0x1,%al
jne    14a8 <main+0x2d8>
jmp    1502 <main+0x332>
mov    -0xc0(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,%edi
mov    -0xa6(%rbp),%ax
movzwl %ax,%esi
movzwl -0xa4(%rbp),%edx
call   1040 <encryptDecrypt@plt>
mov    %al,-0xc1(%rbp)
mov    -0xc0(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%rax
jne    14fd <main+0x32d>
mov    -0xc1(%rbp),%al
mov    -0xb8(%rbp),%rsi
movsbl %al,%edi
call   1090 <fputc@plt>
jmp    143a <main+0x26a>
jmp    151c <main+0x34c>
lea    -0xa0(%rbp),%rsi
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1521 <main+0x351>
lea    0xb9a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1552 <main+0x382>
movw   $0x1,-0xaa(%rbp)
lea    -0xa0(%rbp),%rsi
lea    0xb3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movzwl -0xaa(%rbp),%eax
cmp    $0x1,%eax
je     158e <main+0x3be>
mov    -0xc0(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    158e <main+0x3be>
mov    -0xb8(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     159a <main+0x3ca>
lea    0xb40(%rip),%rdi
call   10f0 <perror@plt>
cmpq   $0x0,-0xb8(%rbp)
je     15b4 <main+0x3e4>
mov    -0xb8(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0xc0(%rbp)
je     15ce <main+0x3fe>
mov    -0xc0(%rbp),%rdi
call   1050 <fclose@plt>
jmp    15d3 <main+0x403>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe06(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x87,%edx
call   10d0 <memcpy@plt>
cmp    $0x5,%ebx
jne    1230 <main+0x50>
mov    0x20(%r14),%rax
cmpb   $0x31,(%rax)
jne    1248 <main+0x68>
mov    $0x9,%edi
call   10e0 <powerOf2@plt>
mov    %rax,%rbx
mov    0x20(%r14),%rax
cmpb   $0x31,0x1(%rax)
je     1250 <main+0x70>
jmp    1260 <main+0x80>
lea    0xe50(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    138c <main+0x1ac>
xor    %ebx,%ebx
cmpb   $0x31,0x1(%rax)
jne    1260 <main+0x80>
mov    $0x8,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x2(%rax)
je     139d <main+0x1bd>
cmpb   $0x31,0x3(%rax)
je     13b7 <main+0x1d7>
cmpb   $0x31,0x4(%rax)
je     13d1 <main+0x1f1>
cmpb   $0x31,0x5(%rax)
je     13eb <main+0x20b>
cmpb   $0x31,0x6(%rax)
je     1405 <main+0x225>
cmpb   $0x31,0x7(%rax)
je     141f <main+0x23f>
cmpb   $0x31,0x8(%rax)
je     1439 <main+0x259>
cmpb   $0x31,0x9(%rax)
jne    12b5 <main+0xd5>
xor    %edi,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
movzwl %bx,%edi
lea    0xe(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1070 <keygen@plt>
mov    0x10(%r14),%rdi
lea    0xdb8(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
je     1549 <main+0x369>
mov    0x18(%r14),%rdi
lea    0xd9e(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1549 <main+0x369>
mov    %rax,%r15
mov    0x8(%r14),%rbx
lea    0xd84(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     1458 <main+0x278>
lea    0xd70(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     14cd <main+0x2ed>
lea    0xd4f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd7b(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    155f <main+0x37f>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    155f <main+0x37f>
test   %r15,%r15
je     137f <main+0x19f>
mov    %r15,%rdi
call   1060 <fclose@plt>
test   %r12,%r12
je     138c <main+0x1ac>
mov    %r12,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x7,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x3(%rax)
jne    1274 <main+0x94>
mov    $0x6,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x4(%rax)
jne    127e <main+0x9e>
mov    $0x5,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x5(%rax)
jne    1288 <main+0xa8>
mov    $0x4,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x6(%rax)
jne    1292 <main+0xb2>
mov    $0x3,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x7(%rax)
jne    129c <main+0xbc>
mov    $0x2,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x8(%rax)
jne    12a6 <main+0xc6>
mov    $0x1,%edi
call   10e0 <powerOf2@plt>
add    %eax,%ebx
mov    0x20(%r14),%rax
cmpb   $0x31,0x9(%rax)
je     12ac <main+0xcc>
jmp    12b5 <main+0xd5>
lea    0xc51(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   10c0 <feof@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r12,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r12,%rdi
call   1090 <fgetc@plt>
movzwl 0xe(%rsp),%esi
movzwl 0xc(%rsp),%edx
mov    %eax,%edi
call   1050 <encryptDecrypt@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   10c0 <feof@plt>
test   %rax,%rax
jne    1464 <main+0x284>
movsbl %bl,%edi
mov    %r15,%rsi
call   10a0 <fputc@plt>
jmp    1464 <main+0x284>
lea    0xc04(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax)
mov    %r12,%rdi
call   10c0 <feof@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r12,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1344 <main+0x164>
mov    %r12,%rdi
call   1090 <fgetc@plt>
movzwl 0xc(%rsp),%esi
movzwl 0xe(%rsp),%edx
mov    %eax,%edi
call   1050 <encryptDecrypt@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   10c0 <feof@plt>
test   %rax,%rax
jne    14e0 <main+0x300>
movsbl %bl,%edi
mov    %r15,%rsi
call   10a0 <fputc@plt>
jmp    14e0 <main+0x300>
lea    0xb37(%rip),%rdi
xor    %r15d,%r15d
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb2e(%rip),%rdi
call   1100 <perror@plt>
test   %r15,%r15
jne    1377 <main+0x197>
jmp    137f <main+0x19f>

LLVM IR (-O0):
@__const.main.usage = [135 x i8] c"sdes by Jason Giancono\0AUSAGE: sdes <FLAG> <input filename> <output filename> <seed key (in base 2)>\0AFLAGS:\09\09-d: decrypt\0A\09\09-e: encrypt\0A\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"-e\00"
@.str.4 = [23 x i8] c"\0A-----\0AEncoding\0A-----\0A\00"
@.str.5 = [3 x i8] c"-d\00"
@.str.6 = [23 x i8] c"\0A-----\0ADecoding\0A-----\0A\00"
@.str.7 = [19 x i8] c"\0A-----\0ADone\0A-----\0A\00"
@.str.8 = [28 x i8] c"A read/write error occurred\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [135 x i8]
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca i16
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [135 x i8]* %6 to i8*
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 5
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = getelementptr inbounds [135 x i8], [135 x i8]* %6, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %176
21: ; preds = %2
store i16 0, i16* %11
store i16 0, i16* %7
store i16 0, i16* %10
br label %22
22: ; preds = %46, %21
%23 = load i16, i16* %10
%24 = zext i16 %23 to i32
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %49
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 4
%29 = load i8*, i8** %28
%30 = load i16, i16* %10
%31 = zext i16 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 49
br i1 %35, label %36, label %45
36: ; preds = %26
%37 = load i16, i16* %10
%38 = zext i16 %37 to i32
%39 = sub nsw i32 9, %38
%40 = call i64 @powerOf2(i32 %39)
%41 = load i16, i16* %7
%42 = zext i16 %41 to i64
%43 = add nsw i64 %42, %40
%44 = trunc i64 %43 to i16
store i16 %44, i16* %7
br label %45
45: ; preds = %36, %26
br label %46
46: ; preds = %45
%47 = load i16, i16* %10
%48 = add i16 %47, 1
store i16 %48, i16* %10
br label %22
49: ; preds = %22
%50 = load i16, i16* %7
%51 = call i32 @keygen(i16 zeroext %50, i16* %8, i16* %9)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %55, i32** %13
%56 = load i32*, i32** %13
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %146
58: ; preds = %49
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 3
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %62, i32** %12
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %146
64: ; preds = %58
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %102, label %70
70: ; preds = %64
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %100, %70
%73 = load i32*, i32** %13
%74 = call i64 @feof(i32* %73)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %84
76: ; preds = %72
%77 = load i32*, i32** %13
%78 = call i64 @ferror(i32* %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = load i32*, i32** %12
%82 = call i64 @ferror(i32* %81)
%83 = icmp eq i64 %82, 0
br label %84
84: ; preds = %80, %76, %72
%85 = phi i1 [ false, %76 ], [ false, %72 ], [ %83, %80 ]
br i1 %85, label %86, label %101
86: ; preds = %84
%87 = load i32*, i32** %13
%88 = call i32 @fgetc(i32* %87)
%89 = load i16, i16* %8
%90 = load i16, i16* %9
%91 = call i64 @encryptDecrypt(i32 %88, i16 zeroext %89, i16 zeroext %90)
%92 = trunc i64 %91 to i8
store i8 %92, i8* %14
%93 = load i32*, i32** %13
%94 = call i64 @feof(i32* %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %100
96: ; preds = %86
%97 = load i8, i8* %14
%98 = load i32*, i32** %12
%99 = call i32 @fputc(i8 signext %97, i32* %98)
br label %100
100: ; preds = %96, %86
br label %72
101: ; preds = %84
br label %144
102: ; preds = %64
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 1
%105 = load i8*, i8** %104
%106 = call i32 @strcmp(i8* %105, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%107 = icmp ne i32 %106, 0
br i1 %107, label %140, label %108
108: ; preds = %102
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %110
110: ; preds = %138, %108
%111 = load i32*, i32** %13
%112 = call i64 @feof(i32* %111)
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %122
114: ; preds = %110
%115 = load i32*, i32** %13
%116 = call i64 @ferror(i32* %115)
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %114
%119 = load i32*, i32** %12
%120 = call i64 @ferror(i32* %119)
%121 = icmp eq i64 %120, 0
br label %122
122: ; preds = %118, %114, %110
%123 = phi i1 [ false, %114 ], [ false, %110 ], [ %121, %118 ]
br i1 %123, label %124, label %139
124: ; preds = %122
%125 = load i32*, i32** %13
%126 = call i32 @fgetc(i32* %125)
%127 = load i16, i16* %9
%128 = load i16, i16* %8
%129 = call i64 @encryptDecrypt(i32 %126, i16 zeroext %127, i16 zeroext %128)
%130 = trunc i64 %129 to i8
store i8 %130, i8* %14
%131 = load i32*, i32** %13
%132 = call i64 @feof(i32* %131)
%133 = icmp eq i64 %132, 0
br i1 %133, label %134, label %138
134: ; preds = %124
%135 = load i8, i8* %14
%136 = load i32*, i32** %12
%137 = call i32 @fputc(i8 signext %135, i32* %136)
br label %138
138: ; preds = %134, %124
br label %110
139: ; preds = %122
br label %143
140: ; preds = %102
%141 = getelementptr inbounds [135 x i8], [135 x i8]* %6, i64 0, i64 0
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %141)
br label %143
143: ; preds = %140, %139
br label %144
144: ; preds = %143, %101
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %149
146: ; preds = %58, %49
store i16 1, i16* %11
%147 = getelementptr inbounds [135 x i8], [135 x i8]* %6, i64 0, i64 0
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %147)
br label %149
149: ; preds = %146, %144
%150 = load i16, i16* %11
%151 = zext i16 %150 to i32
%152 = icmp eq i32 %151, 1
br i1 %152, label %161, label %153
153: ; preds = %149
%154 = load i32*, i32** %13
%155 = call i64 @ferror(i32* %154)
%156 = icmp ne i64 %155, 0
br i1 %156, label %161, label %157
157: ; preds = %153
%158 = load i32*, i32** %12
%159 = call i64 @ferror(i32* %158)
%160 = icmp ne i64 %159, 0
br i1 %160, label %161, label %163
161: ; preds = %157, %153, %149
%162 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %163
163: ; preds = %161, %157
%164 = load i32*, i32** %12
%165 = icmp ne i32* %164, null
br i1 %165, label %166, label %169
166: ; preds = %163
%167 = load i32*, i32** %12
%168 = call i32 @fclose(i32* %167)
br label %169
169: ; preds = %166, %163
%170 = load i32*, i32** %13
%171 = icmp ne i32* %170, null
br i1 %171, label %172, label %175
172: ; preds = %169
%173 = load i32*, i32** %13
%174 = call i32 @fclose(i32* %173)
br label %175
175: ; preds = %172, %169
br label %176
176: ; preds = %175, %18
ret i32 0
}

LLVM IR (-O2):
@__const.main.usage = [135 x i8] c"sdes by Jason Giancono\0AUSAGE: sdes <FLAG> <input filename> <output filename> <seed key (in base 2)>\0AFLAGS:\09\09-d: decrypt\0A\09\09-e: encrypt\0A\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"-e\00"
@.str.5 = [3 x i8] c"-d\00"
@.str.8 = [28 x i8] c"A read/write error occurred\00"
@str = [22 x i8] c"\0A-----\0AEncoding\0A-----\00"
@str.9 = [18 x i8] c"\0A-----\0ADone\0A-----\00"
@str.10 = [22 x i8] c"\0A-----\0ADecoding\0A-----\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [135 x i8]
%4 = alloca i16
%5 = alloca i16
%6 = getelementptr inbounds [135 x i8], [135 x i8]* %3, i64 0, i64 0
%7 = icmp eq i32 %0, 5
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %208
10: ; preds = %2
%11 = bitcast i16* %4 to i8*
%12 = bitcast i16* %5 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 4
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 49
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = tail call i64 @powerOf2(i32 9)
%19 = trunc i64 %18 to i16
%20 = load i8*, i8** %13
br label %21
21: ; preds = %10, %17
%22 = phi i8* [ %20, %17 ], [ %14, %10 ]
%23 = phi i16 [ %19, %17 ], [ 0, %10 ]
%24 = getelementptr inbounds i8, i8* %22, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 49
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = tail call i64 @powerOf2(i32 8)
%29 = trunc i64 %28 to i16
%30 = add i16 %23, %29
%31 = load i8*, i8** %13
br label %32
32: ; preds = %27, %21
%33 = phi i8* [ %31, %27 ], [ %22, %21 ]
%34 = phi i16 [ %30, %27 ], [ %23, %21 ]
%35 = getelementptr inbounds i8, i8* %33, i64 2
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 49
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = tail call i64 @powerOf2(i32 7)
%40 = trunc i64 %39 to i16
%41 = add i16 %34, %40
%42 = load i8*, i8** %13
br label %43
43: ; preds = %38, %32
%44 = phi i8* [ %42, %38 ], [ %33, %32 ]
%45 = phi i16 [ %41, %38 ], [ %34, %32 ]
%46 = getelementptr inbounds i8, i8* %44, i64 3
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 49
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = tail call i64 @powerOf2(i32 6)
%51 = trunc i64 %50 to i16
%52 = add i16 %45, %51
%53 = load i8*, i8** %13
br label %54
54: ; preds = %49, %43
%55 = phi i8* [ %53, %49 ], [ %44, %43 ]
%56 = phi i16 [ %52, %49 ], [ %45, %43 ]
%57 = getelementptr inbounds i8, i8* %55, i64 4
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 49
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = tail call i64 @powerOf2(i32 5)
%62 = trunc i64 %61 to i16
%63 = add i16 %56, %62
%64 = load i8*, i8** %13
br label %65
65: ; preds = %60, %54
%66 = phi i8* [ %64, %60 ], [ %55, %54 ]
%67 = phi i16 [ %63, %60 ], [ %56, %54 ]
%68 = getelementptr inbounds i8, i8* %66, i64 5
%69 = load i8, i8* %68
%70 = icmp eq i8 %69, 49
br i1 %70, label %71, label %76
71: ; preds = %65
%72 = tail call i64 @powerOf2(i32 4)
%73 = trunc i64 %72 to i16
%74 = add i16 %67, %73
%75 = load i8*, i8** %13
br label %76
76: ; preds = %71, %65
%77 = phi i8* [ %75, %71 ], [ %66, %65 ]
%78 = phi i16 [ %74, %71 ], [ %67, %65 ]
%79 = getelementptr inbounds i8, i8* %77, i64 6
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 49
br i1 %81, label %82, label %87
82: ; preds = %76
%83 = tail call i64 @powerOf2(i32 3)
%84 = trunc i64 %83 to i16
%85 = add i16 %78, %84
%86 = load i8*, i8** %13
br label %87
87: ; preds = %82, %76
%88 = phi i8* [ %86, %82 ], [ %77, %76 ]
%89 = phi i16 [ %85, %82 ], [ %78, %76 ]
%90 = getelementptr inbounds i8, i8* %88, i64 7
%91 = load i8, i8* %90
%92 = icmp eq i8 %91, 49
br i1 %92, label %93, label %98
93: ; preds = %87
%94 = tail call i64 @powerOf2(i32 2)
%95 = trunc i64 %94 to i16
%96 = add i16 %89, %95
%97 = load i8*, i8** %13
br label %98
98: ; preds = %93, %87
%99 = phi i8* [ %97, %93 ], [ %88, %87 ]
%100 = phi i16 [ %96, %93 ], [ %89, %87 ]
%101 = getelementptr inbounds i8, i8* %99, i64 8
%102 = load i8, i8* %101
%103 = icmp eq i8 %102, 49
br i1 %103, label %104, label %109
104: ; preds = %98
%105 = tail call i64 @powerOf2(i32 1)
%106 = trunc i64 %105 to i16
%107 = add i16 %100, %106
%108 = load i8*, i8** %13
br label %109
109: ; preds = %104, %98
%110 = phi i8* [ %108, %104 ], [ %99, %98 ]
%111 = phi i16 [ %107, %104 ], [ %100, %98 ]
%112 = getelementptr inbounds i8, i8* %110, i64 9
%113 = load i8, i8* %112
%114 = icmp eq i8 %113, 49
br i1 %114, label %115, label %119
115: ; preds = %109
%116 = tail call i64 @powerOf2(i32 0)
%117 = trunc i64 %116 to i16
%118 = add i16 %111, %117
br label %119
119: ; preds = %115, %109
%120 = phi i16 [ %118, %115 ], [ %111, %109 ]
%121 = call i32 @keygen(i16 zeroext %120, i16* %4, i16* %5)
%122 = getelementptr inbounds i8*, i8** %1, i64 2
%123 = load i8*, i8** %122
%124 = call i32* @fopen(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%125 = icmp eq i32* %124, null
br i1 %125, label %187, label %126
126: ; preds = %119
%127 = getelementptr inbounds i8*, i8** %1, i64 3
%128 = load i8*, i8** %127
%129 = call i32* @fopen(i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%130 = icmp eq i32* %129, null
br i1 %130, label %187, label %131
131: ; preds = %126
%132 = getelementptr inbounds i8*, i8** %1, i64 1
%133 = load i8*, i8** %132
%134 = call i32 @strcmp(i8* dereferenceable(1) %133, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %159
136: ; preds = %131
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%138 = call i64 @feof(i32* %124)
%139 = icmp eq i64 %138, 0
br i1 %139, label %140, label %189
140: ; preds = %136, %156
%141 = call i64 @ferror(i32* %124)
%142 = icmp eq i64 %141, 0
br i1 %142, label %143, label %189
143: ; preds = %140
%144 = call i64 @ferror(i32* %129)
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %189
146: ; preds = %143
%147 = call i32 @fgetc(i32* %124)
%148 = load i16, i16* %4
%149 = load i16, i16* %5
%150 = call i64 @encryptDecrypt(i32 %147, i16 zeroext %148, i16 zeroext %149)
%151 = call i64 @feof(i32* %124)
%152 = icmp eq i64 %151, 0
br i1 %152, label %153, label %156
153: ; preds = %146
%154 = trunc i64 %150 to i8
%155 = call i32 @fputc(i8 signext %154, i32* %129)
br label %156
156: ; preds = %153, %146
%157 = call i64 @feof(i32* %124)
%158 = icmp eq i64 %157, 0
br i1 %158, label %140, label %189
159: ; preds = %131
%160 = call i32 @strcmp(i8* dereferenceable(1) %133, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%161 = icmp eq i32 %160, 0
br i1 %161, label %162, label %185
162: ; preds = %159
%163 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%164 = call i64 @feof(i32* %124)
%165 = icmp eq i64 %164, 0
br i1 %165, label %166, label %189
166: ; preds = %162, %182
%167 = call i64 @ferror(i32* %124)
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %189
169: ; preds = %166
%170 = call i64 @ferror(i32* %129)
%171 = icmp eq i64 %170, 0
br i1 %171, label %172, label %189
172: ; preds = %169
%173 = call i32 @fgetc(i32* %124)
%174 = load i16, i16* %5
%175 = load i16, i16* %4
%176 = call i64 @encryptDecrypt(i32 %173, i16 zeroext %174, i16 zeroext %175)
%177 = call i64 @feof(i32* %124)
%178 = icmp eq i64 %177, 0
br i1 %178, label %179, label %182
179: ; preds = %172
%180 = trunc i64 %176 to i8
%181 = call i32 @fputc(i8 signext %180, i32* %129)
br label %182
182: ; preds = %179, %172
%183 = call i64 @feof(i32* %124)
%184 = icmp eq i64 %183, 0
br i1 %184, label %166, label %189
185: ; preds = %159
%186 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %189
187: ; preds = %119, %126
%188 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %196
189: ; preds = %169, %166, %182, %156, %140, %143, %162, %136, %185
%190 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
%191 = call i64 @ferror(i32* %124)
%192 = icmp eq i64 %191, 0
br i1 %192, label %193, label %196
193: ; preds = %189
%194 = call i64 @ferror(i32* %129)
%195 = icmp eq i64 %194, 0
br i1 %195, label %199, label %196
196: ; preds = %187, %193, %189
%197 = phi i32* [ null, %187 ], [ %129, %193 ], [ %129, %189 ]
%198 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %199
199: ; preds = %196, %193
%200 = phi i32* [ %197, %196 ], [ %129, %193 ]
%201 = icmp eq i32* %200, null
br i1 %201, label %204, label %202
202: ; preds = %199
%203 = call i32 @fclose(i32* %200)
br label %204
204: ; preds = %202, %199
br i1 %125, label %207, label %205
205: ; preds = %204
%206 = call i32 @fclose(i32* %124)
br label %207
207: ; preds = %205, %204
br label %208
208: ; preds = %207, %8
ret i32 0
}