// File: /workspace/github_c_makefile_star2_O1/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, 0x88(%rsp)
xorl %edx, %edx
divl %ecx
movl %eax, 0xc(%rsp)
testl %edx, %edx
jne 0xf3f3
movq %rsi, %r14
leaq 0xd0(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0x18(%rsi), %rcx
addq $0x8, %r14
cmpq %r14, %rcx
je 0xf354
leaq 0x30(%rsp), %r15
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movq %r14, 0x90(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
xorl %eax, %eax
movq %rax, 0x70(%rsp)
movb $0x0, 0x78(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x40(%rcx), %r12
movq %rcx, 0x98(%rsp)
movq 0x48(%rcx), %rax
movq %rax, 0xa0(%rsp)
cmpq %rax, %r12
je 0xf2c8
movl $0x1, %r13d
movl (%r12), %r14d
movl $0x1, %eax
cmpl $0xa, %r14d
jb 0xf1ac
movl $0x4, %eax
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xf1a5
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf1aa
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf1ac
movl %ecx, %edx
imulq %rbx, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xf174
addl $-0x3, %eax
jmp 0xf1ac
addl $-0x2, %eax
jmp 0xf1ac
decl %eax
movl %eax, %esi
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
xorl %edx, %edx
callq 0x63a0
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %r14d, %edx
callq 0x1022b
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x60e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xf1fb
callq 0x6300
movl %r13d, %eax
xorl %edx, %edx
divl 0xc(%rsp)
testl %edx, %edx
jne 0xf2b3
leaq 0xb8(%rsp), %r14
movq %r14, 0xa8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
callq 0x833e
movq %rbp, %rdi
xorl %esi, %esi
callq 0xca62
movl %eax, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xf260
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xf26d
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0xce10
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0xf27f
callq 0x6300
leaq 0x40(%rsp), %r14
movq %r14, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x63e0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0xf2b3
callq 0x6300
incl %r13d
addq $0x4, %r12
cmpq 0xa0(%rsp), %r12
jne 0xf15d
movq 0x98(%rsp), %r12
leaq 0x20(%r12), %rsi
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x101b0
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x10608
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xf301
callq 0x6300
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
movq 0x90(%rsp), %r14
je 0xf31d
callq 0x6300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf32c
callq 0x6300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xf340
callq 0x6300
movq %r12, %rdi
callq 0x6390
movq %rax, %rcx
cmpq %r14, %rax
jne 0xf113
movq 0x88(%rsp), %rbx
leaq 0x8(%rbx), %rcx
movq 0xd8(%rsp), %rdx
testq %rdx, %rdx
je 0xf3ac
leaq 0xf0(%rsp), %rax
movl -0x20(%rax), %esi
movl %esi, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
movups -0x10(%rax), %xmm0
movups %xmm0, 0x18(%rbx)
movq %rcx, 0x8(%rdx)
movq (%rax), %rcx
movq %rcx, 0x28(%rbx)
movq $0x0, -0x18(%rax)
leaq 0xd0(%rsp), %rcx
movq %rcx, -0x10(%rax)
movq %rcx, -0x8(%rax)
jmp 0xf3ca
movl $0x0, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
movq %rcx, 0x18(%rbx)
movq %rcx, 0x20(%rbx)
movq %rbx, %rax
addq $0x28, %rax
movq $0x0, (%rax)
leaq 0xc8(%rsp), %rdi
callq 0x7ff2
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4335(%rip), %rdi      # 0x1372f
leaq 0x434f(%rip), %rsi      # 0x13750
leaq 0x4350(%rip), %rcx      # 0x13758
movl $0x5c, %edx
callq 0x6200
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xfde4
jmp 0xf453
jmp 0xf450
jmp 0xf450
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
jne 0xf449
jmp 0xf453
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xf453
callq 0x6300
jmp 0xf453
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf462
callq 0x6300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xf476
callq 0x6300
leaq 0xc8(%rsp), %rdi
callq 0x7ff2
movq %rbx, %rdi
callq 0x65b0
nop