#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*/ BLZ_Decode(char *);
int /*<<< orphan*/ BLZ_Encode(char *, int);
int /*<<< orphan*/ Title();
int /*<<< orphan*/ Usage();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcasecmp(char *, char *);
int main(int argc, char **argv) {
  int cmd, mode;
  int arg;
  Title();
  if (argc < 2)
    Usage();
  if (!strcasecmp(argv[1], "-d")) {
    cmd = 0x00;
  } else if (!strcasecmp(argv[1], "-en")) {
    cmd = 0x01;
    mode = 0;
  } else if (!strcasecmp(argv[1], "-eo")) {
    cmd = 0x01;
    mode = 1;
  } 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++)
      BLZ_Decode(argv[arg]);
    break;
  case 0x01:
    for (arg = 2; arg < argc; arg++)
      BLZ_Encode(argv[arg], mode);
    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   1060 <Title@plt>
cmpl   $0x2,-0x8(%rbp)
jge    119e <main+0x2e>
mov    $0x0,%al
call   1070 <Usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11c7 <main+0x57>
movl   $0x0,-0x14(%rbp)
jmp    1247 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11f7 <main+0x87>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    1242 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe01(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1227 <main+0xb7>
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    123d <main+0xcd>
lea    0xddd(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    1242 <main+0xd2>
jmp    1247 <main+0xd7>
cmpl   $0x3,-0x8(%rbp)
jge    1267 <main+0xf7>
lea    0xdca(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     128b <main+0x11b>
jmp    127a <main+0x10a>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     12c2 <main+0x152>
jmp    12fc <main+0x18c>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12bd <main+0x14d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <BLZ_Decode@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1292 <main+0x122>
jmp    1301 <main+0x191>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f7 <main+0x187>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%esi
call   1030 <BLZ_Encode@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12c9 <main+0x159>
jmp    1301 <main+0x191>
jmp    1301 <main+0x191>
lea    0xd32(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%r14d
xor    %eax,%eax
call   1060 <Title@plt>
cmp    $0x1,%r14d
jg     1192 <main+0x22>
xor    %eax,%eax
call   1070 <Usage@plt>
mov    0x8(%r15),%rbp
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     11e1 <main+0x71>
lea    0xe53(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     1204 <main+0x94>
lea    0xe44(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcasecmp@plt>
mov    $0x1,%r12d
test   %eax,%eax
jne    1255 <main+0xe5>
cmp    $0x3,%r14d
jge    120d <main+0x9d>
jmp    124c <main+0xdc>
cmp    $0x2,%r14d
jle    124c <main+0xdc>
mov    %r14d,%ebx
mov    $0x2,%ebp
nop
mov    (%r15,%rbp,8),%rdi
call   1080 <BLZ_Decode@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11f0 <main+0x80>
jmp    1235 <main+0xc5>
xor    %r12d,%r12d
cmp    $0x3,%r14d
jl     124c <main+0xdc>
mov    %r14d,%ebx
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,8),%rdi
mov    %r12d,%esi
call   1030 <BLZ_Encode@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1220 <main+0xb0>
lea    0xdcf(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdbe(%rip),%rdi
jmp    125c <main+0xec>
lea    0xdcc(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [4 x i8] c"-en\00"
@.str.2 = [4 x i8] c"-eo\00"
@.str.3 = [23 x i8] c"Command not supported\0A\00"
@.str.4 = [24 x i8] c"Filename not specified\0A\00"
@.str.5 = [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 @strcasecmp(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 %40
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcasecmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 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 1, i32* %6
store i32 0, i32* %7
br label %39
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcasecmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 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 1, i32* %6
store i32 1, i32* %7
br label %38
35: ; preds = %28
%36 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %34
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39, %20
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 3
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @exit(i32 -1)
unreachable
46: ; preds = %40
%47 = load i32, i32* %6
switch i32 %47, label %81 [
i32 0, label %48
i32 1, label %64
]
48: ; preds = %46
store i32 2, i32* %8
br label %49
49: ; preds = %60, %48
%50 = load i32, i32* %8
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i8**, i8*** %5
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @BLZ_Decode(i8* %58)
br label %60
60: ; preds = %53
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %49
63: ; preds = %49
br label %82
64: ; preds = %46
store i32 2, i32* %8
br label %65
65: ; preds = %77, %64
%66 = load i32, i32* %8
%67 = load i32, i32* %4
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %80
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 = load i32, i32* %7
%76 = call i32 @BLZ_Encode(i8* %74, i32 %75)
br label %77
77: ; preds = %69
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %65
80: ; preds = %65
br label %82
81: ; preds = %46
br label %82
82: ; preds = %81, %80, %63
%83 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [4 x i8] c"-en\00"
@.str.2 = [4 x i8] c"-eo\00"
@str = [6 x i8] c"\0ADone\00"
@str.6 = [23 x i8] c"Filename not specified\00"
@str.7 = [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 @strcasecmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %7
%13 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = tail call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %15, %12
%22 = phi i32 [ 0, %12 ], [ 1, %15 ]
%23 = icmp slt i32 %0, 3
br i1 %23, label %26, label %29
24: ; preds = %7
%25 = icmp slt i32 %0, 3
br i1 %25, label %26, label %31
26: ; preds = %24, %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%28 = tail call i32 @exit(i32 -1)
unreachable
29: ; preds = %21
%30 = zext i32 %0 to i64
br label %40
31: ; preds = %24
%32 = zext i32 %0 to i64
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ 2, %31 ], [ %38, %33 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = tail call i32 @BLZ_Decode(i8* %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %32
br i1 %39, label %47, label %33
40: ; preds = %29, %40
%41 = phi i64 [ 2, %29 ], [ %45, %40 ]
%42 = getelementptr inbounds i8*, i8** %1, i64 %41
%43 = load i8*, i8** %42
%44 = tail call i32 @BLZ_Encode(i8* %43, i32 %22)
%45 = add nuw nsw i64 %41, 1
%46 = icmp eq i64 %45, %30
br i1 %46, label %47, label %40
47: ; preds = %40, %33
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret i32 0
}