// File: /workspace/github_cpp_makefile_star2_O2/cristian-bicheru[P]arith/./huffman.h
// Function: void huffman::CompressBuffer<unsigned char, unsigned long>(std::vector<unsigned char, std::allocator<unsigned char>>&, buffer::CodecByteStream&)
void CompressBuffer(std::vector<SymbolType>& UncompressedBuffer, buffer::CodecByteStream& CompressedBuffer) {
        std::map<SymbolType, ValueType> SortedFrequencyTable;
        PopulateFrequencyTable(SortedFrequencyTable, UncompressedBuffer);
        HuffmanTree<SymbolType, ValueType> HuffTree(SortedFrequencyTable);
        HuffTree.ConstructSymbolTable();
        auto SymTable = HuffTree.GetSymbolTable();
        uint64_t index = sizeof(uint16_t)+sizeof(uint64_t);
        for (auto keyval : SortedFrequencyTable) {
            buffer::EncodeTypeToBuffer<SymbolType>(CompressedBuffer.GetBuffer(), index, &keyval.first);
            index += sizeof(SymbolType);
            buffer::EncodeTypeToBuffer<ValueType>(CompressedBuffer.GetBuffer(), index, &keyval.second);
            index += sizeof(ValueType);
        }
        auto ushrt = uint16_t(index);
        buffer::EncodeTypeToBuffer<uint16_t>(CompressedBuffer.GetBuffer(), 0, &ushrt);
        auto ull = uint64_t(UncompressedBuffer.size());
        buffer::EncodeTypeToBuffer<uint64_t>(CompressedBuffer.GetBuffer(), sizeof(uint16_t), &ull);

        std::vector<bool> code;
        for (SymbolType symbol : UncompressedBuffer) {
            code = SymTable[symbol];
            for (bool bit : code) {
                CompressedBuffer.WriteBit(bit);
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x60(%rsp), %r13
andl $0x0, (%r13)
andq $0x0, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
andq $0x0, 0x20(%r13)
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x4514
leaq 0xb8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x4552
leaq 0xb8(%rsp), %rdi
callq 0x4756
leaq 0xc0(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0x7c52
movq 0x70(%rsp), %r12
pushq $0xa
popq %rbp
leaq 0x18(%rsp), %r15
cmpq %r13, %r12
je 0x3acc
movups 0x20(%r12), %xmm0
movaps %xmm0, 0x10(%rsp)
movb 0x10(%rsp), %al
movq (%rbx), %rcx
movb %al, (%rcx,%rbp)
leaq 0x1(%rbp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x38de
addq $0x9, %rbp
movq %r12, %rdi
callq 0x2130
movq %rax, %r12
jmp 0x3a92
leaq 0xe(%rsp), %rdx
movw %bp, (%rdx)
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x480e
movq 0x8(%r14), %rax
subq (%r14), %rax
leaq 0x50(%rsp), %rdx
movq %rax, (%rdx)
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x38de
leaq 0x10(%rsp), %rax
andq $0x0, (%rax)
andl $0x0, 0x8(%rax)
andq $0x0, 0x10(%rax)
andl $0x0, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, 0x40(%rsp)
cmpq 0x40(%rsp), %rax
je 0x3ba8
movq %rax, 0x48(%rsp)
movb (%rax), %al
movb %al, 0xd(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xd(%rsp), %rsi
callq 0x482a
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x4878
movq 0x10(%rsp), %r12
movq 0x20(%rsp), %r15
xorl %ebp, %ebp
movl 0x28(%rsp), %r14d
cmpq %r15, %r12
jne 0x3b6e
cmpl %r14d, %ebp
je 0x3b9b
movq (%r12), %rax
xorl %esi, %esi
btq %rbp, %rax
setb %sil
movq %rbx, %rdi
callq 0x3718
xorl %eax, %eax
cmpl $0x3f, %ebp
leal 0x1(%rbp), %ecx
sete %al
leaq (%r12,%rax,8), %r12
cmovel %r13d, %ecx
movl %ecx, %ebp
jmp 0x3b64
movq 0x48(%rsp), %rax
incq %rax
jmp 0x3b22
leaq 0x10(%rsp), %rdi
callq 0x490e
leaq 0x88(%rsp), %rdi
callq 0x7f52
leaq 0xb8(%rsp), %rdi
callq 0x491e
leaq 0x58(%rsp), %rdi
callq 0x7f66
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3bea
movq %rax, %rbx
jmp 0x3c12
jmp 0x3bf1
movq %rax, %rbx
jmp 0x3c1f
jmp 0x3bf8
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x490e
leaq 0x88(%rsp), %rdi
callq 0x7f52
leaq 0xb8(%rsp), %rdi
callq 0x491e
leaq 0x58(%rsp), %rdi
callq 0x7f66
movq %rbx, %rdi
callq 0x22e0