// File: aalto-speech[P]ftk/src/FactorGraph.cc
// Function: FactorGraph::create_nodes(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>>> const&, unsigned int, 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 map<string, flt_type> &vocab,
                          unsigned int maxlen,
                          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;

        for (unsigned int j=i; j<char_positions.size()-1 && (j-i < maxlen); j++) {
            unsigned int end_pos = text.size();
            if (j < (char_positions.size()-1)) end_pos = char_positions[j+1];
            if (vocab.find(text.substr(start_pos, end_pos-start_pos)) != vocab.end()) {
                nodes.push_back(Node(start_pos, end_pos-start_pos));
                incoming[end_pos].insert(start_pos);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x40, %rax
movq %rax, -0x128(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x120(%rbp)
xorl %edx, %edx
movl %edx, %esi
callq 0x233d0
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x233a0
jmp 0x20dad
leaq -0x60(%rbp), %rdi
callq 0x23420
leaq -0x88(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x23470
movq -0x130(%rbp), %rax
movq -0x138(%rbp), %rsi
movq -0x10(%rbp), %rdi
movzbl 0x70(%rax), %edx
andl $0x1, %edx
callq 0x21130
jmp 0x20de9
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq %rax, -0x140(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x23490
movq %rax, %rcx
movq -0x140(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x210f8
movl -0x8c(%rbp), %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x234b0
movl (%rax), %eax
movl %eax, -0x90(%rbp)
movq -0x28(%rbp), %rdi
movl -0x90(%rbp), %eax
movl %eax, %esi
callq 0x234d0
movq %rax, %rdi
callq 0x234f0
cmpq $0x0, %rax
jne 0x20e8e
jmp 0x210e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x23420
jmp 0x21119
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2110d
movl -0x8c(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movq %rax, -0x150(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x23490
movq -0x150(%rbp), %rcx
movq %rax, %rdx
subq $0x1, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x141(%rbp)
jae 0x20ee6
movl -0x94(%rbp), %eax
subl -0x8c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
setb %al
movb %al, -0x141(%rbp)
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x20ef5
jmp 0x210e2
movq -0x10(%rbp), %rdi
callq 0x42d0
movl %eax, -0x98(%rbp)
movl -0x94(%rbp), %eax
movq %rax, -0x158(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x23490
movq %rax, %rcx
movq -0x158(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x20f51
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x234b0
movl (%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rsi
movl -0x90(%rbp), %eax
movl %eax, %edx
movl %edx, %ecx
movl -0x98(%rbp), %eax
subl %ecx, %eax
movl %eax, %ecx
leaq -0xc0(%rbp), %rdi
callq 0x43e0
jmp 0x20f82
movq -0x160(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1b5a0
movq %rax, -0x168(%rbp)
jmp 0x20f9e
movq -0x168(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1b480
movq %rax, -0xc8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x1b290
movb %al, -0x169(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4828
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x20ff0
jmp 0x210cc
movq -0x130(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x178(%rbp)
movl -0x90(%rbp), %esi
movl -0x98(%rbp), %edx
subl %esi, %edx
leaq -0x100(%rbp), %rdi
callq 0x233d0
jmp 0x2101e
movq -0x178(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x233a0
jmp 0x21033
leaq -0x100(%rbp), %rdi
callq 0x23420
movq -0x28(%rbp), %rdi
movl -0x98(%rbp), %eax
movl %eax, %esi
callq 0x234d0
movq %rax, %rdi
movw -0x90(%rbp), %ax
movw %ax, -0x102(%rbp)
leaq -0x102(%rbp), %rsi
callq 0x23510
movb %dl, -0x181(%rbp)
movq %rax, -0x180(%rbp)
jmp 0x2107c
movb -0x181(%rbp), %al
movq -0x180(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movb %al, -0x110(%rbp)
jmp 0x210cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4828
jmp 0x2110d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x23420
jmp 0x2110d
jmp 0x210ce
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x20e9a
jmp 0x210e4
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x20df3
leaq -0x88(%rbp), %rdi
callq 0x23550
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x88(%rbp), %rdi
callq 0x23550
movq -0x68(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)