// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %r14
movl %edi, %ebx
movl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
cmpl $0x2, %edi
jl 0x2419
movq 0x8(%r14), %rsi
leaq 0x1e5e(%rip), %rdi      # 0x4248
callq 0x21c0
testl %eax, %eax
jne 0x2419
movq 0x10(%r14), %rdi
leaq 0x1e4f(%rip), %rsi      # 0x424d
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x2110
cmpl $0x1, %eax
jne 0x25df
addq $0x10, %r14
addl $-0x2, %ebx
cmpl $0x1, %ebx
jle 0x25df
leaq -0x48(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1e1e(%rip), %rsi      # 0x4250
leaq 0x1e19(%rip), %rdx      # 0x4252
leaq -0x58(%rbp), %r15
movq %r15, %rdi
callq 0x2bea
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x2060
movl %eax, %r13d
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x2461
callq 0x2100
testl %r13d, %r13d
je 0x24ac
leaq -0x48(%rbp), %rax
movq %rax, (%r15)
leaq 0x1ddf(%rip), %rsi      # 0x4253
leaq 0x1dda(%rip), %rdx      # 0x4255
movq %r15, %rdi
callq 0x2bea
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x2060
movl %eax, %r12d
movq (%r15), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x24a3
callq 0x2100
testl %r12d, %r12d
jne 0x25df
cmpl $0x3, %ebx
movl %r13d, -0x38(%rbp)
jne 0x24db
movl $0x208, %edi            # imm = 0x208
callq 0x2130
movq %rax, %r12
movq 0x10(%r14), %rsi
movb $0x1, %r15b
movq %rax, %rdi
movl $0x8, %edx
callq 0x2230
movq %r12, %r13
jmp 0x24e5
movq 0x4af6(%rip), %r13      # 0x6fd8
xorl %r15d, %r15d
cmpl $0x4, %ebx
jne 0x257f
movl %r15d, -0x34(%rbp)
movl %ebx, -0x2c(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0x2130
movq %rax, %r12
movq 0x18(%r14), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x2150
leaq -0x58(%rbp), %rbx
leaq -0x48(%rbp), %rax
movq %rax, (%rbx)
leaq 0x1d31(%rip), %rsi      # 0x4256
leaq 0x1d2b(%rip), %rdx      # 0x4257
movq %rbx, %rdi
callq 0x2bea
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x2060
movl %eax, %r15d
movq (%rbx), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x2554
callq 0x2100
testl %r15d, %r15d
je 0x2588
movl $0x208, %edi            # imm = 0x208
callq 0x2130
movq %rax, %r13
movq 0x10(%r14), %rsi
movb $0x1, %r15b
movq %rax, %rdi
movl $0x8, %edx
callq 0x2230
movl -0x2c(%rbp), %ebx
jmp 0x258f
movq 0x4a42(%rip), %r12      # 0x6fc8
jmp 0x258f
movl -0x2c(%rbp), %ebx
movl -0x34(%rbp), %r15d
movl -0x30(%rbp), %edx
cmpl $0x0, -0x38(%rbp)
je 0x25a5
movq %r13, %rdi
movq %r12, %rsi
callq 0x28b9
jmp 0x25b0
movq %r13, %rdi
movq %r12, %rsi
callq 0x2619
testb %r15b, %r15b
je 0x25bf
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
cmpl $0x4, %ebx
jne 0x25ce
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4a0a(%rip), %rdi      # 0x6ff0
leaq 0x1a33(%rip), %rsi      # 0x4020
callq 0x2120
movl $0x1, %edi
callq 0x2180
movq %rax, %rbx
movq %r13, %r12
jmp 0x2609
jmp 0x2606
movq %rax, %rbx
movq %r12, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2210