// File: /workspace/github_cpp_makefile_star2_O1/aalto-speech[P]ftk/src/FactorGraph.cc
// Function: FactorGraph::create_nodes(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, StringSet const&, 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::create_nodes(const string &text,
                          const StringSet &vocab,
                          vector<unordered_set<fg_node_idx_t> > &incoming)
{
    nodes.push_back(Node(0,0));

    vector<unsigned int> char_positions;
    get_character_positions(text, char_positions, utf8);

    for (unsigned int i=0; i<char_positions.size()-1; i++) {

        unsigned int start_pos = char_positions[i];
        if (incoming[start_pos].size() == 0) continue;

        const StringSet::Node *node = &vocab.root_node;
        for (unsigned int j=start_pos; j<text.length(); j++) {

            StringSet::Arc *arc = vocab.find_arc(text[j], node);

            if (arc == NULL) break;
            node = arc->target_node;

            // String associated with this node
            if (arc->factor.length() > 0) {
                nodes.push_back(Node(start_pos, j+1-start_pos));
                incoming[j+1].insert(start_pos);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, -0x40(%rbp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
addq $0x40, %rdi
leaq -0xb8(%rbp), %rsi
movw $0x0, (%rsi)
movb $0x0, 0x2(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movq %rdi, -0x80(%rbp)
callq 0x10650
leaq -0xb8(%rbp), %rdi
callq 0xff90
leaq -0x60(%rbp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movzbl 0x70(%rbx), %edx
movq %r15, %rdi
callq 0xe8f2
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rax
subq %rdi, %rax
cmpq $0x4, %rax
je 0xee8b
xorl %ecx, %ecx
leaq -0xb8(%rbp), %r13
movq %r15, -0x78(%rbp)
movq %r14, -0x70(%rbp)
movq %rcx, -0x68(%rbp)
movl (%rdi,%rcx,4), %ecx
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rcx, -0x38(%rbp)
imulq $0x38, %rcx, %rcx
cmpq $0x0, 0x18(%rax,%rcx)
je 0xee6a
movq -0x38(%rbp), %rax
cmpq %rax, 0x8(%r15)
jbe 0xee6a
movl $0x1, %r12d
movq -0x38(%rbp), %rax
movq %r14, -0x48(%rbp)
movq (%r15), %rcx
movsbl (%rcx,%rax), %esi
movq %r14, %rdi
movq -0x48(%rbp), %rdx
callq 0xcdf2
movq %rax, %rbx
testq %rax, %rax
je 0xee51
movq 0x28(%rbx), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, 0x10(%rbx)
je 0xee51
movq %r13, %r14
movq -0x38(%rbp), %r13
movw %r13w, -0xb8(%rbp)
movb %r12b, -0xb6(%rbp)
leaq -0xb0(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x10650
leal (%r12,%r13), %r15d
movq %r14, %rdi
callq 0xff90
movl %r15d, %eax
imulq $0x38, %rax, %rdi
movq -0x40(%rbp), %rax
addq (%rax), %rdi
movw %r13w, -0x2a(%rbp)
movq %rdi, -0xb8(%rbp)
leaq -0x2a(%rbp), %rsi
movq %r14, %r13
movq %r14, %rdx
callq 0x10a40
movq -0x70(%rbp), %r14
movq -0x78(%rbp), %r15
testq %rbx, %rbx
je 0xee6a
movq -0x38(%rbp), %rax
addl %r12d, %eax
incl %r12d
cmpq %rax, 0x8(%r15)
ja 0xedaf
movq -0x68(%rbp), %rcx
incl %ecx
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rax
subq %rdi, %rax
sarq $0x2, %rax
decq %rax
cmpq %rcx, %rax
ja 0xed71
testq %rdi, %rdi
je 0xee95
callq 0x4350
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xeecd
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0xff90
jmp 0xeede
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0xff90
jmp 0xeed0
jmp 0xeecd
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0xeede
callq 0x4350
movq %rbx, %rdi
callq 0x4650