#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*/ F_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ compress(char *, char *);
int /*<<< orphan*/ extract(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char *argv[]) {
  bool Compressing, HelpShowing = false;
  int ExitCode = 0;
  for (int i = 0; (i < argc) && (!HelpShowing); i++) {
    if ((strstr(argv[i], "help") != NULL) || (strstr(argv[i], "-h") != NULL)) {
      HelpShowing = true;
    }
  }
  if (HelpShowing) {
    printf("huff InputFile [ -c|-x ] OutputFile\n");
  } else {
    if (argc < 4) {
      printf("Too few arguments: %i < 3.\n", (argc - 1));
      ExitCode = 1;
    } else {
      if (strcmp(argv[2], "-c") == 0) {
        Compressing = true;
      } else if (strcmp(argv[2], "-x") == 0) {
        Compressing = false;
      } else {
        printf("The secong argument isn't an action: %s.\n", argv[2]);
        ExitCode = 2;
      }
      if (access(argv[1], F_OK) == -1) {
        printf("Input file %s isn't accessible.\n", argv[1]);
        ExitCode = 3;
      }
      if (ExitCode == 0) {
        if (Compressing) {
          compress(argv[1], argv[3]);
        } else {
          extract(argv[1], argv[3]);
        }
      }
    }
  }
  if (ExitCode != 0) {
    printf("Try `%s --help`.\n", argv[0]);
  }
  return (ExitCode);
}


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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x21(%rbp)
jge    11a8 <main+0x48>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b8 <main+0x58>
jmp    1216 <main+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe35(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
jne    11fc <main+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe18(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1203 <main+0xa3>
movl   $0x1,-0x18(%rbp)
jmp    1208 <main+0xa8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118b <main+0x2b>
cmpl   $0x0,-0x18(%rbp)
je     1233 <main+0xd3>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1361 <main+0x201>
cmpl   $0x4,-0x8(%rbp)
jge    125d <main+0xfd>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    135c <main+0x1fc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddd(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1287 <main+0x127>
movl   $0x1,-0x14(%rbp)
jmp    12d3 <main+0x173>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12b1 <main+0x151>
movl   $0x0,-0x14(%rbp)
jmp    12ce <main+0x16e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x1c(%rbp)
jmp    12d3 <main+0x173>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cf6(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0xffffffff,%eax
jne    130f <main+0x1af>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1357 <main+0x1f7>
cmpl   $0x0,-0x14(%rbp)
je     133d <main+0x1dd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <compress@plt>
jmp    1352 <main+0x1f2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <extract@plt>
jmp    1357 <main+0x1f7>
jmp    135c <main+0x1fc>
jmp    1361 <main+0x201>
cmpl   $0x0,-0x1c(%rbp)
je     1380 <main+0x220>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%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
mov    %rsi,%rbx
mov    %edi,%esi
test   %edi,%edi
jle    11d6 <main+0x66>
mov    %esi,0x4(%rsp)
mov    %esi,%r15d
xor    %r14d,%r14d
lea    0xe6b(%rip),%r13
lea    0xe69(%rip),%r12
nopl   0x0(%rax)
mov    (%rbx,%r14,8),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    11ff <main+0x8f>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    11ff <main+0x8f>
add    $0x1,%r14
cmp    %r15,%r14
jb     11a0 <main+0x30>
mov    0x4(%rsp),%esi
cmp    $0x3,%esi
jg     121e <main+0xae>
add    $0xffffffff,%esi
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
mov    (%rbx),%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120d <main+0x9d>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbx),%rdi
lea    0xdfb(%rip),%rsi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1266 <main+0xf6>
mov    0x10(%rbx),%rdi
lea    0xde7(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     126e <main+0xfe>
mov    0x10(%rbx),%rsi
lea    0xdd5(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%ebp
jmp    1274 <main+0x104>
mov    $0x1,%r14b
xor    %r15d,%r15d
jmp    1274 <main+0x104>
mov    $0x1,%r15b
mov    $0x1,%r14b
mov    0x8(%rbx),%rdi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
call   1070 <access@plt>
cmp    $0xffffffff,%eax
je     12ac <main+0x13c>
test   %r14b,%r14b
je     11ec <main+0x7c>
mov    0x8(%rbx),%rdi
mov    0x18(%rbx),%rsi
test   $0x1,%r15b
je     12c8 <main+0x158>
call   1080 <extract@plt>
jmp    120b <main+0x9b>
mov    0x8(%rbx),%rsi
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%ebp
jmp    11ec <main+0x7c>
call   1030 <compress@plt>
jmp    120b <main+0x9b>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [37 x i8] c"huff InputFile [ -c|-x ] OutputFile\0A\00"
@.str.3 = [28 x i8] c"Too few arguments: %i < 3.\0A\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [3 x i8] c"-x\00"
@.str.6 = [42 x i8] c"The secong argument isn't an action: %s.\0A\00"
@F_OK = global i32 0
@.str.7 = [33 x i8] c"Input file %s isn't accessible.\0A\00"
@.str.8 = [18 x i8] c"Try `%s --help`.\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br label %18
18: ; preds = %14, %10
%19 = phi i1 [ false, %10 ], [ %17, %14 ]
br i1 %19, label %20, label %41
20: ; preds = %18
%21 = load i8**, i8*** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32* @strstr(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i32* %26, null
br i1 %27, label %36, label %28
28: ; preds = %20
%29 = load i8**, i8*** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32* @strstr(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %37
36: ; preds = %28, %20
store i32 1, i32* %7
br label %37
37: ; preds = %36, %28
br label %38
38: ; preds = %37
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %10
41: ; preds = %18
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %110
46: ; preds = %41
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 4
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32, i32* %4
%51 = sub nsw i32 %50, 1
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %51)
store i32 1, i32* %8
br label %109
53: ; preds = %46
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %53
store i32 1, i32* %6
br label %73
60: ; preds = %53
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %60
store i32 0, i32* %6
br label %72
67: ; preds = %60
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8* %70)
store i32 2, i32* %8
br label %72
72: ; preds = %67, %66
br label %73
73: ; preds = %72, %59
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = load i32, i32* @F_OK
%78 = call i32 @access(i8* %76, i32 %77)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %85
80: ; preds = %73
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %83)
store i32 3, i32* %8
br label %85
85: ; preds = %80, %73
%86 = load i32, i32* %8
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %108
88: ; preds = %85
%89 = load i32, i32* %6
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %99
91: ; preds = %88
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 1
%94 = load i8*, i8** %93
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 3
%97 = load i8*, i8** %96
%98 = call i32 @compress(i8* %94, i8* %97)
br label %107
99: ; preds = %88
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 3
%105 = load i8*, i8** %104
%106 = call i32 @extract(i8* %102, i8* %105)
br label %107
107: ; preds = %99, %91
br label %108
108: ; preds = %107, %85
br label %109
109: ; preds = %108, %49
br label %110
110: ; preds = %109, %44
%111 = load i32, i32* %8
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %118
113: ; preds = %110
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 0
%116 = load i8*, i8** %115
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %116)
br label %118
118: ; preds = %113, %110
%119 = load i32, i32* %8
ret i32 %119
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.3 = [28 x i8] c"Too few arguments: %i < 3.\0A\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [3 x i8] c"-x\00"
@.str.6 = [42 x i8] c"The secong argument isn't an action: %s.\0A\00"
@F_OK = global i32 0
@.str.7 = [33 x i8] c"Input file %s isn't accessible.\0A\00"
@.str.8 = [18 x i8] c"Try `%s --help`.\0A\00"
@str = [36 x i8] c"huff InputFile [ -c|-x ] OutputFile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32* @strstr(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = tail call i32* @strstr(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = add nuw nsw i64 %7, 1
%17 = icmp ult i64 %16, %5
br i1 %17, label %6, label %20
18: ; preds = %6, %12
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %62
20: ; preds = %15
%21 = icmp slt i32 %0, 4
br i1 %21, label %22, label %25
22: ; preds = %2, %20
%23 = add nsw i32 %0, -1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %58
25: ; preds = %20
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %25
%31 = load i8*, i8** %26
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i8*, i8** %26
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %30, %25, %34
%38 = phi i1 [ undef, %34 ], [ false, %25 ], [ true, %30 ]
%39 = phi i1 [ false, %34 ], [ true, %25 ], [ true, %30 ]
%40 = phi i32 [ 2, %34 ], [ 0, %25 ], [ 0, %30 ]
%41 = getelementptr inbounds i8*, i8** %1, i64 1
%42 = load i8*, i8** %41
%43 = load i32, i32* @F_OK
%44 = tail call i32 @access(i8* %42, i32 %43)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %37
%47 = load i8*, i8** %41
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %47)
br label %58
49: ; preds = %37
br i1 %39, label %50, label %58
50: ; preds = %49
%51 = load i8*, i8** %41
%52 = getelementptr inbounds i8*, i8** %1, i64 3
%53 = load i8*, i8** %52
br i1 %38, label %56, label %54
54: ; preds = %50
%55 = tail call i32 @compress(i8* %51, i8* %53)
br label %62
56: ; preds = %50
%57 = tail call i32 @extract(i8* %51, i8* %53)
br label %62
58: ; preds = %49, %22, %46
%59 = phi i32 [ 1, %22 ], [ %40, %49 ], [ 3, %46 ]
%60 = load i8*, i8** %1
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %56, %54, %18, %58
%63 = phi i32 [ %59, %58 ], [ 0, %18 ], [ 0, %54 ], [ 0, %56 ]
ret i32 %63
}