// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/EM.cc
// Function: forward_backward(MultiStringFactorGraph 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>>, 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>>>>>>&)
flt_type
forward_backward(const MultiStringFactorGraph &msfg,
                 const map<string, flt_type> &word_freqs,
                 transitions_t &stats)
{
    if (msfg.nodes.size() == 0) return MIN_FLOAT;

    vector<flt_type> fw(msfg.nodes.size(), MIN_FLOAT);
    fw[0] = 0.0;

    forward(msfg, fw);
    flt_type total_lp = 0.0;
    for (auto it = msfg.string_end_nodes.begin(); it != msfg.string_end_nodes.end(); ++it) {
        flt_type lp = backward(msfg, it->first, fw, stats, word_freqs.at(it->first));
        total_lp += word_freqs.at(it->first) * lp;
    }

    return total_lp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, -0x40(%rbp)
movq %rsi, %r14
movq 0x28(%rdi), %rsi
subq 0x20(%rdi), %rsi
je 0x1a6ec
movq %rdi, %r15
sarq $0x7, %rsi
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
leaq -0x68(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x60(%rbp), %r12
leaq -0x29(%rbp), %rcx
movq %r12, %rdi
callq 0x1b134
movq (%r12), %rax
movq $0x0, (%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x193e4
movq 0x50(%r15), %r12
leaq 0x40(%r15), %rbx
xorpd %xmm0, %xmm0
cmpq %rbx, %r12
je 0x1a6f6
movsd %xmm0, -0x38(%rbp)
leaq 0x20(%r12), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x1b3f6
movsd (%rax), %xmm0
movq %r15, %rdi
movq %r13, %rsi
leaq -0x60(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x19f01
movsd %xmm0, -0x48(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x1b3f6
movsd -0x48(%rbp), %xmm1
mulsd (%rax), %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r12, %rdi
callq 0x4410
movq %rax, %r12
cmpq %rbx, %rax
jne 0x1a68c
jmp 0x1a6fb
movsd 0xc10c(%rip), %xmm0     # 0x26800
jmp 0x1a70e
movsd %xmm0, -0x38(%rbp)
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1a709
callq 0x4350
movsd -0x38(%rbp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x1a72e
callq 0x4350
movq %rbx, %rdi
callq 0x4650