// File: /workspace/github_cpp_makefile_star2_O1/aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::init_candidates_num_contexts(unsigned int, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, 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, double>>>, 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::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, 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, double>>>>>> const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, 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, double>>> const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, 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, double>>>&, 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&)
int
Bigrams::init_candidates_num_contexts(unsigned int n_candidates,
                                      const transitions_t &transitions,
                                      const map<string, flt_type> &unigram_stats,
                                      map<string, flt_type> &candidates,
                                      const set<string> &stoplist)
{
    vector<pair<string, flt_type> > sorted_stats;
    Unigrams::sort_vocab(unigram_stats, sorted_stats, false);

    map<string, flt_type> ctxt_estimate;
    for (auto srcit = transitions.begin(); srcit != transitions.end(); ++srcit) {
        ctxt_estimate[srcit->first] += srcit->second.size();
        for (auto tgtit = srcit->second.begin(); tgtit != srcit->second.end(); ++tgtit)
            ctxt_estimate[tgtit->first] += 1;
    }

    for (auto ssit = sorted_stats.begin(); ssit != sorted_stats.end(); ++ssit)
        ssit->second = ctxt_estimate[ssit->first];
    stable_sort(sorted_stats.begin(), sorted_stats.end(), ascending_sort);

    for (auto it = sorted_stats.begin(); it != sorted_stats.end(); ++it) {
        if (stoplist.find(it->first) != stoplist.end()) continue;
        candidates[it->first] = 0.0;
        if (candidates.size() >= n_candidates) break;
    }

    return candidates.size();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, -0x58(%rbp)
movq %rcx, -0x60(%rbp)
movq %rsi, %r12
movl %edi, -0x2c(%rbp)
xorpd %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq %rdx, %rdi
xorl %edx, %edx
callq 0x1dd68
leaq -0xa0(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq 0x18(%r12), %r13
addq $0x8, %r12
cmpq %r12, %r13
je 0x2387c
leaq -0xa8(%rbp), %r15
leaq 0x20(%r13), %rsi
movq 0x68(%r13), %rbx
movq %r15, %rdi
callq 0x1b05e
movq %rbx, %xmm0
punpckldq 0x309d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x30a5(%rip), %xmm0     # 0x268c0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
movq 0x58(%r13), %rbx
leaq 0x48(%r13), %r14
cmpq %r14, %rbx
je 0x23868
leaq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x1b05e
movsd (%rax), %xmm0
addsd 0x2fb4(%rip), %xmm0     # 0x26808
movsd %xmm0, (%rax)
movq %rbx, %rdi
callq 0x4410
movq %rax, %rbx
cmpq %r14, %rax
jne 0x2383c
movq %r13, %rdi
callq 0x4410
movq %rax, %r13
cmpq %r12, %rax
jne 0x237f6
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r15
cmpq %r15, %r12
movq -0x60(%rbp), %r14
movq -0x58(%rbp), %r13
je 0x238bb
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1b05e
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%r12)
addq $0x28, %r12
movq -0x48(%rbp), %r15
cmpq %r15, %r12
jne 0x23898
movq -0x50(%rbp), %r12
cmpq %r15, %r12
je 0x23936
movq %r15, %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
leaq 0x1(%rcx), %rax
shrq $0x3f, %rax
leaq (%rcx,%rax), %rdx
incq %rdx
sarq %rdx
leaq -0x78(%rbp), %rdi
movq %r12, %rsi
callq 0x24606
movq -0x68(%rbp), %rdx
testq %rdx, %rdx
je 0x2391b
movq -0x70(%rbp), %rcx
leaq -0x62cf(%rip), %r8      # 0x1d63f
movq %r12, %rdi
movq %r15, %rsi
callq 0x24738
jmp 0x2392d
leaq -0x62e3(%rip), %rdx     # 0x1d63f
movq %r12, %rdi
movq %r15, %rsi
callq 0x24685
leaq -0x78(%rbp), %rdi
callq 0x24828
movq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r15
je 0x2397a
leaq 0x8(%r13), %rbx
movl -0x2c(%rbp), %r12d
movq %r13, %rdi
movq %r15, %rsi
callq 0x10d38
cmpq %rbx, %rax
jne 0x23970
movq %r14, %rdi
movq %r15, %rsi
callq 0x1b05e
movq $0x0, (%rax)
cmpq %r12, 0x28(%r14)
jae 0x2397a
addq $0x28, %r15
cmpq -0x48(%rbp), %r15
jne 0x23948
movl 0x28(%r14), %ebx
leaq -0xa8(%rbp), %rdi
callq 0x5cea
leaq -0x50(%rbp), %rdi
callq 0x1fd8a
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x24828
jmp 0x239c7
jmp 0x239c4
movq %rax, %rbx
jmp 0x239d3
jmp 0x239c4
jmp 0x239c4
jmp 0x239c4
jmp 0x239c4
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x5cea
leaq -0x50(%rbp), %rdi
callq 0x1fd8a
movq %rbx, %rdi
callq 0x4650