// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/EM.cc
// Function: forward(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, MultiStringFactorGraph const&, std::map<unsigned int, double, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, double>>>&)
flt_type
forward(const string &text,
        const MultiStringFactorGraph &msfg,
        map<msfg_node_idx_t, flt_type> &fw)
{
    map<msfg_node_idx_t, vector<MultiStringFactorGraph::Arc*> > arcs;
    msfg.collect_arcs(text, arcs);

    for (auto ndit = arcs.begin(); ndit != arcs.end(); ++ndit) {

        const MultiStringFactorGraph::Node &node = msfg.nodes[ndit->first];
        for (auto arc = node.outgoing.begin(); arc != node.outgoing.end(); ++arc) {
            int tgt_node = (**arc).target_node;
            flt_type cost = fw[ndit->first] + *(**arc).cost;
            if (fw.find(tgt_node) == fw.end()) fw[tgt_node] = cost;
            else fw[tgt_node] = add_log_domain_probs(fw[tgt_node], cost);
        }
    }

    return fw.at(msfg.string_end_nodes.at(text));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %rbx
movq %rsi, %rcx
movq %rdi, %rsi
leaq -0xb8(%rbp), %r14
movl $0x0, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
movq %rax, 0x20(%r14)
leaq -0xc0(%rbp), %rdx
movq %rcx, -0x48(%rbp)
movq %rcx, %rdi
movq %rsi, -0x58(%rbp)
callq 0x12e7c
movq -0xa8(%rbp), %rcx
cmpq %r14, %rcx
je 0x196d9
leaq 0x8(%rbx), %r12
movq %rcx, -0x50(%rbp)
movl 0x20(%rcx), %eax
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rcx
shlq $0x7, %rax
leaq (%rcx,%rax), %r13
addq $0x58, %r13
movq 0x10(%r13), %r15
cmpq %r13, %r15
je 0x196bd
movq -0x50(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x68(%rbp)
movq 0x20(%r15), %rax
movl 0x4(%rax), %r14d
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
callq 0x1b5c8
movsd (%rax), %xmm0
movq 0x20(%r15), %rax
movq 0x8(%rax), %rax
addsd (%rax), %xmm0
movq 0x10(%rbx), %rax
testq %rax, %rax
movapd %xmm0, -0x40(%rbp)
je 0x19605
movq %r12, %rcx
xorl %edx, %edx
cmpl %r14d, 0x20(%rax)
setb %dl
cmovaeq %rax, %rcx
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0x195e3
cmpq %r12, %rcx
je 0x19605
cmpl 0x20(%rcx), %r14d
jae 0x19633
movl %r14d, -0x2c(%rbp)
movq %rbx, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1b630
movapd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r15, %rdi
callq 0x4410
movq %rax, %r15
cmpq %r13, %rax
jne 0x195ae
jmp 0x196bd
movl %r14d, -0x2c(%rbp)
movq %rbx, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1b630
movsd (%rax), %xmm0
movapd %xmm0, -0x90(%rbp)
movapd %xmm0, %xmm1
subsd -0x40(%rbp), %xmm1
movapd %xmm1, %xmm0
xorpd 0xd1bc(%rip), %xmm0     # 0x26820
movapd %xmm1, -0x80(%rbp)
minsd %xmm1, %xmm0
callq 0x4660
callq 0x46e0
movsd %xmm0, -0x60(%rbp)
movl %r14d, -0x30(%rbp)
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1b630
xorpd %xmm0, %xmm0
cmpltsd -0x80(%rbp), %xmm0
movapd -0x90(%rbp), %xmm1
andpd %xmm0, %xmm1
andnpd -0x40(%rbp), %xmm0
orpd %xmm1, %xmm0
movsd -0x60(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax)
jmp 0x1961e
movq -0x50(%rbp), %rdi
callq 0x4280
movq %rax, %rcx
leaq -0xb8(%rbp), %rax
cmpq %rax, %rcx
jne 0x1957a
movq -0x48(%rbp), %rdi
addq $0x38, %rdi
movq -0x58(%rbp), %rsi
callq 0x138da
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1b698
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x1b9a4
movsd -0x40(%rbp), %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19729
jmp 0x19729
jmp 0x19729
jmp 0x19729
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x1b9a4
movq %rbx, %rdi
callq 0x4650