// File: /workspace/github_cpp_makefile_star2_O3/aalto-speech[P]ftk/src/MSFG.cc
// Function: MultiStringFactorGraph::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void
MultiStringFactorGraph::read(const std::string &filename)
{
    ifstream infile(filename);
    if (!infile) return;

    int node_count, arc_count, end_node_count;
    char type;
    string line;
    getline(infile, line);
    stringstream ss(line);
    ss >> node_count >> arc_count >> end_node_count;

    nodes.clear();
    string_end_nodes.clear();
    reverse_string_end_nodes.clear();
    nodes.resize(node_count);

    msfg_node_idx_t node_idx;
    string factor;
    for (int i=0; i<node_count; i++) {
        getline(infile, line);
        stringstream nodess(line);
        nodess >> type;
        if (type != 'n') {
            cerr << "Some problem reading MSFG file" << endl;
            exit(EXIT_FAILURE);
        }
        nodess >> node_idx >> factor;
        nodes[node_idx].factor.assign(factor);
        factor_node_map[factor].push_back(node_idx);
    }

    msfg_node_idx_t src_node, tgt_node;
    for (int i=0; i<arc_count; i++) {
        getline(infile, line);
        stringstream arcss(line);
        arcss >> type;
        if (type != 'a') {
            cerr << "Some problem reading MSFG file" << endl;
            exit(EXIT_FAILURE);
        }
        arcss >> src_node >> tgt_node;
        create_arc(src_node, tgt_node);
    }

    msfg_node_idx_t end_node_idx;
    string curr_string;
    for (int i=0; i<arc_count; i++) {
        getline(infile, line);
        stringstream endnss(line);
        endnss >> type;
        if (type != 'e') {
            cerr << "Some problem reading MSFG file" << endl;
            exit(EXIT_FAILURE);
        }
        endnss >> curr_string >> end_node_idx;
        string_end_nodes[curr_string] = end_node_idx;
        reverse_string_end_nodes[end_node_idx] = curr_string;
    }

    infile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5c8, %rsp            # imm = 0x5C8
movq %rdi, %r13
leaq -0x468(%rbp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x45a0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x448(%rbp,%rax)
jne 0x12c6d
leaq (%rax,%rbp), %rdi
addq $-0x468, %rdi           # imm = 0xFB98
leaq -0x60(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
leaq -0x468(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4680
leaq -0x5f0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x18, %edx
callq 0x4580
leaq -0x5f0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4220
leaq -0x34(%rbp), %rsi
movq %rax, %rdi
callq 0x4220
leaq -0x94(%rbp), %rsi
movq %rax, %rdi
callq 0x4220
leaq 0x20(%r13), %rax
movq %rax, -0x40(%rbp)
movq 0x20(%r13), %rbx
movq 0x28(%r13), %r15
cmpq %rbx, %r15
je 0x128e6
movq %rbx, %r14
movq %r14, %rdi
callq 0x136c6
subq $-0x80, %r14
cmpq %r15, %r14
jne 0x128d1
movq %rbx, 0x28(%r13)
leaq 0x38(%r13), %rdi
movq %rdi, -0x88(%rbp)
callq 0x160e8
leaq 0x68(%r13), %rdi
movq %rdi, -0x80(%rbp)
callq 0x16120
movslq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdi
callq 0x13ad8
movq %r13, -0x78(%rbp)
leaq -0xc8(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $0x0, -0x38(%rbp)
jle 0x12a33
movq -0x78(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x90(%rbp)
xorl %ebx, %ebx
leaq -0x70(%rbp), %r14
leaq -0x260(%rbp), %r12
leaq -0xd8(%rbp), %r13
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x468(%rbp), %r15
addq %r15, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x4680
movq %r12, %rdi
movq %r14, %rsi
movl $0x18, %edx
callq 0x4580
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4490
cmpb $0x6e, -0x29(%rbp)
jne 0x12c8b
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x4640
movq %rax, %rdi
movq %r13, %rsi
callq 0x4450
movl -0x30(%rbp), %edi
shlq $0x7, %rdi
movq -0x40(%rbp), %rax
addq (%rax), %rdi
movq %r13, %rsi
callq 0x41c0
movq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x13a58
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x12a01
movl -0x30(%rbp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x12a0d
movq %rax, %rdi
leaq -0x30(%rbp), %rdx
callq 0x1048c
movq %r12, %rdi
movq 0x21579(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
cmpl -0x38(%rbp), %ebx
jl 0x12959
cmpl $0x0, -0x34(%rbp)
jle 0x12bf0
xorl %ebx, %ebx
leaq -0x70(%rbp), %r15
leaq -0x260(%rbp), %r12
movq 0x2153f(%rip), %r14     # 0x33f90
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x468(%rbp), %r13
addq %r13, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x4680
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x4580
movq -0x78(%rbp), %r13
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4490
cmpb $0x61, -0x29(%rbp)
jne 0x12cb1
movq %r12, %rdi
leaq -0x4c(%rbp), %rsi
callq 0x4640
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x4640
movl -0x4c(%rbp), %esi
movl -0x48(%rbp), %edx
movq %r13, %rdi
callq 0x11cda
movq %r12, %rdi
movq %r14, %rsi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
movl -0x34(%rbp), %eax
cmpl %eax, %ebx
jl 0x12a51
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
testl %eax, %eax
jle 0x12c07
movq %r14, -0x40(%rbp)
xorl %ebx, %ebx
leaq -0x260(%rbp), %r12
leaq -0xb8(%rbp), %r14
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x468(%rbp), %r15
addq %r15, %rdi
movl $0xa, %esi
callq 0x4370
leaq -0x70(%rbp), %r13
movsbl %al, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x4680
movq %r12, %rdi
movq %r13, %rsi
movl $0x18, %edx
callq 0x4580
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4490
cmpb $0x65, -0x29(%rbp)
jne 0x12cd7
movq %r12, %rdi
movq %r14, %rsi
callq 0x4450
movq %rax, %rdi
leaq -0x44(%rbp), %rsi
callq 0x4640
movl -0x44(%rbp), %r15d
movq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x13786
movl %r15d, (%rax)
movq -0x80(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x13872
movq %rax, %rdi
movq %r14, %rsi
callq 0x41c0
movq %r12, %rdi
movq 0x213c5(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
cmpl -0x34(%rbp), %ebx
jl 0x12b25
leaq -0xa8(%rbp), %r14
jmp 0x12c07
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq -0x468(%rbp), %rdi
leaq -0x60(%rbp), %rbx
callq 0x40a0
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x12c28
callq 0x4350
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x12c40
callq 0x4350
movq 0x21349(%rip), %rsi     # 0x33f90
leaq -0x5f0(%rbp), %rdi
callq 0x42c0
leaq -0x570(%rbp), %rdi
callq 0x4110
movq -0x70(%rbp), %rdi
cmpq %rbx, %rdi
je 0x12c6d
callq 0x4350
leaq -0x468(%rbp), %rdi
callq 0x40c0
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x21356(%rip), %rdi     # 0x33fe8
leaq 0x13b19(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x2133e(%rip), %rdi     # 0x33fe8
callq 0x4180
jmp 0x12cfb
movq 0x21330(%rip), %rdi     # 0x33fe8
leaq 0x13af3(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x21318(%rip), %rdi     # 0x33fe8
callq 0x4180
jmp 0x12cfb
movq 0x2130a(%rip), %rdi     # 0x33fe8
leaq 0x13acd(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x212f2(%rip), %rdi     # 0x33fe8
callq 0x4180
movl $0x1, %edi
callq 0x4420
movq %r14, -0x40(%rbp)
jmp 0x12d29
jmp 0x12d0d
movq %rax, %rbx
jmp 0x12dca
movq %rax, %rbx
jmp 0x12dab
jmp 0x12d35
jmp 0x12d29
jmp 0x12d6d
jmp 0x12d6d
jmp 0x12d30
jmp 0x12d30
movq %rax, %rbx
jmp 0x12d57
jmp 0x12d30
movq %rax, %rbx
jmp 0x12d8f
movq %rax, %rbx
movq 0x21251(%rip), %rsi     # 0x33f90
leaq -0x260(%rbp), %rdi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
movq -0xb8(%rbp), %rdi
cmpq -0x40(%rbp), %rdi
je 0x12d8f
callq 0x4350
jmp 0x12d8f
jmp 0x12d6d
movq %rax, %rbx
movq 0x21219(%rip), %rsi     # 0x33f90
leaq -0x260(%rbp), %rdi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
leaq -0x60(%rbp), %r12
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x12dab
callq 0x4350
movq 0x211de(%rip), %rsi     # 0x33f90
leaq -0x5f0(%rbp), %rdi
callq 0x42c0
leaq -0x570(%rbp), %rdi
callq 0x4110
movq -0x70(%rbp), %rdi
cmpq %r12, %rdi
je 0x12dd8
callq 0x4350
leaq -0x468(%rbp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x4650