// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/EM.cc
// Function: likelihood_fb(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, MultiStringFactorGraph const&)
flt_type
likelihood_fb(const string &text,
              const MultiStringFactorGraph &msfg)
{
    map<msfg_node_idx_t, flt_type> fw;
    int text_end_node = msfg.string_end_nodes.at(text);
    set<int> nodes_to_process; nodes_to_process.insert(text_end_node);
    fw[text_end_node] = 0.0;

    while(nodes_to_process.size() > 0) {

        int i = *(nodes_to_process.rbegin());

        const MultiStringFactorGraph::Node &node = msfg.nodes[i];

        for (auto arc = node.incoming.begin(); arc != node.incoming.end(); ++arc) {
            int src_node = (**arc).source_node;
            flt_type cost = fw[i] + *(**arc).cost;
            if (fw.find(src_node) == fw.end()) fw[src_node] = cost;
            else fw[src_node] = add_log_domain_probs(fw[src_node], cost);
            nodes_to_process.insert(src_node);
        }

        nodes_to_process.erase(i);
    }

    return fw.at(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rcx
leaq -0x88(%rbp), %rdx
movl $0x0, (%rdx)
xorl %eax, %eax
movq %rax, 0x8(%rdx)
movq %rdx, 0x10(%rdx)
movq %rdx, 0x18(%rdx)
movq %rax, 0x20(%rdx)
movq %rsi, -0x58(%rbp)
leaq 0x38(%rsi), %rdi
movq %rcx, %rsi
callq 0x138da
movl (%rax), %eax
leaq -0x3c(%rbp), %rsi
movl %eax, (%rsi)
leaq -0xb8(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq -0xc0(%rbp), %rdi
callq 0x1cd4c
movl -0x3c(%rbp), %eax
leaq -0x2c(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x90(%rbp), %rdi
callq 0x1b630
movq $0x0, (%rax)
cmpq $0x0, -0x98(%rbp)
je 0x19b58
leaq -0xc0(%rbp), %r15
leaq -0x90(%rbp), %r13
leaq -0x30(%rbp), %r12
leaq -0xb8(%rbp), %rdi
callq 0x4210
movslq 0x20(%rax), %rax
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rcx
movq 0x20(%rcx), %rcx
shlq $0x7, %rax
leaq (%rcx,%rax), %r14
addq $0x28, %r14
movq 0x10(%r14), %rbx
cmpq %r14, %rbx
je 0x19b33
movq 0x20(%rbx), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x1b630
movsd (%rax), %xmm0
movq 0x20(%rbx), %rax
movq 0x8(%rax), %rax
addsd (%rax), %xmm0
movl -0x34(%rbp), %eax
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
movapd %xmm0, -0x50(%rbp)
je 0x19a67
leaq -0x88(%rbp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movl 0x20(%rdi), %esi
xorl %edi, %edi
cmpl %eax, %esi
setb %dil
movq %rdx, %r8
cmovbq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x19a2e
leaq -0x88(%rbp), %rdi
cmpq %rdi, %r8
je 0x19a67
cmpl %eax, %esi
cmovbq %rcx, %rdx
cmpl 0x20(%rdx), %eax
jae 0x19aa3
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x1b630
movapd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r15, %rdi
leaq -0x34(%rbp), %rsi
callq 0x1cd4c
movq %rbx, %rdi
callq 0x4410
movq %rax, %rbx
cmpq %r14, %rax
jne 0x199ec
jmp 0x19b33
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x1b630
movsd (%rax), %xmm0
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, %xmm1
subsd -0x50(%rbp), %xmm1
movapd %xmm1, %xmm0
xorpd 0xcd4e(%rip), %xmm0     # 0x26820
movapd %xmm1, -0xd0(%rbp)
minsd %xmm1, %xmm0
callq 0x4660
callq 0x46e0
movsd %xmm0, -0x60(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq %r13, %rdi
leaq -0x38(%rbp), %rsi
callq 0x1b630
xorpd %xmm0, %xmm0
cmpltsd -0xd0(%rbp), %xmm0
movapd -0xe0(%rbp), %xmm1
andpd %xmm0, %xmm1
andnpd -0x50(%rbp), %xmm0
orpd %xmm1, %xmm0
movsd -0x60(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax)
jmp 0x19a7e
movq %r15, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1ce68
movq %r15, %rdi
movq %rax, %rsi
callq 0x1ceea
cmpq $0x0, -0x98(%rbp)
jne 0x199b8
leaq -0x2c(%rbp), %rsi
movl $0x0, (%rsi)
leaq -0x90(%rbp), %rdi
callq 0x1b698
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x1ba62
leaq -0x90(%rbp), %rdi
callq 0x1ba0a
movsd -0x50(%rbp), %xmm0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19bbb
jmp 0x19bbb
jmp 0x19bbb
movq %rax, %rbx
jmp 0x19bca
jmp 0x19bbb
jmp 0x19bbb
jmp 0x19bbb
jmp 0x19bbb
jmp 0x19bbb
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x1ba62
leaq -0x90(%rbp), %rdi
callq 0x1ba0a
movq %rbx, %rdi
callq 0x4650