// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rcx, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rsi, %r15
movq %rdi, %r14
addq $0x40, %rdi
leaq -0x98(%rbp), %rsi
andw $0x0, (%rsi)
movb $0x0, 0x2(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movq %rdi, -0x48(%rbp)
callq 0xeddc
leaq -0x98(%rbp), %rdi
callq 0xe6fe
leaq -0x60(%rbp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movzbl 0x70(%r14), %edx
movq %r15, %rdi
callq 0xd689
xorl %edx, %edx
movl %edx, %edx
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
decq %rcx
cmpq %rdx, %rcx
jbe 0xdb1f
movq %rdx, -0x40(%rbp)
movl (%rax,%rdx,4), %r13d
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x38, %r13, %rcx
cmpq $0x0, 0x18(%rax,%rcx)
je 0xdb14
movq -0x38(%rbp), %r14
movl %r13d, %r12d
movl %r12d, %r12d
cmpq %r12, 0x8(%r15)
jbe 0xdb14
movq (%r15), %rax
movsbl (%rax,%r12), %esi
movq -0x38(%rbp), %rdi
movq %r14, %rdx
callq 0xbb42
testq %rax, %rax
je 0xdb14
movq 0x28(%rax), %r14
cmpq $0x0, 0x10(%rax)
je 0xdb0c
incl %r12d
movl %r12d, %eax
subl %r13d, %eax
movw %r13w, -0x98(%rbp)
movb %al, -0x96(%rbp)
leaq -0x90(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x98(%rbp), %rbx
movq %rbx, %rsi
callq 0xeddc
movq %rbx, %rdi
callq 0xe6fe
movl %r12d, %eax
imulq $0x38, %rax, %rdi
movq -0x30(%rbp), %rax
addq (%rax), %rdi
movw %r13w, -0x98(%rbp)
movq %rbx, %rsi
callq 0xf180
jmp 0xda71
incl %r12d
jmp 0xda71
movq -0x40(%rbp), %rdx
incl %edx
jmp 0xda2e
leaq -0x60(%rbp), %rdi
callq 0xed7a
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdb5d
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0xe6fe
jmp 0xdb69
jmp 0xdb5d
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0xe6fe
jmp 0xdb60
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xed7a
movq %rbx, %rdi
callq 0x45f0
nop