#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 */

/* Variables and functions */
int /*<<< orphan*/ LZX_Decode(char *);
int /*<<< orphan*/ LZX_Encode(char *, int, int);
int /*<<< orphan*/ Title();
int /*<<< orphan*/ Usage();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int cmd, vram;
  int arg;
  Title();
  if (argc < 2)
    Usage();
  if (!strcmp(argv[1], "-d")) {
    cmd = 0x00;
  } else if (!strcmp(argv[1], "-evb")) {
    cmd = 0x11;
    vram = 0x01;
  } else if (!strcmp(argv[1], "-ewb")) {
    cmd = 0x11;
    vram = 0x00;
  } else if (!strcmp(argv[1], "-evl")) {
    cmd = 0x40;
    vram = 0x01;
  } else if (!strcmp(argv[1], "-ewl")) {
    cmd = 0x40;
    vram = 0x00;
  } else {
    printf("Command not supported\n");
    exit(-1);
  };
  if (argc < 3) {
    printf("Filename not specified\n");
    exit(-1);
  };
  switch (cmd) {
  case 0x00:
    for (arg = 2; arg < argc; arg++)
      LZX_Decode(argv[arg]);
    break;
  case 0x11:
  case 0x40:
    for (arg = 2; arg < argc; arg++)
      LZX_Encode(argv[arg], cmd, vram);
    break;
  default:
    break;
  }
  printf("\nDone\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <Title@plt>
cmpl   $0x2,-0x8(%rbp)
jge    119e <main+0x2e>
mov    $0x0,%al
call   1050 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <main+0x57>
movl   $0x0,-0x14(%rbp)
jmp    12b1 <main+0x141>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f7 <main+0x87>
movl   $0x11,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    12ac <main+0x13c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe02(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1227 <main+0xb7>
movl   $0x11,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    12a7 <main+0x137>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1257 <main+0xe7>
movl   $0x40,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    12a2 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdac(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1287 <main+0x117>
movl   $0x40,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    129d <main+0x12d>
lea    0xd89(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    12a2 <main+0x132>
jmp    12a7 <main+0x137>
jmp    12ac <main+0x13c>
jmp    12b1 <main+0x141>
cmpl   $0x3,-0x8(%rbp)
jge    12d1 <main+0x161>
lea    0xd6c(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     1306 <main+0x196>
jmp    12e4 <main+0x174>
mov    -0x20(%rbp),%eax
sub    $0x11,%eax
je     133d <main+0x1cd>
jmp    12f5 <main+0x185>
mov    -0x20(%rbp),%eax
sub    $0x40,%eax
je     133d <main+0x1cd>
jmp    137a <main+0x20a>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1338 <main+0x1c8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <LZX_Decode@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    130d <main+0x19d>
jmp    137f <main+0x20f>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1375 <main+0x205>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <LZX_Encode@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1344 <main+0x1d4>
jmp    137f <main+0x20f>
jmp    137f <main+0x20f>
lea    0xcc0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   1040 <Title@plt>
cmp    $0x1,%ebx
jg     1196 <main+0x26>
xor    %eax,%eax
call   1050 <Usage@plt>
mov    0x8(%r15),%r12
lea    0xe5f(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1218 <main+0xa8>
lea    0xe4f(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcmp@plt>
mov    $0x11,%r13d
test   %eax,%eax
je     1222 <main+0xb2>
lea    0xe3b(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcmp@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1228 <main+0xb8>
lea    0xe2a(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcmp@plt>
mov    $0x40,%r13d
test   %eax,%eax
je     12a5 <main+0x135>
lea    0xe12(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1228 <main+0xb8>
lea    0xe21(%rip),%rdi
jmp    12bb <main+0x14b>
cmp    $0x2,%ebx
jg     1231 <main+0xc1>
jmp    12b4 <main+0x144>
mov    $0x1,%r14d
cmp    $0x2,%ebx
jle    12b4 <main+0x144>
cmp    $0x40,%r13d
je     1264 <main+0xf4>
cmp    $0x11,%r13d
je     1264 <main+0xf4>
test   %r13d,%r13d
jne    1288 <main+0x118>
mov    %ebx,%ebx
mov    $0x2,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rdi
call   1070 <LZX_Decode@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1250 <main+0xe0>
jmp    1288 <main+0x118>
mov    %ebx,%ebp
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1090 <LZX_Encode@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1270 <main+0x100>
lea    0xd88(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r14d
cmp    $0x2,%ebx
jg     1231 <main+0xc1>
lea    0xd62(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [5 x i8] c"-evb\00"
@.str.2 = [5 x i8] c"-ewb\00"
@.str.3 = [5 x i8] c"-evl\00"
@.str.4 = [5 x i8] c"-ewl\00"
@.str.5 = [23 x i8] c"Command not supported\0A\00"
@.str.6 = [24 x i8] c"Filename not specified\0A\00"
@.str.7 = [7 x i8] c"\0ADone\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @Title()
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @Usage()
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 0, i32* %6
br label %56
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %21
store i32 17, i32* %6
store i32 1, i32* %7
br label %55
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %28
store i32 17, i32* %6
store i32 0, i32* %7
br label %54
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %35
store i32 64, i32* %6
store i32 1, i32* %7
br label %53
42: ; preds = %35
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %42
store i32 64, i32* %6
store i32 0, i32* %7
br label %52
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %48
br label %53
53: ; preds = %52, %41
br label %54
54: ; preds = %53, %34
br label %55
55: ; preds = %54, %27
br label %56
56: ; preds = %55, %20
%57 = load i32, i32* %4
%58 = icmp slt i32 %57, 3
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %56
%63 = load i32, i32* %6
switch i32 %63, label %98 [
i32 0, label %64
i32 17, label %80
i32 64, label %80
]
64: ; preds = %62
store i32 2, i32* %8
br label %65
65: ; preds = %76, %64
%66 = load i32, i32* %8
%67 = load i32, i32* %4
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %79
69: ; preds = %65
%70 = load i8**, i8*** %5
%71 = load i32, i32* %8
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @LZX_Decode(i8* %74)
br label %76
76: ; preds = %69
%77 = load i32, i32* %8
%78 = add nsw i32 %77, 1
store i32 %78, i32* %8
br label %65
79: ; preds = %65
br label %99
80: ; preds = %62, %62
store i32 2, i32* %8
br label %81
81: ; preds = %94, %80
%82 = load i32, i32* %8
%83 = load i32, i32* %4
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %97
85: ; preds = %81
%86 = load i8**, i8*** %5
%87 = load i32, i32* %8
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = load i32, i32* %6
%92 = load i32, i32* %7
%93 = call i32 @LZX_Encode(i8* %90, i32 %91, i32 %92)
br label %94
94: ; preds = %85
%95 = load i32, i32* %8
%96 = add nsw i32 %95, 1
store i32 %96, i32* %8
br label %81
97: ; preds = %81
br label %99
98: ; preds = %62
br label %99
99: ; preds = %98, %97, %79
%100 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [5 x i8] c"-evb\00"
@.str.2 = [5 x i8] c"-ewb\00"
@.str.3 = [5 x i8] c"-evl\00"
@.str.4 = [5 x i8] c"-ewl\00"
@str = [6 x i8] c"\0ADone\00"
@str.8 = [23 x i8] c"Filename not specified\00"
@str.9 = [22 x i8] c"Command not supported\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @Title()
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (...) @Usage()
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %21, %18, %15, %12, %7
%28 = phi i32 [ 0, %7 ], [ 17, %12 ], [ 17, %15 ], [ 64, %18 ], [ 64, %21 ]
%29 = phi i32 [ undef, %7 ], [ 1, %12 ], [ 0, %15 ], [ 1, %18 ], [ 0, %21 ]
%30 = icmp slt i32 %0, 3
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%33 = tail call i32 @exit(i32 -1)
unreachable
34: ; preds = %27
switch i32 %28, label %53 [
i32 0, label %35
i32 17, label %44
i32 64, label %44
]
35: ; preds = %34
%36 = zext i32 %0 to i64
br label %37
37: ; preds = %35, %37
%38 = phi i64 [ 2, %35 ], [ %42, %37 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i32 @LZX_Decode(i8* %40)
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, %36
br i1 %43, label %53, label %37
44: ; preds = %34, %34
%45 = zext i32 %0 to i64
br label %46
46: ; preds = %44, %46
%47 = phi i64 [ 2, %44 ], [ %51, %46 ]
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
%50 = tail call i32 @LZX_Encode(i8* %49, i32 %28, i32 %29)
%51 = add nuw nsw i64 %47, 1
%52 = icmp eq i64 %51, %45
br i1 %52, label %53, label %46
53: ; preds = %46, %37, %34
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret i32 0
}