// File: /workspace/github_cpp_makefile_star2_O3/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 0x1dc30
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 0x236e4
leaq -0xa8(%rbp), %r15
leaq 0x20(%r13), %rsi
movq 0x68(%r13), %rbx
movq %r15, %rdi
callq 0x1af86
movq %rbx, %xmm0
punpckldq 0x3235(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x323d(%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 0x236d0
leaq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x1af86
movsd (%rax), %xmm0
addsd 0x314c(%rip), %xmm0     # 0x26808
movsd %xmm0, (%rax)
movq %rbx, %rdi
callq 0x4410
movq %rax, %rbx
cmpq %r14, %rax
jne 0x236a4
movq %r13, %rdi
callq 0x4410
movq %rax, %r13
cmpq %r12, %rax
jne 0x2365e
movq -0x50(%rbp), %r12
movq -0x48(%rbp), %r15
cmpq %r15, %r12
je 0x23729
leaq -0xa8(%rbp), %rbx
movq -0x60(%rbp), %r14
movq -0x58(%rbp), %r13
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1af86
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%r12)
addq $0x28, %r12
movq -0x48(%rbp), %r15
cmpq %r15, %r12
jne 0x23700
movq -0x50(%rbp), %r12
jmp 0x23731
movq -0x60(%rbp), %r14
movq -0x58(%rbp), %r13
cmpq %r15, %r12
je 0x237f0
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 0x2447c
movq -0x68(%rbp), %rdx
testq %rdx, %rdx
je 0x23791
movq -0x70(%rbp), %rcx
leaq -0x6279(%rip), %r8      # 0x1d50b
movq %r12, %rdi
movq %r15, %rsi
callq 0x245b0
jmp 0x237a3
leaq -0x628d(%rip), %rdx     # 0x1d50b
movq %r12, %rdi
movq %r15, %rsi
callq 0x244fb
leaq -0x78(%rbp), %rdi
callq 0x246a0
movq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r15
je 0x237f0
leaq 0x8(%r13), %rbx
movl -0x2c(%rbp), %r12d
movq %r13, %rdi
movq %r15, %rsi
callq 0x10c22
cmpq %rbx, %rax
jne 0x237e6
movq %r14, %rdi
movq %r15, %rsi
callq 0x1af86
movq $0x0, (%rax)
cmpq %r12, 0x28(%r14)
jae 0x237f0
addq $0x28, %r15
cmpq -0x48(%rbp), %r15
jne 0x237be
movl 0x28(%r14), %ebx
leaq -0xa8(%rbp), %rdi
callq 0x5ce4
leaq -0x50(%rbp), %rdi
callq 0x1fbf4
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 0x246a0
jmp 0x2383d
jmp 0x2383a
movq %rax, %rbx
jmp 0x23849
jmp 0x2383a
jmp 0x2383a
jmp 0x2383a
jmp 0x2383a
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x5ce4
leaq -0x50(%rbp), %rdi
callq 0x1fbf4
movq %rbx, %rdi
callq 0x4650