// File: /workspace/github_cpp_makefile_star2_O1/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 0x1c532
movq %r14, %rdi
callq 0x1c04a
testl %ebx, %ebx
je 0x21742
movq %r13, -0x40(%rbp)
movq %r14, -0x48(%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 0x1b220
movq (%rbx), %rax
movq $0x0, (%rax)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x194cc
leaq -0x90(%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 0x50(%r15), %r13
leaq 0x40(%r15), %r14
xorpd %xmm0, %xmm0
cmpq %r14, %r13
je 0x2176d
movsd %xmm0, -0x38(%rbp)
leaq 0x20(%r13), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1b4d8
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1b4d8
movsd (%rax), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x68(%rbp), %rdx
leaq -0x98(%rbp), %rcx
callq 0x19fd1
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r13, %rdi
callq 0x4280
movq %rax, %r13
cmpq %r14, %rax
jne 0x216dc
jmp 0x21772
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1aca3
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x22102
movq %r13, %rdi
movq %r14, %rsi
callq 0x2228e
jmp 0x217a8
movsd %xmm0, -0x38(%rbp)
leaq -0x98(%rbp), %rdi
movsd 0x5087(%rip), %xmm0     # 0x26808
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x21e6a
leaq -0x98(%rbp), %rdi
callq 0x1b9da
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x217a8
callq 0x4350
movsd -0x38(%rbp), %xmm0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x217c3
movq %rax, %rbx
jmp 0x217d2
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x1b9da
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x217e0
callq 0x4350
movq %rbx, %rdi
callq 0x4650