// File: /workspace/github_c_makefile_star2_O1/perdisci[P]LSH/lsh.cpp
// Function: rp::LSH::compute_ngram_similarities(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, 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::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>> const&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> const&)
std::vector<float> LSH::compute_ngram_similarities(const CorpusNGramsMap& ng_map, const std::vector<CandidatePair>& cpv) {
        
        std::vector<float> js_vect;
        
        for(CandidatePair cp : cpv) {
            std::set<std::string> v1 = ng_map.at(cp.first);
            std::set<std::string> v2 = ng_map.at(cp.second);
            
            std::vector<std::string> v_int;
            std::vector<std::string> v_uni;
            std::set_intersection(v1.begin(), v1.end(),
                                  v2.begin(), v2.end(),
                                  std::back_inserter(v_int));
            std::set_union(v1.begin(), v1.end(),
                           v2.begin(), v2.end(),
                           std::back_inserter(v_uni));
            
            float js = float(v_int.size())/v_uni.size(); // Jaccard similarity
            js_vect.push_back(js);
        }
        
        return std::move(js_vect);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbp
movq %rdi, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdx), %rsi
movq 0x8(%rdx), %rax
movq %rax, 0x78(%rsp)
cmpq %rax, %rsi
je 0xfcb7
leaq 0x90(%rsp), %r13
leaq 0xb8(%rsp), %rbx
leaq 0xf8(%rsp), %r14
movq %rbx, %rdi
movq %rsi, 0x80(%rsp)
callq 0x9e7c
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xffc8
movq %r14, %rdi
movq %rax, %rsi
callq 0x10342
movq %rbx, %r12
movq %r13, %rbx
movq %rbp, %r15
movq %rbp, %rdi
leaq 0xd8(%rsp), %rsi
callq 0xffc8
leaq 0x88(%rsp), %rdi
movq %rax, %rsi
callq 0x10342
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x60(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x110(%rsp), %rdi
movq 0xa0(%rsp), %rdx
leaq 0x100(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rbp
movq %rbx, %rcx
leaq 0x50(%rsp), %r8
callq 0x11153
movq 0x110(%rsp), %rdi
movq 0xa0(%rsp), %rdx
movq %r13, %rsi
movq %rbp, %rcx
leaq 0x30(%rsp), %r8
callq 0x111fe
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x5, %rax
js 0xfbc2
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xfbda
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movq %rbx, %r13
movq %r12, %rbx
movq %r15, %rbp
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x5, %rax
js 0xfbfa
cvtsi2ss %rax, %xmm1
jmp 0xfc0f
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xfc34
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xfc43
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x10ff4
leaq 0x30(%rsp), %rdi
callq 0x7caa
leaq 0x50(%rsp), %rdi
callq 0x7caa
leaq 0x88(%rsp), %rdi
callq 0x807c
movq %r14, %rdi
callq 0x807c
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0xfc86
callq 0x6300
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xfca0
callq 0x6300
movq 0x80(%rsp), %rsi
addq $0x40, %rsi
cmpq 0x78(%rsp), %rsi
jne 0xfaf5
movaps 0x10(%rsp), %xmm0
movq 0x70(%rsp), %rax
movups %xmm0, (%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfcf0
movq %rax, %rbx
jmp 0xfd2e
movq %rax, %rbx
jmp 0xfd21
movq %rax, %rbx
jmp 0xfd14
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x7caa
leaq 0x50(%rsp), %rdi
callq 0x7caa
leaq 0x88(%rsp), %rdi
callq 0x807c
leaq 0xf8(%rsp), %rdi
callq 0x807c
leaq 0xb8(%rsp), %rdi
callq 0xff1c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xfd3d
callq 0x6300
movq %rbx, %rdi
callq 0x65b0
nop