// File: /workspace/github_cpp_makefile_star2_O3/marknelson[P]LZW/lzw.cpp
// Function: main
int main(int argc, char* argv[])
{
    int max_code = 32767;
    if ( argc >= 2 && !strcmp( "-max", argv[1] ) ) {
        if ( sscanf( argv[2], "%d", &max_code ) != 1 )
            usage();
        argc -= 2;
        argv += 2;
    }
    if ( argc < 2 )
            usage();
        bool compress;
        if ( std::string( "-c" ) == argv[1] )
            compress = true;
        else if ( std::string( "-d" ) == argv[1] )
            compress = false;
        else
            usage();
        std::istream *in = &std::cin;
        std::ostream *out = &std::cout;
        bool delete_instream = false;
        bool delete_ostream = false;
        if ( argc == 3 ) {
            in = new std::ifstream( argv[2] );
            delete_instream = true;
        }
        if ( argc == 4 ) {
            out = new std::ofstream( argv[3] );
            delete_ostream = true;
            if ( std::string("-") != argv[2] ) {
                in = new std::ifstream( argv[2] );
                delete_instream = true;
            }
        }
        if ( compress )
            lzw::compress( *in, *out, max_code );
        else
            lzw::decompress( *in, *out, max_code );
        if ( delete_instream )
            delete in;
        if ( delete_ostream )
            delete out;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0x7fff, -0x2c(%rbp)    # imm = 0x7FFF
cmpl $0x2, %edi
jl 0x2606
movq %rsi, %r14
movl %edi, %ebx
movq 0x8(%rsi), %rsi
leaq 0x1e5a(%rip), %rdi      # 0x4248
callq 0x21c0
testl %eax, %eax
jne 0x2426
movq 0x10(%r14), %rdi
leaq 0x1e4b(%rip), %rsi      # 0x424d
leaq -0x2c(%rbp), %rdx
xorl %eax, %eax
callq 0x2110
cmpl $0x1, %eax
jne 0x2606
addl $-0x2, %ebx
cmpl $0x1, %ebx
jbe 0x2606
addq $0x10, %r14
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x1e1b(%rip), %rsi      # 0x4250
leaq 0x1e16(%rip), %rdx      # 0x4252
leaq -0x50(%rbp), %r12
movq %r12, %rdi
callq 0x2bf0
movq 0x8(%r14), %rsi
movq %r12, %rdi
callq 0x2060
movl %eax, %r15d
movq (%r12), %rdi
cmpq %r13, %rdi
je 0x2465
callq 0x2100
testl %r15d, %r15d
je 0x24b6
leaq -0x50(%rbp), %r13
leaq -0x40(%rbp), %rax
movq %rax, (%r13)
leaq 0x1dd6(%rip), %rsi      # 0x4253
leaq 0x1dd1(%rip), %rdx      # 0x4255
movq %r13, %rdi
callq 0x2bf0
movq 0x8(%r14), %rsi
movq %r13, %rdi
callq 0x2060
movl %eax, %r12d
movq (%r13), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x24ad
callq 0x2100
testl %r12d, %r12d
jne 0x2606
movq 0x3b1b(%rip), %r12      # 0x5fd8
cmpl $0x4, %ebx
je 0x2509
cmpl $0x3, %ebx
jne 0x2597
movl $0x208, %edi            # imm = 0x208
callq 0x2130
movq %rax, %rbx
movq 0x10(%r14), %rsi
movq %rax, %rdi
movl $0x8, %edx
callq 0x2230
movl -0x2c(%rbp), %edx
movq 0x3ad5(%rip), %rsi      # 0x5fc8
movq %rbx, %rdi
testl %r15d, %r15d
je 0x25aa
callq 0x28df
jmp 0x25ec
movl %r15d, -0x30(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0x2130
movq %rax, %rbx
movq 0x18(%r14), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x2150
leaq -0x50(%rbp), %r15
leaq -0x40(%rbp), %rax
movq %rax, (%r15)
leaq 0x1d19(%rip), %rsi      # 0x4256
leaq 0x1d13(%rip), %rdx      # 0x4257
movq %r15, %rdi
callq 0x2bf0
movq 0x10(%r14), %rsi
movq %r15, %rdi
callq 0x2060
movl %eax, %r13d
movq (%r15), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x256c
callq 0x2100
testl %r13d, %r13d
je 0x25b1
movl $0x208, %edi            # imm = 0x208
callq 0x2130
movq %rax, %r12
movq 0x10(%r14), %rsi
movb $0x1, %r14b
movq %rax, %rdi
movl $0x8, %edx
callq 0x2230
movb $0x1, %r15b
jmp 0x25b7
movl %r15d, -0x30(%rbp)
movq 0x3a26(%rip), %rbx      # 0x5fc8
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x25b7
callq 0x2640
jmp 0x25ec
xorl %r15d, %r15d
movb $0x1, %r14b
movl -0x2c(%rbp), %edx
cmpl $0x0, -0x30(%rbp)
je 0x25cd
movq %r12, %rdi
movq %rbx, %rsi
callq 0x28df
jmp 0x25d8
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2640
testb %r15b, %r15b
je 0x25e7
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
testb %r14b, %r14b
je 0x25f5
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x39e3(%rip), %rdi      # 0x5ff0
leaq 0x1a0c(%rip), %rsi      # 0x4020
callq 0x2120
movl $0x1, %edi
callq 0x2180
movq %rax, %r14
movq %r12, %rbx
jmp 0x2630
jmp 0x262d
movq %rax, %r14
movq %rbx, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x2210