// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/FactorGraph.cc
// Function: FactorGraph::prune_and_create_arcs(std::vector<std::unordered_set<unsigned short, std::hash<unsigned short>, std::equal_to<unsigned short>, std::allocator<unsigned short>>, std::allocator<std::unordered_set<unsigned short, std::hash<unsigned short>, std::equal_to<unsigned short>, std::allocator<unsigned short>>>>&)
void
FactorGraph::prune_and_create_arcs(vector<unordered_set<fg_node_idx_t> > &incoming)
{
    // Find all possible node start positions
    unordered_set<int> possible_node_starts;
    possible_node_starts.insert(text.size());
    for (int i=incoming.size()-1; i>= 0; i--) {
        if (possible_node_starts.find(i) == possible_node_starts.end()) continue;
        for (auto it = incoming[i].cbegin(); it != incoming[i].cend(); ++it)
            possible_node_starts.insert(*it);
    }

    // Prune non-reachable nodes
    for (auto it = nodes.begin(); it != nodes.end(); ) {
        if (possible_node_starts.find(it->start_pos) == possible_node_starts.end() ||
            possible_node_starts.find(it->start_pos+it->len) == possible_node_starts.end())
            it = nodes.erase(it);
        else
            ++it;
    }

    // Add end node
    nodes.push_back(Node(text.size(),0));

    // Collect nodes by start position
    vector<vector<unsigned int> > nodes_by_start_pos(text.size()+1);
    for (unsigned int i=1; i<nodes.size(); i++)
        nodes_by_start_pos[nodes[i].start_pos].push_back(i);

    // Set arcs
    for (unsigned int i=0; i<nodes.size()-1; i++) {
        unsigned int end_pos = nodes[i].start_pos + nodes[i].len;
        for (unsigned int j=0; j<nodes_by_start_pos[end_pos].size(); j++) {
            unsigned int nodei = nodes_by_start_pos[end_pos][j];
            Arc *arc = new Arc(i, nodei, 0.0);
            arcs.push_back(arc);
            nodes[i].outgoing.push_back(arc);
            nodes[nodei].incoming.push_back(arc);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
leaq -0x90(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq %rdi, -0x40(%rbp)
movl 0x8(%rdi), %eax
leaq -0x30(%rbp), %rsi
movl %eax, (%rsi)
leaq -0xc0(%rbp), %r15
leaq -0x88(%rbp), %rdx
movq %r15, (%rdx)
movq %r15, %rdi
callq 0x10cc0
movq 0x8(%rbx), %rax
movq %rbx, -0x38(%rbp)
subq (%rbx), %rax
shrq $0x3, %rax
imull $0xb6db6db7, %eax, %eax # imm = 0xB6DB6DB7
decl %eax
js 0xeeff
movl %eax, %r12d
leaq -0x30(%rbp), %r13
leaq -0x88(%rbp), %r14
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq %r12, %rax
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0xeeee
movq %rdx, %rcx
movq (%rax), %r8
movl 0x8(%r8), %eax
cmpq %rax, %r12
je 0xeeb8
movq (%r8), %r8
testq %r8, %r8
je 0xeeee
movslq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
cmpq %rcx, %rdx
jne 0xeeee
movl %esi, %eax
jmp 0xee96
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x38, %r12, %rcx
movq 0x10(%rax,%rcx), %rbx
testq %rbx, %rbx
je 0xeeee
movzwl 0x8(%rbx), %eax
movl %eax, -0x30(%rbp)
movq %r15, -0x88(%rbp)
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x10cc0
movq (%rbx), %rbx
jmp 0xeec8
leaq -0x1(%r12), %rax
testq %r12, %r12
movq %rax, %r12
jg 0xee6d
movq -0x40(%rbp), %r14
leaq 0x40(%r14), %rax
movq %rax, -0x38(%rbp)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %r9
cmpq %r9, %rsi
je 0xefc6
movzwl (%rsi), %ecx
movq -0xc0(%rbp), %r11
movq -0xb8(%rbp), %r10
movq %rcx, %rax
xorl %edx, %edx
divq %r10
movq %rdx, %rdi
movl %edi, %eax
movq (%r11,%rax,8), %rax
testq %rax, %rax
je 0xefb5
movq (%rax), %rbx
cmpl %ecx, 0x8(%rbx)
je 0xef69
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xefb5
movslq 0x8(%rbx), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r10
cmpq %rdi, %rdx
jne 0xefb5
cmpl %ecx, %r8d
jne 0xef4b
movzbl 0x2(%rsi), %edi
addl %ecx, %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r10
movq %rdx, %rcx
movl %ecx, %eax
movq (%r11,%rax,8), %rax
testq %rax, %rax
je 0xefb5
movq (%rax), %r11
cmpl 0x8(%r11), %edi
je 0xefac
movq (%r11), %r11
testq %r11, %r11
je 0xefb5
movslq 0x8(%r11), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r10
cmpq %rcx, %rdx
jne 0xefb5
cmpl %r8d, %edi
jne 0xef8e
addq $0x38, %rsi
jmp 0xef13
movq -0x38(%rbp), %rdi
callq 0x10f5a
movq %rax, %rsi
jmp 0xef0f
movzwl 0x8(%r14), %eax
leaq -0x88(%rbp), %rsi
movw %ax, (%rsi)
movb $0x0, 0x2(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movq -0x38(%rbp), %rdi
callq 0x10560
leaq -0x88(%rbp), %rdi
callq 0xfea4
movq 0x8(%r14), %rsi
incq %rsi
leaq -0x88(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0xfeee
movl $0x1, -0x30(%rbp)
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rax
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %rsi
sarq $0x3, %rsi
movabsq $0x6db6db6db6db6db7, %rbx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rbx, %rsi
cmpq $0x2, %rsi
jb 0xf0b5
movl $0x1, %r8d
movl $0x1, %esi
leaq -0x30(%rbp), %r15
imulq $0x38, %rsi, %rdx
movzwl (%rcx,%rdx), %ecx
movq -0x88(%rbp), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xf081
movl %r8d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xf08d
movq %r15, %rdx
callq 0x1048c
movq 0x48(%r14), %rax
movl -0x30(%rbp), %esi
incl %esi
movl %esi, -0x30(%rbp)
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %rdi
sarq $0x3, %rdi
imulq %rbx, %rdi
movl %esi, %r8d
cmpq %rsi, %rdi
ja 0xf053
cmpq $0x38, %rdx
je 0xf211
leaq 0x58(%r14), %rdx
movq %rdx, -0x48(%rbp)
xorl %r12d, %r12d
movq -0x88(%rbp), %rdx
imulq $0x38, %r12, %r15
movzwl (%rcx,%r15), %esi
movzbl 0x2(%rcx,%r15), %edi
leaq (%rsi,%rsi,2), %rsi
movq %rsi, -0x50(%rbp)
leaq (%rdx,%rsi,8), %r8
leaq (%rdi,%rdi,2), %r14
movq (%r8,%r14,8), %rsi
cmpq %rsi, 0x8(%r8,%r14,8)
je 0xf1f4
movl $0x1, %ebx
xorl %eax, %eax
movl (%rsi,%rax,4), %r13d
movl $0x10, %edi
callq 0x4390
movw %r12w, (%rax)
movw %r13w, 0x2(%rax)
movq $0x0, 0x8(%rax)
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rcx
movq 0x60(%rcx), %rsi
cmpq 0x68(%rcx), %rsi
je 0xf141
movq %rax, (%rsi)
addq $0x8, 0x60(%rcx)
jmp 0xf14e
movq -0x48(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x11120
movq -0x38(%rbp), %rax
movq (%rax), %rax
leaq (%rax,%r15), %rdi
addq $0x20, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xf175
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0xf17e
leaq -0x30(%rbp), %rdx
callq 0x11120
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x38, %r13, %rcx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xf1a9
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0xf1b2
leaq -0x30(%rbp), %rdx
callq 0x11120
movl %ebx, %eax
movq -0x88(%rbp), %rdx
movq -0x50(%rbp), %rcx
leaq (%rdx,%rcx,8), %rcx
movq (%rcx,%r14,8), %rsi
movq 0x8(%rcx,%r14,8), %rcx
subq %rsi, %rcx
sarq $0x2, %rcx
incl %ebx
cmpq %rax, %rcx
ja 0xf106
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rcx
movq 0x48(%rax), %rax
movabsq $0x6db6db6db6db6db7, %rbx # imm = 0x6DB6DB6DB6DB6DB7
incl %r12d
movq %rax, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
decq %rsi
cmpq %r12, %rsi
ja 0xf0d1
leaq -0x88(%rbp), %rdi
callq 0xff6c
leaq -0xc0(%rbp), %rdi
callq 0x10416
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf254
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0xfea4
jmp 0xf268
jmp 0xf254
jmp 0xf259
jmp 0xf254
movq %rax, %rbx
jmp 0xf268
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0xff6c
leaq -0xc0(%rbp), %rdi
callq 0x10416
movq %rbx, %rdi
callq 0x4650