// File: /workspace/github_c_makefile_star2_O3/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
xorl %edx, %edx
divl %ecx
movl %eax, 0xc(%rsp)
testl %edx, %edx
jne 0xe34b
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x90(%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 0xe302
movq %rbx, 0xb8(%rsp)
leaq 0x30(%rsp), %r15
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movq %r14, 0xc0(%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, 0xc8(%rsp)
movq 0x48(%rcx), %rax
movq %rax, 0xd0(%rsp)
cmpq %rax, %r12
je 0xe201
movl $0x1, %r13d
movl (%r12), %r14d
movl $0x1, %eax
cmpl $0xa, %r14d
jb 0xe0e5
movl $0x4, %eax
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xe0de
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xe0e3
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xe0e5
movl %ecx, %edx
imulq %rbx, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xe0ad
addl $-0x3, %eax
jmp 0xe0e5
addl $-0x2, %eax
jmp 0xe0e5
decl %eax
movl %eax, %esi
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
xorl %edx, %edx
callq 0x53a0
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %r14d, %edx
callq 0xf125
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x50e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xe134
callq 0x5300
movl %r13d, %eax
xorl %edx, %edx
divl 0xc(%rsp)
testl %edx, %edx
jne 0xe1ec
leaq 0xe8(%rsp), %r14
movq %r14, 0xd8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
callq 0x734c
movq %rbp, %rdi
xorl %esi, %esi
callq 0xb98e
movl %eax, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xe199
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xe1a6
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0xbd48
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0xe1b8
callq 0x5300
leaq 0x40(%rsp), %r14
movq %r14, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x53e0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0xe1ec
callq 0x5300
incl %r13d
addq $0x4, %r12
cmpq 0xd0(%rsp), %r12
jne 0xe096
movq 0xc8(%rsp), %r12
leaq 0x20(%r12), %rsi
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0xf0aa
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0xf4a2
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xe23a
callq 0x5300
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
movq 0xc0(%rsp), %r14
je 0xe256
callq 0x5300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe265
callq 0x5300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xe279
callq 0x5300
movq %r12, %rdi
callq 0x5390
movq %rax, %rcx
cmpq %r14, %rax
jne 0xe04c
movq 0x98(%rsp), %rsi
movq 0xb8(%rsp), %rbx
leaq 0x8(%rbx), %rax
testq %rsi, %rsi
je 0xe306
movl 0x90(%rsp), %ecx
movq %rsi, 0x10(%rbx)
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %rdx
movq %rax, 0x8(%rsi)
movq 0xb0(%rsp), %rax
movq %rax, 0x28(%rbx)
movq $0x0, 0x98(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movq %rdi, %rax
leaq 0xb0(%rsp), %rsi
jmp 0xe317
leaq 0x8(%rbx), %rax
movq $0x0, 0x10(%rbx)
leaq 0x28(%rbx), %rsi
xorl %ecx, %ecx
movq %rax, %rdx
movq %rax, 0x18(%rbx)
movq %rdx, 0x20(%rbx)
movq $0x0, (%rsi)
movl %ecx, 0x8(%rbx)
leaq 0x88(%rsp), %rdi
callq 0x6fee
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43dd(%rip), %rdi      # 0x1272f
leaq 0x43f7(%rip), %rsi      # 0x12750
leaq 0x43f8(%rip), %rcx      # 0x12758
movl $0x5c, %edx
callq 0x5200
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xece4
jmp 0xe3ab
jmp 0xe3a8
jmp 0xe3a8
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
jne 0xe3a1
jmp 0xe3ab
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xe3ab
callq 0x5300
jmp 0xe3ab
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe3ba
callq 0x5300
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xe3ce
callq 0x5300
leaq 0x88(%rsp), %rdi
callq 0x6fee
movq %rbx, %rdi
callq 0x55b0
nop