#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 *calloc(int, int);
int /*<<< orphan*/ closeFile(int /*<<< orphan*/ *);
int decode(char);
int encode(char);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ *loadFile(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char const *, char *);
size_t strlen(char *);
int main(int argc, char const *argv[]) {
  if (argc < 3) {
    printf("Not enough arguments!\n[FILE] [e(ncode) or d(ecode)]");
    return 1;
  }
  FILE *inp = loadFile((char *)argv[1]);
  char *line = calloc(1024, sizeof(char));
  while (fgets(line, 1024, inp) != NULL) {
    for (size_t i = 0; i < strlen(line); ++i) {
      if (strcmp(argv[2], "e") == 0) {
        printf("%c", encode(line[i]));
      } else if (strcmp(argv[2], "d") == 0) {
        printf("%c", decode(line[i]));
      }
    }
  }
  free(line);
  closeFile(inp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11da <main+0x3a>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ff <main+0x15f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <loadFile@plt>
mov    %rax,-0x18(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12e6 <main+0x146>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jae    12e1 <main+0x141>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1287 <main+0xe7>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <encode@plt>
mov    %eax,%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12cb <main+0x12b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xda3(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12c6 <main+0x126>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10b0 <decode@plt>
mov    %eax,%esi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12cb <main+0x12b>
jmp    12d0 <main+0x130>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1222 <main+0x82>
jmp    11fe <main+0x5e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <closeFile@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     11d8 <main+0x28>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
jmp    12b0 <main+0x100>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
call   10d0 <loadFile@plt>
mov    %rax,%r14
mov    $0x400,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     129e <main+0xee>
lea    0xe1b(%rip),%r12
lea    0xe16(%rip),%r13
jmp    1245 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     129e <main+0xee>
cmpb   $0x0,(%rbx)
je     1230 <main+0x80>
xor    %ebp,%ebp
jmp    1271 <main+0xc1>
xchg   %ax,%ax
movsbl (%rbx,%rbp,1),%edi
call   1050 <encode@plt>
mov    %eax,%edi
call   1040 <putchar@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    %rax,%rbp
jae    1230 <main+0x80>
mov    0x10(%r15),%rdi
mov    %r12,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1250 <main+0xa0>
mov    0x10(%r15),%rdi
mov    %r13,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    1260 <main+0xb0>
movsbl (%rbx,%rbp,1),%edi
call   10c0 <decode@plt>
jmp    1259 <main+0xa9>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   10b0 <closeFile@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Not enough arguments!\0A[FILE] [e(ncode) or d(ecode)]\00"
@.str.1 = [2 x i8] c"e\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %67
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @loadFile(i8* %16)
store i32* %17, i32** %6
%18 = call i8* @calloc(i32 1024, i32 1)
store i8* %18, i8** %7
br label %19
19: ; preds = %61, %13
%20 = load i8*, i8** %7
%21 = load i32*, i32** %6
%22 = call i32* @fgets(i8* %20, i32 1024, i32* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %62
24: ; preds = %19
store i64 0, i64* %8
br label %25
25: ; preds = %58, %24
%26 = load i64, i64* %8
%27 = load i8*, i8** %7
%28 = call i64 @strlen(i8* %27)
%29 = icmp ult i64 %26, %28
br i1 %29, label %30, label %61
30: ; preds = %25
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %30
%37 = load i8*, i8** %7
%38 = load i64, i64* %8
%39 = getelementptr inbounds i8, i8* %37, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @encode(i8 signext %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %57
43: ; preds = %30
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %43
%50 = load i8*, i8** %7
%51 = load i64, i64* %8
%52 = getelementptr inbounds i8, i8* %50, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @decode(i8 signext %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %49, %43
br label %57
57: ; preds = %56, %36
br label %58
58: ; preds = %57
%59 = load i64, i64* %8
%60 = add i64 %59, 1
store i64 %60, i64* %8
br label %25
61: ; preds = %25
br label %19
62: ; preds = %19
%63 = load i8*, i8** %7
%64 = call i32 @free(i8* %63)
%65 = load i32*, i32** %6
%66 = call i32 @closeFile(i32* %65)
store i32 0, i32* %3
br label %67
67: ; preds = %62, %11
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [52 x i8] c"Not enough arguments!\0A[FILE] [e(ncode) or d(ecode)]\00"
@.str.1 = [2 x i8] c"e\00"
@.str.3 = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %48
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @loadFile(i8* %8)
%10 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1024, i32 1)
%11 = tail call i32* @fgets(i8* %10, i32 1024, i32* %9)
%12 = icmp eq i32* %11, null
br i1 %12, label %45, label %13
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
br label %18
15: ; preds = %41, %18
%16 = tail call i32* @fgets(i8* %10, i32 1024, i32* %9)
%17 = icmp eq i32* %16, null
br i1 %17, label %45, label %18
18: ; preds = %13, %15
%19 = load i8, i8* %10
%20 = icmp eq i8 %19, 0
br i1 %20, label %15, label %21
21: ; preds = %18, %41
%22 = phi i64 [ %42, %41 ], [ 0, %18 ]
%23 = load i8*, i8** %14
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %10, i64 %22
%28 = load i8, i8* %27
%29 = tail call i32 @encode(i8 signext %28)
br label %38
30: ; preds = %21
%31 = load i8*, i8** %14
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = getelementptr inbounds i8, i8* %10, i64 %22
%36 = load i8, i8* %35
%37 = tail call i32 @decode(i8 signext %36)
br label %38
38: ; preds = %34, %26
%39 = phi i32 [ %29, %26 ], [ %37, %34 ]
%40 = tail call i32 @putchar(i32 %39)
br label %41
41: ; preds = %38, %30
%42 = add nuw i64 %22, 1
%43 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%44 = icmp ult i64 %42, %43
br i1 %44, label %21, label %15
45: ; preds = %15, %6
%46 = tail call i32 @free(i8* %10)
%47 = tail call i32 @closeFile(i32* %9)
br label %48
48: ; preds = %45, %4
%49 = phi i32 [ 1, %4 ], [ 0, %45 ]
ret i32 %49
}