// File: /workspace/github_cpp_makefile_star2_O2/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, -0x30(%rbp)    # imm = 0x7FFF
cmpl $0x2, %edi
jl 0x25a1
movq %rsi, %rbx
movl %edi, %r13d
movq 0x8(%rsi), %rsi
leaq 0x1e4b(%rip), %rdi      # 0x4248
callq 0x2200
testl %eax, %eax
jne 0x2437
movq 0x10(%rbx), %rdi
leaq 0x1e3c(%rip), %rsi      # 0x424d
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x2140
cmpl $0x1, %eax
jne 0x25a1
addl $-0x2, %r13d
cmpl $0x1, %r13d
jbe 0x25a1
addq $0x10, %rbx
leaq 0x1e12(%rip), %rsi      # 0x4250
leaq -0x50(%rbp), %r14
leaq -0x29(%rbp), %rdx
movq %r14, %rdi
callq 0x2090
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x25c3
movl %eax, %r15d
movq %r14, %rdi
callq 0x20c0
testb %r15b, %r15b
jne 0x249d
leaq 0x1de2(%rip), %rsi      # 0x4253
leaq -0x29(%rbp), %rdx
movq %r14, %rdi
callq 0x2090
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x25c3
movl %eax, %r12d
movq %r14, %rdi
callq 0x20c0
testb %r12b, %r12b
je 0x25a1
movq 0x4b34(%rip), %r14      # 0x6fd8
cmpl $0x4, %r13d
je 0x24de
movq 0x4b17(%rip), %r12      # 0x6fc8
cmpl $0x3, %r13d
jne 0x2551
movl $0x208, %edi            # imm = 0x208
callq 0x2160
movq %rax, %r14
movq 0x10(%rbx), %rsi
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x2260
movb $0x1, %r13b
xorl %ebx, %ebx
jmp 0x255a
movl $0x200, %edi            # imm = 0x200
callq 0x2160
movq %rax, %r12
movq 0x18(%rbx), %rsi
pushq $0x10
popq %rdx
movq %rax, %rdi
callq 0x2180
leaq 0x1d55(%rip), %rsi      # 0x4256
leaq -0x50(%rbp), %r13
leaq -0x29(%rbp), %rdx
movq %r13, %rdi
callq 0x2090
movq 0x10(%rbx), %rsi
movq %r13, %rdi
callq 0x25d3
movl %eax, %r13d
leaq -0x50(%rbp), %rdi
callq 0x20c0
testb %r13b, %r13b
je 0x2555
movl $0x208, %edi            # imm = 0x208
callq 0x2160
movq %rax, %r14
movq 0x10(%rbx), %rsi
movb $0x1, %bl
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x2260
movb $0x1, %r13b
jmp 0x255a
xorl %ebx, %ebx
jmp 0x2557
movb $0x1, %bl
xorl %r13d, %r13d
movl -0x30(%rbp), %edx
movq %r14, %rdi
movq %r12, %rsi
testb %r15b, %r15b
je 0x256f
callq 0x25e0
jmp 0x2574
callq 0x27f2
testb %r13b, %r13b
je 0x2582
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
testb %bl, %bl
je 0x2590
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x23ac
jmp 0x25b0
movq %rax, %rbx
movq %r12, %r14
jmp 0x25b3
movq %rax, %rbx
movq %r14, %rdi
callq 0x2130
movq %rbx, %rdi
callq 0x2250