// File: /workspace/github_c_makefile_star2_O2/perdisci[P]LSH/lsh.cpp
// Function: rp::LSH::compute_bands(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<unsigned int, std::allocator<unsigned int>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::vector<unsigned int, std::allocator<unsigned int>>>>> const&, unsigned int, unsigned int)
BandsHashMap LSH::compute_bands(const MinHashMap& mh_map, const unsigned minhash_sig_len, const unsigned lsh_bands) {
        
        assert(minhash_sig_len % lsh_bands == 0);
        
        BandsHashMap local_bh_map;
        for(auto& i : mh_map) {
            std::string s;
            VUint32 bh;
            unsigned index = 1;
            // std::cout << "=========== " << i.first << std::endl;
            for(auto mh : i.second) {
                // s += "|" + std::to_string(mh) + "|"; // for debugging
                s += std::to_string(mh);
                if(index % (minhash_sig_len/lsh_bands) == 0) {
                    bh.push_back(MinHash::shash32(s));
                    // std::cout << "bh = " << s << " - " << MinHash::shash32(s) << std::endl;
                    s = std::string();
                }
                ++index;
            }
            // std::cout << "==== bh size = " << bh.size() << std::endl;
            local_bh_map.insert(std::make_pair(i.first,bh));
        }
        
        return std::move(local_bh_map);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %edx, %eax
movq %rdi, 0x30(%rsp)
xorl %edx, %edx
divl %ecx
movl %eax, 0xc(%rsp)
testl %edx, %edx
jne 0xd31e
movq %rsi, %rbx
leaq 0xb0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x18(%rsi), %rcx
addq $0x8, %rbx
leaq 0x70(%rsp), %r13
leaq 0x50(%rsp), %r15
movq %rbx, 0x38(%rsp)
cmpq %rbx, %rcx
je 0xd2e3
leaq 0x20(%rcx), %rax
movq %rax, 0x48(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x40(%rcx), %rbx
movq %rcx, 0x40(%rsp)
movq 0x48(%rcx), %r14
pushq $0x1
popq %r12
cmpq %r14, %rbx
je 0xd28d
movl (%rbx), %esi
movq %r13, %rdi
callq 0xdc64
movq %r15, %rdi
movq %r13, %rsi
callq 0x6630
movq %r13, %rdi
callq 0x6658
movl %r12d, %eax
xorl %edx, %edx
divl 0xc(%rsp)
testl %edx, %edx
jne 0xd281
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x6430
movq %rbp, %rdi
xorl %esi, %esi
callq 0xb3ec
movl %eax, 0x70(%rsp)
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0xb72e
leaq 0xd8(%rsp), %rdi
callq 0x6658
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
movb $0x0, 0x80(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x63b0
movq %r13, %rdi
callq 0x6658
incl %r12d
addq $0x4, %rbx
jmp 0xd1e5
movq %r13, %rdi
movq 0x48(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0xdfe0
leaq 0xa8(%rsp), %rdi
movq %r13, %rsi
callq 0xe524
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %r14
movq %r13, %rdi
callq 0xdc22
leaq 0x10(%rsp), %rdi
callq 0x781e
movq %r15, %rdi
callq 0x6658
movq %r14, %rdi
callq 0x6370
movq %rax, %rcx
jmp 0xd19f
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0xb0(%rsp), %rsi
callq 0xe188
leaq 0xa8(%rsp), %rdi
callq 0x788e
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43ca(%rip), %rdi      # 0x116ef
leaq 0x43e4(%rip), %rsi      # 0x11710
leaq 0x43e5(%rip), %rcx      # 0x11718
pushq $0x5c
popq %rdx
callq 0x6210
jmp 0xd35b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xdc22
jmp 0xd36d
jmp 0xd35b
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0xd368
movq %rax, %rbx
jmp 0xd36d
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x6658
leaq 0x10(%rsp), %rdi
callq 0x781e
leaq 0x50(%rsp), %rdi
callq 0x6658
leaq 0xa8(%rsp), %rdi
callq 0x788e
movq %rbx, %rdi
callq 0x65a0