// File: 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
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31110
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31180
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x31140
testb $0x1, %al
jne 0x44498
jmp 0x4450c
leaq -0x18(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x30260
movq %rax, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x302c0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x444dd
jmp 0x444fc
leaq -0x28(%rbp), %rdi
callq 0x302f0
movq (%rax), %rax
movq $0x0, 0x8(%rax)
leaq -0x28(%rbp), %rdi
callq 0x30320
jmp 0x444b1
jmp 0x444fe
leaq -0x18(%rbp), %rdi
callq 0x48af0
jmp 0x44474
movq -0x8(%rbp), %rdi
callq 0x48b10
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31360
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x48b40
testb $0x1, %al
jne 0x4453c
jmp 0x446e3
movq -0x10(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x130(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x48c10
movq -0x130(%rbp), %rdi
movq %rax, %rsi
callq 0x48b70
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x24e80
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x24d10
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31040
testb $0x1, %al
jne 0x44599
jmp 0x446d3
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x138(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31080
movq -0x138(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0x30240
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
addq $0x50, %rdi
callq 0x30260
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
addq $0x50, %rdi
callq 0x302c0
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x445fd
jmp 0x446c3
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x140(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x302f0
movq -0x140(%rbp), %rdi
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, %esi
callq 0x30240
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x48c10
movq %rax, %rdi
addq $0x20, %rdi
movq -0x78(%rbp), %rsi
callq 0x48c60
movq %rax, -0x80(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x48c10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x48c90
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x48c30
testb $0x1, %al
jne 0x4467c
jmp 0x446b3
leaq -0x38(%rbp), %rdi
callq 0x48c10
movq %rax, %rdi
addq $0x20, %rdi
movq -0x78(%rbp), %rsi
callq 0x48cc0
movq %rax, -0x148(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x302f0
movq -0x148(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x446b5
leaq -0x68(%rbp), %rdi
callq 0x30320
jmp 0x445d6
jmp 0x446c5
leaq -0x50(%rbp), %rdi
callq 0x310c0
jmp 0x44576
jmp 0x446d5
leaq -0x38(%rbp), %rdi
callq 0x48d60
jmp 0x44519
leaq -0xb8(%rbp), %rdi
callq 0x32900
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31110
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31180
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x31140
testb $0x1, %al
jne 0x44733
jmp 0x44832
leaq -0xc0(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x30260
movq %rax, -0xd0(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x302c0
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x4478d
jmp 0x4481f
leaq -0xd0(%rbp), %rdi
callq 0x302f0
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4480c
leaq -0xd0(%rbp), %rdi
callq 0x302f0
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x30ee0
movb %dl, -0x151(%rbp)
movq %rax, -0x150(%rbp)
jmp 0x447cd
movb -0x151(%rbp), %al
movq -0x150(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movb %al, -0xf0(%rbp)
jmp 0x4480c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x32920
jmp 0x449ab
jmp 0x4480e
leaq -0xd0(%rbp), %rdi
callq 0x30320
jmp 0x44752
jmp 0x44821
leaq -0xc0(%rbp), %rdi
callq 0x48af0
jmp 0x44703
leaq -0xb8(%rbp), %rdi
callq 0x30260
movq %rax, -0x100(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x302c0
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x44871
jmp 0x448a9
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x302f0
movq -0x160(%rbp), %rdi
movq (%rax), %rsi
callq 0x2e130
jmp 0x44899
jmp 0x4489b
leaq -0x100(%rbp), %rdi
callq 0x30320
jmp 0x44845
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x31250
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x312b0
movq %rax, -0x118(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x31280
testb $0x1, %al
jne 0x448f3
jmp 0x44996
movq -0x8(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x31340
movq -0x170(%rbp), %rdi
movq %rax, %rsi
callq 0x31310
movq %rax, -0x168(%rbp)
jmp 0x44922
movq -0x168(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31360
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x312e0
testb $0x1, %al
jne 0x44959
jmp 0x44983
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x31340
movq -0x178(%rbp), %rdi
movq %rax, %rsi
callq 0x2e1c0
jmp 0x44981
jmp 0x44983
jmp 0x44985
leaq -0x110(%rbp), %rdi
callq 0x31390
jmp 0x448c0
leaq -0xb8(%rbp), %rdi
callq 0x32920
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x46e0
nopw (%rax,%rax)