// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/src/EM.cc
// Function: assign_scores(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>>>>>>&, MultiStringFactorGraph&)
void
assign_scores(transitions_t &transitions,
              MultiStringFactorGraph &msfg)
{
    for (auto ndit = msfg.nodes.begin(); ndit != msfg.nodes.end(); ++ndit)
        for (auto arc = ndit->outgoing.begin(); arc != ndit->outgoing.end(); ++arc)
            (**arc).cost = nullptr;

    for (auto it = transitions.begin(); it != transitions.end(); ++it) {
        vector<msfg_node_idx_t> &nodes = msfg.factor_node_map.at(it->first);
        for (auto ndit = nodes.begin(); ndit != nodes.end(); ++ndit) {
            MultiStringFactorGraph::Node &node = msfg.nodes[*ndit];
            for (auto arc = node.outgoing.begin(); arc != node.outgoing.end(); ++arc) {
                string &tgt_str = msfg.nodes[(**arc).target_node].factor;
                if (it->second.find(tgt_str) != it->second.end())
                    (**arc).cost = &(it->second.at(tgt_str));
            }
        }
    }

    set<MultiStringFactorGraph::Arc*> to_remove;
    for (auto ndit = msfg.nodes.begin(); ndit != msfg.nodes.end(); ++ndit)
        for (auto arc = ndit->outgoing.begin(); arc != ndit->outgoing.end(); ++arc)
            if ((**arc).cost == nullptr) to_remove.insert(*arc);
    for (auto trit = to_remove.begin(); trit != to_remove.end(); ++trit)
        msfg.remove_arc(*trit);

    for (auto fnit=msfg.factor_node_map.begin(); fnit != msfg.factor_node_map.end(); ++fnit)
        if (transitions.find(fnit->first) == transitions.end())
            msfg.remove_arcs(fnit->first);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r15
movq %rsi, -0x30(%rbp)
movq 0x20(%rsi), %rbx
movq -0x30(%rbp), %rax
cmpq 0x28(%rax), %rbx
je 0x17382
movq 0x68(%rbx), %rax
leaq 0x58(%rbx), %r14
cmpq %r14, %rax
je 0x1737c
movq 0x20(%rax), %rcx
andq $0x0, 0x8(%rcx)
movq %rax, %rdi
callq 0x43b0
jmp 0x17364
subq $-0x80, %rbx
jmp 0x17352
movq 0x18(%r15), %rbx
movq %r15, -0x40(%rbp)
leaq 0x8(%r15), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x48(%rbp)
cmpq -0x38(%rbp), %rbx
je 0x17456
leaq 0x20(%rbx), %rsi
movq -0x48(%rbp), %rdi
callq 0x191f4
movq %rax, -0x58(%rbp)
movq (%rax), %rcx
leaq 0x40(%rbx), %r14
movq %rbx, -0x50(%rbp)
leaq 0x48(%rbx), %r13
movq -0x58(%rbp), %rax
cmpq 0x8(%rax), %rcx
je 0x17445
movq %rcx, -0x60(%rbp)
movl (%rcx), %eax
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
shlq $0x7, %rax
leaq (%rcx,%rax), %rbx
addq $0x58, %rbx
movq 0x10(%rbx), %r15
cmpq %rbx, %r15
je 0x1743b
movq 0x20(%r15), %rax
movl 0x4(%rax), %r12d
shlq $0x7, %r12
movq -0x30(%rbp), %rax
addq 0x20(%rax), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x197ac
cmpq %r13, %rax
je 0x1742e
movq %r14, %rdi
movq %r12, %rsi
callq 0x19244
movq 0x20(%r15), %rcx
movq %rax, 0x8(%rcx)
movq %r15, %rdi
callq 0x43b0
movq %rax, %r15
jmp 0x173f2
movq -0x60(%rbp), %rcx
addq $0x4, %rcx
jmp 0x173ca
movq -0x50(%rbp), %rdi
callq 0x4270
movq %rax, %rbx
jmp 0x173a0
leaq -0x88(%rbp), %r12
andl $0x0, (%r12)
andq $0x0, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
andq $0x0, 0x20(%r12)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r13
leaq -0x90(%rbp), %r14
movq -0x30(%rbp), %rax
cmpq 0x28(%rax), %r13
je 0x174c8
movq 0x68(%r13), %r15
leaq 0x58(%r13), %rbx
cmpq %rbx, %r15
je 0x174c2
movq 0x20(%r15), %rax
cmpq $0x0, 0x8(%rax)
jne 0x174b5
leaq 0x20(%r15), %rsi
movq %r14, %rdi
callq 0x14282
movq %r15, %rdi
callq 0x43b0
movq %rax, %r15
jmp 0x17499
subq $-0x80, %r13
jmp 0x17487
movq -0x78(%rbp), %r14
movq -0x40(%rbp), %r13
cmpq %r12, %r14
je 0x174ef
movq 0x20(%r14), %rsi
movq -0x30(%rbp), %rdi
callq 0x10cd4
movq %r14, %rdi
callq 0x43b0
movq %rax, %r14
jmp 0x174d0
movq -0x30(%rbp), %rax
movq 0xb0(%rax), %r14
leaq 0xa0(%rax), %rbx
cmpq %rbx, %r14
je 0x17534
leaq 0x20(%r14), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x14b00
cmpq -0x38(%rbp), %rax
jne 0x17527
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x10d32
movq %r14, %rdi
callq 0x4270
movq %rax, %r14
jmp 0x17501
leaq -0x90(%rbp), %rdi
callq 0x121d4
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17555
jmp 0x17555
jmp 0x17555
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x121d4
movq %rbx, %rdi
callq 0x45f0