#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*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ *AllocAndReadFile(int /*<<< orphan*/, int *);
int /*<<< orphan*/ CompressData(int /*<<< orphan*/, int /*<<< orphan*/ *, int,
                                int, int, int, int, int, int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc != 1 && argc != 7) {
    fprintf(stderr,
            "Usage: %s <inputfile >outputfile [typeshift literalshift "
            "lengthshift1 lengthshift2 offsetshift1 offsetshift2]\n",
            argv[0]);
    exit(1);
  }
  uint32_t size;
  uint8_t *file = AllocAndReadFile(stdin, &size);
  int typeshift = 4, literalshift = 2, lengthshift1 = 4, lengthshift2 = 4,
      offsetshift1 = 4, offsetshift2 = 4;
  if (argc == 7) {
    typeshift = atoi(argv[1]);
    literalshift = atoi(argv[2]);
    lengthshift1 = atoi(argv[3]);
    lengthshift2 = atoi(argv[4]);
    offsetshift1 = atoi(argv[5]);
    offsetshift2 = atoi(argv[6]);
  }
  fputc(size & 0xff, stdout);
  fputc((size >> 8) & 0xff, stdout);
  fputc((size >> 16) & 0xff, stdout);
  fputc((size >> 24) & 0xff, stdout);
  fputc((offsetshift1 << 4) | offsetshift2, stdout);
  fputc((lengthshift1 << 4) | lengthshift2, stdout);
  fputc((typeshift << 4) | literalshift, stdout);
  CompressData(stdout, file, size, typeshift, literalshift, lengthshift1,
               lengthshift2, offsetshift1, offsetshift2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11b0 <main+0x50>
cmpl   $0x7,-0x8(%rbp)
je     11b0 <main+0x50>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
call   1050 <AllocAndReadFile@plt>
mov    %rax,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
movl   $0x4,-0x2c(%rbp)
movl   $0x4,-0x30(%rbp)
movl   $0x4,-0x34(%rbp)
movl   $0x4,-0x38(%rbp)
cmpl   $0x7,-0x8(%rbp)
jne    125a <main+0xfa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
and    $0xff,%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%edi
sar    $0x8,%edi
and    $0xff,%edi
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%edi
sar    $0x10,%edi
and    $0xff,%edi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%edi
sar    $0x18,%edi
and    $0xff,%edi
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x34(%rbp),%edi
shl    $0x4,%edi
or     -0x38(%rbp),%edi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x2c(%rbp),%edi
shl    $0x4,%edi
or     -0x30(%rbp),%edi
mov    0x2cea(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    -0x24(%rbp),%edi
shl    $0x4,%edi
or     -0x28(%rbp),%edi
mov    0x2cd3(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%r11d
mov    -0x34(%rbp),%r10d
mov    -0x38(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <CompressData@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
cmp    $0x1,%edi
je     1181 <main+0x21>
cmp    $0x7,%ebx
jne    12c6 <main+0x166>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
call   1050 <AllocAndReadFile@plt>
mov    %rax,0x20(%rsp)
cmp    $0x7,%ebx
jne    11e9 <main+0x89>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    0x20(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r12d
mov    0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x30(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
jmp    1210 <main+0xb0>
movl   $0x2,0x10(%rsp)
movl   $0x4,0x14(%rsp)
mov    $0x4,%r13d
mov    $0x4,%r12d
mov    $0x4,%r14d
mov    $0x4,%ebx
mov    %r12,0x18(%rsp)
movzbl 0xc(%rsp),%edi
mov    0x2daf(%rip),%rbp
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
movzbl 0xd(%rsp),%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
movzbl 0xe(%rsp),%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
movzbl 0xf(%rsp),%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
mov    %r14d,%edi
shl    $0x4,%edi
or     %ebx,%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
mov    %r13d,%edi
shl    $0x4,%edi
or     %r12d,%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
mov    0x14(%rsp),%r12d
mov    %r12d,%edi
shl    $0x4,%edi
mov    0x10(%rsp),%r15d
or     %r15d,%edi
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
mov    0x0(%rbp),%edi
mov    0xc(%rsp),%edx
sub    $0x8,%rsp
mov    0x28(%rsp),%rsi
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r13d,%r9d
push   %rbx
push   %r14
push   0x30(%rsp)
call   1030 <CompressData@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd26(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [111 x i8] c"Usage: %s <inputfile >outputfile [typeshift literalshift lengthshift1 lengthshift2 offsetshift1 offsetshift2]\0A\00"
@stdin = global i32 0
@stdout = global i32 0
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
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %26
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 7
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %16, %2
%27 = load i32, i32* @stdin
%28 = call i32* @AllocAndReadFile(i32 %27, i32* %6)
store i32* %28, i32** %7
store i32 4, i32* %8
store i32 2, i32* %9
store i32 4, i32* %10
store i32 4, i32* %11
store i32 4, i32* %12
store i32 4, i32* %13
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 7
br i1 %30, label %31, label %56
31: ; preds = %26
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %8
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %9
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %10
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 4
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %11
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 5
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %12
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 6
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %13
br label %56
56: ; preds = %31, %26
%57 = load i32, i32* %6
%58 = and i32 %57, 255
%59 = load i32, i32* @stdout
%60 = call i32 @fputc(i32 %58, i32 %59)
%61 = load i32, i32* %6
%62 = ashr i32 %61, 8
%63 = and i32 %62, 255
%64 = load i32, i32* @stdout
%65 = call i32 @fputc(i32 %63, i32 %64)
%66 = load i32, i32* %6
%67 = ashr i32 %66, 16
%68 = and i32 %67, 255
%69 = load i32, i32* @stdout
%70 = call i32 @fputc(i32 %68, i32 %69)
%71 = load i32, i32* %6
%72 = ashr i32 %71, 24
%73 = and i32 %72, 255
%74 = load i32, i32* @stdout
%75 = call i32 @fputc(i32 %73, i32 %74)
%76 = load i32, i32* %12
%77 = shl i32 %76, 4
%78 = load i32, i32* %13
%79 = or i32 %77, %78
%80 = load i32, i32* @stdout
%81 = call i32 @fputc(i32 %79, i32 %80)
%82 = load i32, i32* %10
%83 = shl i32 %82, 4
%84 = load i32, i32* %11
%85 = or i32 %83, %84
%86 = load i32, i32* @stdout
%87 = call i32 @fputc(i32 %85, i32 %86)
%88 = load i32, i32* %8
%89 = shl i32 %88, 4
%90 = load i32, i32* %9
%91 = or i32 %89, %90
%92 = load i32, i32* @stdout
%93 = call i32 @fputc(i32 %91, i32 %92)
%94 = load i32, i32* @stdout
%95 = load i32*, i32** %7
%96 = load i32, i32* %6
%97 = load i32, i32* %8
%98 = load i32, i32* %9
%99 = load i32, i32* %10
%100 = load i32, i32* %11
%101 = load i32, i32* %12
%102 = load i32, i32* %13
%103 = call i32 @CompressData(i32 %94, i32* %95, i32 %96, i32 %97, i32 %98, i32 %99, i32 %100, i32 %101, i32 %102)
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [111 x i8] c"Usage: %s <inputfile >outputfile [typeshift literalshift lengthshift1 lengthshift2 offsetshift1 offsetshift2]\0A\00"
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
switch i32 %0, label %4 [
i32 7, label %9
i32 1, label %9
]
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2, %2
%10 = bitcast i32* %3 to i8*
%11 = load i32, i32* @stdin
%12 = call i32* @AllocAndReadFile(i32 %11, i32* %3)
%13 = icmp eq i32 %0, 7
br i1 %13, label %14, label %33
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = getelementptr inbounds i8*, i8** %1, i64 5
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = getelementptr inbounds i8*, i8** %1, i64 6
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
br label %33
33: ; preds = %14, %9
%34 = phi i32 [ %17, %14 ], [ 4, %9 ]
%35 = phi i32 [ %20, %14 ], [ 2, %9 ]
%36 = phi i32 [ %23, %14 ], [ 4, %9 ]
%37 = phi i32 [ %26, %14 ], [ 4, %9 ]
%38 = phi i32 [ %29, %14 ], [ 4, %9 ]
%39 = phi i32 [ %32, %14 ], [ 4, %9 ]
%40 = load i32, i32* %3
%41 = and i32 %40, 255
%42 = load i32, i32* @stdout
%43 = call i32 @fputc(i32 %41, i32 %42)
%44 = load i32, i32* %3
%45 = lshr i32 %44, 8
%46 = and i32 %45, 255
%47 = load i32, i32* @stdout
%48 = call i32 @fputc(i32 %46, i32 %47)
%49 = load i32, i32* %3
%50 = lshr i32 %49, 16
%51 = and i32 %50, 255
%52 = load i32, i32* @stdout
%53 = call i32 @fputc(i32 %51, i32 %52)
%54 = load i32, i32* %3
%55 = lshr i32 %54, 24
%56 = load i32, i32* @stdout
%57 = call i32 @fputc(i32 %55, i32 %56)
%58 = shl i32 %38, 4
%59 = or i32 %58, %39
%60 = load i32, i32* @stdout
%61 = call i32 @fputc(i32 %59, i32 %60)
%62 = shl i32 %36, 4
%63 = or i32 %62, %37
%64 = load i32, i32* @stdout
%65 = call i32 @fputc(i32 %63, i32 %64)
%66 = shl i32 %34, 4
%67 = or i32 %66, %35
%68 = load i32, i32* @stdout
%69 = call i32 @fputc(i32 %67, i32 %68)
%70 = load i32, i32* @stdout
%71 = load i32, i32* %3
%72 = call i32 @CompressData(i32 %70, i32* %12, i32 %71, i32 %34, i32 %35, i32 %36, i32 %37, i32 %38, i32 %39)
ret i32 0
}