// File: /workspace/github_cpp_makefile_star2_O1/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), %rcx
testb $0x5, -0x448(%rbp,%rcx)
jne 0x12d5f
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
leaq -0x468(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4680
leaq -0x5f0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x18, %edx
callq 0x4580
leaq -0x5f0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4220
leaq -0x30(%rbp), %rsi
movq %rax, %rdi
callq 0x4220
leaq -0x94(%rbp), %rsi
movq %rax, %rdi
callq 0x4220
leaq 0x20(%r13), %rax
movq %rax, -0x78(%rbp)
movq 0x20(%r13), %rbx
movq 0x28(%r13), %r15
cmpq %rbx, %r15
je 0x129f6
movq %rbx, %r14
movq %r14, %rdi
callq 0x137a8
subq $-0x80, %r14
cmpq %r15, %r14
jne 0x129e1
movq %rbx, 0x28(%r13)
leaq 0x38(%r13), %rdi
movq %rdi, -0x90(%rbp)
callq 0x161fc
leaq 0x68(%r13), %rdi
movq %rdi, -0x88(%rbp)
callq 0x16234
movslq -0x38(%rbp), %rsi
movq -0x78(%rbp), %rdi
callq 0x13bb0
movq %r13, -0x70(%rbp)
leaq -0xc8(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $0x0, -0x38(%rbp)
jle 0x12b40
movq -0x70(%rbp), %rax
addq $0x98, %rax
movq %rax, -0x80(%rbp)
xorl %ebx, %ebx
leaq -0x68(%rbp), %r15
leaq -0x260(%rbp), %r12
leaq -0xd8(%rbp), %r13
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x468(%rbp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x4680
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x4580
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4490
cmpb $0x6e, -0x29(%rbp)
jne 0x12d7d
movq %r12, %rdi
leaq -0x34(%rbp), %rsi
callq 0x4640
movq %rax, %rdi
movq %r13, %rsi
callq 0x4450
movl -0x34(%rbp), %edi
shlq $0x7, %rdi
movq -0x78(%rbp), %rax
addq (%rax), %rdi
movq %r13, %rsi
callq 0x41c0
movq -0x80(%rbp), %rdi
movq %r13, %rsi
callq 0x13b30
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x12b0e
movl -0x34(%rbp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x12b1a
movq %rax, %rdi
leaq -0x34(%rbp), %rdx
callq 0x1057c
movq %r12, %rdi
movq 0x2146c(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
cmpl -0x38(%rbp), %ebx
jl 0x12a69
cmpl $0x0, -0x30(%rbp)
jle 0x12bfd
xorl %ebx, %ebx
leaq -0x68(%rbp), %r15
leaq -0x260(%rbp), %r12
movq 0x21432(%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 -0x70(%rbp), %r13
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x4490
cmpb $0x61, -0x29(%rbp)
jne 0x12da3
movq %r12, %rdi
leaq -0x44(%rbp), %rsi
callq 0x4640
movq %rax, %rdi
leaq -0x40(%rbp), %rsi
callq 0x4640
movl -0x44(%rbp), %esi
movl -0x40(%rbp), %edx
movq %r13, %rdi
callq 0x11dfc
movq %r12, %rdi
movq %r14, %rsi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
cmpl -0x30(%rbp), %ebx
jl 0x12b5e
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $0x0, -0x30(%rbp)
jle 0x12cf2
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 -0x68(%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 0x12dc9
movq %r12, %rdi
movq %r14, %rsi
callq 0x4450
movq %rax, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x4640
movl -0x3c(%rbp), %r15d
movq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x13868
movl %r15d, (%rax)
movq -0x88(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x13954
movq %rax, %rdi
movq %r14, %rsi
callq 0x41c0
movq %r12, %rdi
movq 0x212ba(%rip), %rsi     # 0x33f90
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
incl %ebx
cmpl -0x30(%rbp), %ebx
jl 0x12c2d
leaq -0x468(%rbp), %rdi
callq 0x40a0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
leaq -0x58(%rbp), %rbx
je 0x12d1a
callq 0x4350
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x12d32
callq 0x4350
movq 0x21257(%rip), %rsi     # 0x33f90
leaq -0x5f0(%rbp), %rdi
callq 0x42c0
leaq -0x570(%rbp), %rdi
callq 0x4110
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0x12d5f
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 0x21264(%rip), %rdi     # 0x33fe8
leaq 0x13a27(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x2124c(%rip), %rdi     # 0x33fe8
callq 0x4180
jmp 0x12ded
movq 0x2123e(%rip), %rdi     # 0x33fe8
leaq 0x13a01(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x21226(%rip), %rdi     # 0x33fe8
callq 0x4180
jmp 0x12ded
movq 0x21218(%rip), %rdi     # 0x33fe8
leaq 0x139db(%rip), %rsi     # 0x267b2
movl $0x1e, %edx
callq 0x4400
movq 0x21200(%rip), %rdi     # 0x33fe8
callq 0x4180
movl $0x1, %edi
callq 0x4420
jmp 0x12e17
jmp 0x12dfb
movq %rax, %rbx
jmp 0x12ebe
movq %rax, %rbx
jmp 0x12e9f
jmp 0x12e49
jmp 0x12e25
jmp 0x12e25
jmp 0x12e17
jmp 0x12e1e
jmp 0x12e1e
movq %rax, %rbx
jmp 0x12e6b
jmp 0x12e1e
movq %rax, %rbx
jmp 0x12e83
jmp 0x12e25
movq %rax, %rbx
movq 0x21161(%rip), %rsi     # 0x33f90
leaq -0x260(%rbp), %rdi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
jmp 0x12e83
movq %rax, %rbx
movq 0x2113d(%rip), %rsi     # 0x33f90
leaq -0x260(%rbp), %rdi
callq 0x42c0
leaq -0x1e0(%rbp), %rdi
callq 0x4110
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x12e83
callq 0x4350
leaq -0x58(%rbp), %r12
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x12e9f
callq 0x4350
movq 0x210ea(%rip), %rsi     # 0x33f90
leaq -0x5f0(%rbp), %rdi
callq 0x42c0
leaq -0x570(%rbp), %rdi
callq 0x4110
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x12ecc
callq 0x4350
leaq -0x468(%rbp), %rdi
callq 0x40c0
movq %rbx, %rdi
callq 0x4650