#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 /*<<< orphan*/ dekompress(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ error();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ kompress(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  FILE *fi, *fo;
  int mode;
  if (argc < 4)
    error();
  if (argv[1][0] != '-')
    error();
  if (argv[1][1] == 'k')
    mode = 1;
  else if (argv[1][1] == 'd')
    mode = 2;
  else
    error();
  if ((fi = fopen(argv[2], "rb")) != NULL &&
      (fo = fopen(argv[3], "wb")) != NULL) {
    if (mode == 1) {
      kompress(fi, fo);
      fclose(fi);
      fclose(fo);
    } else {
      dekompress(fi, fo);
      fclose(fi);
      fclose(fo);
    }
  }
  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   $0x4,-0x8(%rbp)
jge    1177 <main+0x27>
mov    $0x0,%al
call   1060 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1192 <main+0x42>
mov    $0x0,%al
call   1060 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6b,%eax
jne    11b3 <main+0x63>
movl   $0x1,-0x24(%rbp)
jmp    11e0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    11d4 <main+0x84>
movl   $0x2,-0x24(%rbp)
jmp    11db <main+0x8b>
mov    $0x0,%al
call   1060 <error@plt>
jmp    11e0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe11(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1276 <main+0x126>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdf2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1276 <main+0x126>
cmpl   $0x1,-0x24(%rbp)
jne    1252 <main+0x102>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <kompress@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1271 <main+0x121>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <dekompress@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1276 <main+0x126>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x3,%edi
jg     1163 <main+0x13>
xor    %eax,%eax
call   1060 <error@plt>
mov    0x8(%r14),%rax
cmpb   $0x2d,(%rax)
je     1177 <main+0x27>
xor    %eax,%eax
call   1060 <error@plt>
mov    0x8(%r14),%rax
mov    0x1(%rax),%al
cmp    $0x6b,%al
je     1186 <main+0x36>
cmp    $0x64,%al
jne    118b <main+0x3b>
xor    %ebp,%ebp
jmp    1192 <main+0x42>
mov    $0x1,%bpl
jmp    1192 <main+0x42>
xor    %eax,%eax
call   1060 <error@plt>
mov    0x10(%r14),%rdi
lea    0xe63(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ea <main+0x9a>
mov    %rax,%rbx
mov    0x18(%r14),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ea <main+0x9a>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
test   $0x1,%bpl
je     11d5 <main+0x85>
call   1030 <kompress@plt>
jmp    11da <main+0x8a>
call   1050 <dekompress@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\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 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @error()
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 45
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 (...) @error()
br label %23
23: ; preds = %21, %13
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 107
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 1, i32* %8
br label %44
32: ; preds = %23
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 100
br i1 %39, label %40, label %41
40: ; preds = %32
store i32 2, i32* %8
br label %43
41: ; preds = %32
%42 = call i32 (...) @error()
br label %43
43: ; preds = %41, %40
br label %44
44: ; preds = %43, %31
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32* @fopen(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %48, i32** %6
%49 = icmp ne i32* %48, null
br i1 %49, label %50, label %76
50: ; preds = %44
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %54, i32** %7
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %76
56: ; preds = %50
%57 = load i32, i32* %8
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %67
59: ; preds = %56
%60 = load i32*, i32** %6
%61 = load i32*, i32** %7
%62 = call i32 @kompress(i32* %60, i32* %61)
%63 = load i32*, i32** %6
%64 = call i32 @fclose(i32* %63)
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
br label %75
67: ; preds = %56
%68 = load i32*, i32** %6
%69 = load i32*, i32** %7
%70 = call i32 @dekompress(i32* %68, i32* %69)
%71 = load i32*, i32** %6
%72 = call i32 @fclose(i32* %71)
%73 = load i32*, i32** %7
%74 = call i32 @fclose(i32* %73)
br label %75
75: ; preds = %67, %59
br label %76
76: ; preds = %75, %50, %44
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @error()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i32 (...) @error()
%13 = load i8*, i8** %7
br label %14
14: ; preds = %11, %6
%15 = phi i8* [ %13, %11 ], [ %8, %6 ]
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
switch i8 %17, label %19 [
i8 107, label %21
i8 100, label %18
]
18: ; preds = %14
br label %21
19: ; preds = %14
%20 = tail call i32 (...) @error()
br label %21
21: ; preds = %14, %18, %19
%22 = phi i1 [ false, %18 ], [ undef, %19 ], [ true, %14 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %40, label %27
27: ; preds = %21
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %40, label %32
32: ; preds = %27
br i1 %22, label %33, label %35
33: ; preds = %32
%34 = tail call i32 @kompress(i32* %25, i32* %30)
br label %37
35: ; preds = %32
%36 = tail call i32 @dekompress(i32* %25, i32* %30)
br label %37
37: ; preds = %35, %33
%38 = tail call i32 @fclose(i32* %25)
%39 = tail call i32 @fclose(i32* %30)
br label %40
40: ; preds = %37, %27, %21
ret i32 0
}