// File: /workspace/github_cpp_makefile_star2_O1/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 -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)
movq %rsi, -0x58(%rbp)
leaq 0x38(%rsi), %rdi
movq %rcx, %rsi
callq 0x139bc
movl (%rax), %eax
leaq -0x3c(%rbp), %rsi
movl %eax, (%rsi)
leaq -0x88(%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 -0x90(%rbp), %rdi
callq 0x1ce60
movl -0x3c(%rbp), %eax
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
leaq -0xc0(%rbp), %rdi
callq 0x1b712
movq $0x0, (%rax)
cmpq $0x0, -0x68(%rbp)
je 0x19c36
leaq -0x90(%rbp), %r12
leaq -0xc0(%rbp), %r13
leaq -0x88(%rbp), %rdi
callq 0x4210
movslq 0x20(%rax), %rax
movl %eax, -0x30(%rbp)
movq -0x58(%rbp), %rcx
movq 0x20(%rcx), %rcx
shlq $0x7, %rax
leaq (%rcx,%rax), %r15
addq $0x28, %r15
movq 0x10(%r15), %rbx
cmpq %r15, %rbx
je 0x19c14
movq 0x20(%rbx), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r13, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1b712
movl -0x34(%rbp), %ecx
movq -0xb0(%rbp), %rsi
movq %r14, %rdx
testq %rsi, %rsi
je 0x19b1e
movq %r14, %rdx
xorl %edi, %edi
cmpl %ecx, 0x20(%rsi)
setb %dil
cmovaeq %rsi, %rdx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x19b07
movq %r14, %rsi
cmpq %r14, %rdx
je 0x19b30
cmpl 0x20(%rdx), %ecx
cmovbq %r14, %rdx
movq %rdx, %rsi
movsd (%rax), %xmm0
movq 0x20(%rbx), %rax
movq 0x8(%rax), %rax
addsd (%rax), %xmm0
movapd %xmm0, -0x50(%rbp)
cmpq %r14, %rsi
je 0x19bdc
movl %ecx, -0x2c(%rbp)
movq %r13, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1b712
movsd (%rax), %xmm0
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, %xmm1
subsd -0x50(%rbp), %xmm1
movapd %xmm1, %xmm0
xorpd 0xcca2(%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 0x1b712
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 0x19bf4
movl %ecx, -0x2c(%rbp)
movq %r13, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1b712
movapd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
movq %r12, %rdi
leaq -0x34(%rbp), %rsi
callq 0x1ce60
movq %rbx, %rdi
callq 0x4410
movq %rax, %rbx
cmpq %r15, %rax
jne 0x19ad7
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1cf88
movq %r12, %rdi
movq %rax, %rsi
callq 0x1d004
cmpq $0x0, -0x68(%rbp)
jne 0x19aa3
leaq -0x30(%rbp), %rsi
movl $0x0, (%rsi)
leaq -0xc0(%rbp), %rdi
callq 0x1b77a
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x1bb50
leaq -0xc0(%rbp), %rdi
callq 0x1baf8
movsd -0x50(%rbp), %xmm0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19c99
jmp 0x19c99
jmp 0x19c99
movq %rax, %rbx
jmp 0x19ca8
jmp 0x19c99
jmp 0x19c99
jmp 0x19c99
jmp 0x19c99
jmp 0x19c99
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x1bb50
leaq -0xc0(%rbp), %rdi
callq 0x1baf8
movq %rbx, %rdi
callq 0x4650