// 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>>, 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(map<string, flt_type> &vocab,
              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 = msfg.factor_node_map.begin(); it != msfg.factor_node_map.end(); ++it) {
        flt_type *curr_score = &(vocab.at(it->first));
        for (auto ndit = it->second.begin(); ndit != it->second.end(); ++ndit) {
            MultiStringFactorGraph::Node &node = msfg.nodes[*ndit];
            for (auto arc = node.incoming.begin(); arc != node.incoming.end(); ++arc)
                (**arc).cost = curr_score;
        }
    }

    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 (vocab.find(fnit->first) == vocab.end())
            msfg.remove_arcs(fnit->first);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
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 0x44a08
jmp 0x44a7c
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 0x44a4d
jmp 0x44a6c
leaq -0x28(%rbp), %rdi
callq 0x302f0
movq (%rax), %rax
movq $0x0, 0x8(%rax)
leaq -0x28(%rbp), %rdi
callq 0x30320
jmp 0x44a21
jmp 0x44a6e
leaq -0x18(%rbp), %rdi
callq 0x48af0
jmp 0x449e4
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x31250
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x312b0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x31280
testb $0x1, %al
jne 0x44aba
jmp 0x44bd7
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31340
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x48cc0
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31340
movq %rax, %rdi
addq $0x20, %rdi
callq 0x24e80
movq %rax, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31340
movq %rax, %rdi
addq $0x20, %rdi
callq 0x24d10
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x31040
testb $0x1, %al
jne 0x44b29
jmp 0x44bc7
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x120(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31080
movq -0x120(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0x30240
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
addq $0x20, %rdi
callq 0x30260
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
addq $0x20, %rdi
callq 0x302c0
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x44b8a
jmp 0x44bb7
movq -0x48(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x302f0
movq -0x128(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x8(%rax)
leaq -0x68(%rbp), %rdi
callq 0x30320
jmp 0x44b66
jmp 0x44bb9
leaq -0x50(%rbp), %rdi
callq 0x310c0
jmp 0x44afa
jmp 0x44bc9
leaq -0x38(%rbp), %rdi
callq 0x31390
jmp 0x44a90
leaq -0xa0(%rbp), %rdi
callq 0x32900
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31110
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x31180
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x31140
testb $0x1, %al
jne 0x44c27
jmp 0x44d26
leaq -0xa8(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x30260
movq %rax, -0xb8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x311b0
movq %rax, %rdi
addq $0x50, %rdi
callq 0x302c0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x44c81
jmp 0x44d13
leaq -0xb8(%rbp), %rdi
callq 0x302f0
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x44d00
leaq -0xb8(%rbp), %rdi
callq 0x302f0
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x30ee0
movb %dl, -0x131(%rbp)
movq %rax, -0x130(%rbp)
jmp 0x44cc1
movb -0x131(%rbp), %al
movq -0x130(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movb %al, -0xd8(%rbp)
jmp 0x44d00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x32920
jmp 0x44e9f
jmp 0x44d02
leaq -0xb8(%rbp), %rdi
callq 0x30320
jmp 0x44c46
jmp 0x44d15
leaq -0xa8(%rbp), %rdi
callq 0x48af0
jmp 0x44bf7
leaq -0xa0(%rbp), %rdi
callq 0x30260
movq %rax, -0xe8(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x302c0
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x30290
testb $0x1, %al
jne 0x44d65
jmp 0x44d9d
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x302f0
movq -0x140(%rbp), %rdi
movq (%rax), %rsi
callq 0x2e130
jmp 0x44d8d
jmp 0x44d8f
leaq -0xe8(%rbp), %rdi
callq 0x30320
jmp 0x44d39
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x31250
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x98, %rdi
callq 0x312b0
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x31280
testb $0x1, %al
jne 0x44de7
jmp 0x44e8a
movq -0x8(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31340
movq -0x150(%rbp), %rdi
movq %rax, %rsi
callq 0x48c60
movq %rax, -0x148(%rbp)
jmp 0x44e16
movq -0x148(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rdi
callq 0x48c90
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x48d90
testb $0x1, %al
jne 0x44e4d
jmp 0x44e77
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31340
movq -0x158(%rbp), %rdi
movq %rax, %rsi
callq 0x2e1c0
jmp 0x44e75
jmp 0x44e77
jmp 0x44e79
leaq -0xf8(%rbp), %rdi
callq 0x31390
jmp 0x44db4
leaq -0xa0(%rbp), %rdi
callq 0x32920
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0xc8(%rbp), %rdi
callq 0x46e0
nopl (%rax,%rax)