// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x18(%rsp)
movq %rdi, %rax
movq %rax, 0x20(%rsp)
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movl %edx, 0x194(%rsp)
movl %ecx, 0x190(%rsp)
movl 0x194(%rsp), %eax
xorl %edx, %edx
divl 0x190(%rsp)
cmpl $0x0, %edx
jne 0x23089
jmp 0x230a8
leaq 0xf684(%rip), %rdi      # 0x32714
leaq 0xf69e(%rip), %rsi      # 0x32735
movl $0x5c, %edx
leaq 0xf69a(%rip), %rcx      # 0x3273d
callq 0x82e0
leaq 0x160(%rsp), %rdi
callq 0x249c0
movq 0x198(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rdi
callq 0x24f70
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rdi
callq 0x24fa0
movq %rax, 0x148(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x24fd0
testb $0x1, %al
jne 0x2310d
jmp 0x233f4
leaq 0x150(%rsp), %rdi
callq 0x24ff0
movq %rax, 0x140(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x8680
leaq 0x108(%rsp), %rdi
callq 0x19550
movl $0x1, 0x104(%rsp)
movq 0x140(%rsp), %rax
addq $0x20, %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0xb820
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0xb850
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x25010
testb $0x1, %al
jne 0x231a3
jmp 0x2332c
leaq 0xf0(%rsp), %rdi
callq 0x25050
movl (%rax), %eax
movl %eax, 0xe4(%rsp)
movl 0xe4(%rsp), %esi
leaq 0xc0(%rsp), %rdi
callq 0x25060
jmp 0x231cf
leaq 0x120(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x85c0
jmp 0x231e6
leaq 0xc0(%rsp), %rdi
callq 0x8928
movl 0x104(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x194(%rsp), %eax
xorl %edx, %edx
divl 0x190(%rsp)
movl %eax, %ecx
movl 0x14(%rsp), %eax
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
jne 0x23309
leaq 0x90(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x81a0
jmp 0x23238
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
callq 0x19060
movl %eax, 0x10(%rsp)
jmp 0x2324d
movl 0x10(%rsp), %eax
movl %eax, 0xb0(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x19560
jmp 0x2326f
leaq 0x90(%rsp), %rdi
callq 0x8928
leaq 0x70(%rsp), %rdi
callq 0x8680
leaq 0x120(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x8570
leaq 0x70(%rsp), %rdi
callq 0x8928
jmp 0x23309
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x233cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x8928
jmp 0x233cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x8928
jmp 0x233cb
movl 0x104(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x104(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x25160
jmp 0x23185
movq 0x140(%rsp), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x24dd0
jmp 0x23348
leaq 0x160(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x24d80
movb %dl, 0x7(%rsp)
movq %rax, 0x8(%rsp)
jmp 0x23365
movb 0x7(%rsp), %al
movq 0x8(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movb %al, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x24e10
leaq 0x108(%rsp), %rdi
callq 0xbe70
leaq 0x120(%rsp), %rdi
callq 0x8928
leaq 0x150(%rsp), %rdi
callq 0x25180
jmp 0x230ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x24e10
leaq 0x108(%rsp), %rdi
callq 0xbe70
leaq 0x120(%rsp), %rdi
callq 0x8928
leaq 0x160(%rsp), %rdi
callq 0xa4b0
jmp 0x23420
movq 0x18(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x251b0
leaq 0x160(%rsp), %rdi
callq 0xa4b0
movq 0x20(%rsp), %rax
addq $0x1a8, %rsp            # imm = 0x1A8
retq
movq 0xb8(%rsp), %rdi
callq 0x8820
nopl (%rax)