// File: /workspace/github_cpp_makefile_star2_O1/marknelson[P]LZW/./lzw.h
// Function: void lzw::compress<std::istream, std::ostream>(std::istream&, std::ostream&, unsigned int)
void compress( INPUT &input, OUTPUT &output, const unsigned int max_code = 32767 )
{
    input_symbol_stream<INPUT> in( input );
    output_code_stream<OUTPUT> out( output, max_code );

    std::unordered_map<std::string, unsigned int> codes( (max_code * 11)/10 );
    for ( unsigned int i = 0 ; i < 256 ; i++ )
        codes[std::string(1,i)] = i;
    unsigned int next_code = 257;
    std::string current_string;
    char c;
    while ( in >> c ) {
        current_string = current_string + c;
        if ( codes.find(current_string) == codes.end() ) {
            if ( next_code <= max_code )
                codes[ current_string ] = next_code++;
            current_string.erase(current_string.size()-1);
            out << codes[current_string];
            current_string = c;
        }
    }
    if ( current_string.size() )
        out << codes[current_string];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, -0x60(%rbp)
movl $0x9, -0xa8(%rbp)
movq %rsi, -0xa0(%rbp)
movaps 0x19c7(%rip), %xmm0     # 0x4010
movups %xmm0, -0x98(%rbp)
movl %edx, -0x88(%rbp)
leal (%rdx,%rdx,4), %eax
movq %rdx, -0x58(%rbp)
leal (%rdx,%rax,2), %eax
movl $0xcccccccd, %esi       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x23, %rsi
leaq -0xe0(%rbp), %rdi
leaq -0x50(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq -0x29(%rbp), %r8
callq 0x2cf6
xorl %r13d, %r13d
leaq -0x40(%rbp), %r14
leaq -0x50(%rbp), %rbx
leaq -0xe0(%rbp), %r15
movq %r14, -0x50(%rbp)
movsbl %r13b, %edx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x2170
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e22
movl %r13d, (%rax)
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x26c8
callq 0x2100
incl %r13d
cmpl $0x100, %r13d           # imm = 0x100
jne 0x2697
leaq -0x50(%rbp), %r15
movq %r14, (%r15)
movq $0x0, 0x8(%r15)
movb $0x0, 0x10(%r15)
movl $0x101, -0x30(%rbp)     # imm = 0x101
leaq -0x70(%rbp), %rbx
leaq -0x80(%rbp), %r13
movq -0x60(%rbp), %rdi
leaq -0x29(%rbp), %rsi
callq 0x21b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x27ee
movb -0x29(%rbp), %r12b
movq %rbx, -0x80(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3256
movq -0x78(%rbp), %rsi
movsbl %r12b, %r8d
movl $0x1, %ecx
movq %r13, %rdi
xorl %edx, %edx
callq 0x2240
movq %r15, %rdi
movq %r13, %rsi
callq 0x2190
movq -0x80(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2761
callq 0x2100
leaq -0xe0(%rbp), %rdi
movq %r15, %rsi
callq 0x32f0
testq %rax, %rax
jne 0x26f7
movl -0x30(%rbp), %eax
cmpl -0x58(%rbp), %eax
ja 0x2796
leaq -0xe0(%rbp), %rdi
movq %r15, %rsi
callq 0x3334
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
incl %ecx
movl %ecx, -0x30(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
subq $0x1, %rdx
jb 0x284c
movq %rdx, -0x48(%rbp)
movq -0x50(%rbp), %rax
movb $0x0, (%rax,%rdx)
leaq -0xe0(%rbp), %rdi
movq %r15, %rsi
callq 0x3334
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x2c84
movsbl -0x29(%rbp), %r8d
movq -0x48(%rbp), %rdx
movl $0x1, %ecx
movq %r15, %rdi
xorl %esi, %esi
callq 0x2240
jmp 0x26f7
cmpq $0x0, -0x48(%rbp)
je 0x2814
leaq -0xe0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3334
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x2c84
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x2822
callq 0x2100
leaq -0xe0(%rbp), %rdi
callq 0x34aa
leaq -0xa8(%rbp), %rdi
callq 0x2cc8
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a43(%rip), %rdi      # 0x4296
leaq 0x1a28(%rip), %rsi      # 0x4282
xorl %eax, %eax
callq 0x21e0
movq %rax, %r15
jmp 0x28a5
jmp 0x2888
jmp 0x2888
jmp 0x2888
movq %rax, %r15
movq -0x80(%rbp), %rdi
cmpq %rbx, %rdi
je 0x288b
callq 0x2100
jmp 0x288b
jmp 0x2888
jmp 0x2888
movq %rax, %r15
jmp 0x2899
movq %rax, %r15
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x2899
callq 0x2100
leaq -0xe0(%rbp), %rdi
callq 0x34aa
leaq -0xa8(%rbp), %rdi
callq 0x2cc8
movq %r15, %rdi
callq 0x2210