// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
leaq -0x2e0(%rbp), %rbx
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x4540
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2c0(%rbp,%rax)
jne 0x114e0
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2e0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x4090
leaq -0x5f0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
pushq $0x18
popq %rdx
callq 0x4520
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(%r14), %rbx
movq %rbx, %rdi
callq 0x11f18
leaq 0x38(%r14), %rdi
movq %rdi, -0x58(%rbp)
callq 0x14bba
leaq 0x68(%r14), %rdi
movq %rdi, -0x50(%rbp)
callq 0x14bf2
movslq -0x38(%rbp), %rsi
movq %rbx, -0x70(%rbp)
movq %rbx, %rdi
callq 0x11f26
leaq -0xc8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %r14, -0x60(%rbp)
leaq 0x98(%r14), %rax
movq %rax, -0x68(%rbp)
xorl %r13d, %r13d
leaq -0x90(%rbp), %r14
leaq -0x468(%rbp), %r15
leaq -0x44(%rbp), %rbx
leaq -0xd8(%rbp), %r12
cmpl -0x38(%rbp), %r13d
jge 0x1135c
leaq -0x2e0(%rbp), %rdi
movq %r14, %rsi
callq 0x4090
movq %r15, %rdi
movq %r14, %rsi
pushq $0x18
popq %rdx
callq 0x4520
movq %r15, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4440
cmpb $0x6e, -0x29(%rbp)
jne 0x114fe
movq %r15, %rdi
movq %rbx, %rsi
callq 0x45e0
movq %rax, %rdi
movq %r12, %rsi
callq 0x43f0
movl -0x44(%rbp), %edi
shlq $0x7, %rdi
movq -0x70(%rbp), %rax
addq (%rax), %rdi
movq %r12, %rsi
callq 0x41c0
movq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x11eae
movq %rax, %rdi
movq %rbx, %rsi
callq 0xe79a
movq %r15, %rdi
callq 0x42b0
incl %r13d
jmp 0x112cc
xorl %r13d, %r13d
leaq -0x90(%rbp), %r14
leaq -0x468(%rbp), %r15
leaq -0x40(%rbp), %rbx
leaq -0x3c(%rbp), %r12
movl -0x34(%rbp), %eax
cmpl %eax, %r13d
jge 0x113e2
leaq -0x2e0(%rbp), %rdi
movq %r14, %rsi
callq 0x4090
movq %r15, %rdi
movq %r14, %rsi
pushq $0x18
popq %rdx
callq 0x4520
movq %r15, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4440
cmpb $0x61, -0x29(%rbp)
jne 0x1151b
movq %r15, %rdi
movq %rbx, %rsi
callq 0x45e0
movq %rax, %rdi
movq %r12, %rsi
callq 0x45e0
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x60(%rbp), %rdi
callq 0x108d2
movq %r15, %rdi
callq 0x42b0
incl %r13d
jmp 0x11375
leaq -0xa8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
xorl %r14d, %r14d
leaq -0x90(%rbp), %r12
leaq -0x468(%rbp), %r13
leaq -0xb8(%rbp), %r15
cmpl %eax, %r14d
jge 0x114a4
leaq -0x2e0(%rbp), %rdi
movq %r12, %rsi
callq 0x4090
movq %r13, %rdi
movq %r12, %rbx
movq %r12, %rsi
pushq $0x18
popq %rdx
callq 0x4520
movq %r13, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4440
cmpb $0x65, -0x29(%rbp)
jne 0x11538
movq %r13, %rdi
movq %r15, %rsi
callq 0x43f0
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x45e0
movl -0x30(%rbp), %r12d
movq -0x58(%rbp), %rdi
movq %r15, %rsi
callq 0x11c7e
movl %r12d, (%rax)
movq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x11d3c
movq %rax, %rdi
movq %r15, %rsi
callq 0x41c0
movq %r13, %rdi
callq 0x42b0
incl %r14d
movl -0x34(%rbp), %eax
movq %rbx, %r12
jmp 0x1140d
leaq -0x2e0(%rbp), %rdi
callq 0x40a0
leaq -0xb8(%rbp), %rdi
callq 0x46b8
leaq -0xd8(%rbp), %rdi
callq 0x46b8
leaq -0x5f0(%rbp), %rdi
callq 0x42b0
leaq -0x90(%rbp), %rdi
callq 0x46b8
leaq -0x2e0(%rbp), %rdi
callq 0x40d0
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x23ae3(%rip), %rdi     # 0x34fe8
leaq 0x12236(%rip), %rsi     # 0x23742
callq 0x4340
movq %rax, %rdi
callq 0x4180
jmp 0x11553
movq 0x23ac6(%rip), %rdi     # 0x34fe8
leaq 0x12219(%rip), %rsi     # 0x23742
callq 0x4340
movq %rax, %rdi
callq 0x4180
jmp 0x11553
movq 0x23aa9(%rip), %rdi     # 0x34fe8
leaq 0x121fc(%rip), %rsi     # 0x23742
callq 0x4340
movq %rax, %rdi
callq 0x4180
pushq $0x1
popq %rdi
callq 0x43c0
jmp 0x11571
jmp 0x1155f
movq %rax, %rbx
jmp 0x115c7
movq %rax, %rbx
jmp 0x115bb
jmp 0x11583
jmp 0x115a0
jmp 0x115a0
jmp 0x11571
movq %rax, %rbx
jmp 0x11592
jmp 0x1157c
jmp 0x1157c
jmp 0x1157c
movq %rax, %rbx
jmp 0x115af
jmp 0x115a0
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
callq 0x42b0
leaq -0xb8(%rbp), %rdi
callq 0x46b8
jmp 0x115af
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
callq 0x42b0
leaq -0xd8(%rbp), %rdi
callq 0x46b8
leaq -0x5f0(%rbp), %rdi
callq 0x42b0
leaq -0x90(%rbp), %rdi
callq 0x46b8
leaq -0x2e0(%rbp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45f0
nop