// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/src/Bigrams.cc
// Function: Bigrams::collect_trans_stats(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&, MultiStringFactorGraph&, 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>>>>>>&, 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>>>&, bool)
flt_type
Bigrams::collect_trans_stats(const map<string, flt_type> &words,
                             MultiStringFactorGraph &msfg,
                             transitions_t &trans_stats,
                             map<string, flt_type> &unigram_stats,
                             bool fb)
{
    trans_stats.clear();
    unigram_stats.clear();

    flt_type total_lp = 0.0;
    if (fb) {
        vector<flt_type> fw(msfg.nodes.size(), MIN_FLOAT);
        fw[0] = 0.0;
        forward(msfg, fw);
        transitions_t word_stats;
        for (auto it = msfg.string_end_nodes.begin(); it != msfg.string_end_nodes.end(); ++it)
            total_lp += words.at(it->first) * backward(msfg, it->first, fw, word_stats, words.at(it->first));
        update_trans_stats(word_stats, 1.0, trans_stats, unigram_stats);
    }
    else {
        total_lp = viterbi(msfg, words, trans_stats);
        finalize_viterbi_stats(msfg, trans_stats);
        get_unigram_stats(trans_stats, unigram_stats);
    }

    return total_lp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, %ebx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r12
movq %rdx, %rdi
callq 0x1a3dc
movq %r14, %rdi
callq 0x19cca
testl %ebx, %ebx
je 0x1f106
movq %r14, -0x40(%rbp)
movq 0x28(%r15), %rsi
subq 0x20(%r15), %rsi
sarq $0x7, %rsi
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
leaq -0x98(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x68(%rbp), %rbx
leaq -0x29(%rbp), %rcx
movq %rbx, %rdi
callq 0x18ee6
movq (%rbx), %rax
andq $0x0, (%rax)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x17729
leaq -0x90(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq 0x50(%r15), %rbx
movq %r15, -0x48(%rbp)
leaq 0x40(%r15), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq %r14, %rbx
je 0x1f131
movq %r13, %r15
leaq 0x20(%rbx), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x19102
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x19102
movsd (%rax), %xmm0
movq -0x48(%rbp), %rdi
movq %r13, %rsi
leaq -0x68(%rbp), %rdx
leaq -0x98(%rbp), %rcx
callq 0x18001
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
callq 0x4270
movq %rax, %rbx
movq %r15, %r13
jmp 0x1f095
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x18a8f
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x1fa18
movq %r13, %rdi
movq %r14, %rsi
callq 0x1fb5e
jmp 0x1f161
leaq -0x98(%rbp), %rdi
movsd 0x4658(%rip), %xmm0     # 0x23798
movq %r13, %rsi
movq -0x40(%rbp), %rdx
callq 0x1f7be
leaq -0x98(%rbp), %rdi
callq 0x19564
leaq -0x68(%rbp), %rdi
callq 0x1a10a
movsd -0x38(%rbp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f17c
movq %rax, %rbx
jmp 0x1f18b
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x19564
leaq -0x68(%rbp), %rdi
callq 0x1a10a
movq %rbx, %rdi
callq 0x45f0