// File: /workspace/github_cpp_makefile_star2_O2/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 0x18649
movq %rdi, %r15
sarq $0x7, %rsi
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
leaq -0x68(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x60(%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
movq 0x50(%r15), %r13
leaq 0x40(%r15), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq %rbx, %r13
je 0x18639
leaq 0x20(%r13), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x19102
movsd (%rax), %xmm0
movq %r15, %rdi
movq %r12, %rsi
leaq -0x60(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x18001
movsd %xmm0, -0x48(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x19102
movsd -0x48(%rbp), %xmm1
mulsd (%rax), %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r13, %rdi
callq 0x43b0
movq %rax, %r13
jmp 0x185da
leaq -0x60(%rbp), %rdi
callq 0x1a10a
movsd -0x38(%rbp), %xmm0
jmp 0x18651
movsd 0xb13f(%rip), %xmm0     # 0x23790
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x1a10a
movq %rbx, %rdi
callq 0x45f0