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

    vector<Arc*> arcs; collect_arcs(arcs);

    outfile << nodes.size() << " " << arcs.size() << " " << string_end_nodes.size() << endl;
    for (unsigned int i=0; i<nodes.size(); i++)
        outfile << "n " << i << " " << nodes[i].factor << endl;
    for (auto it = arcs.begin(); it != arcs.end(); ++it)
        outfile << "a " << (**it).source_node << " " << (**it).target_node << endl;
    for (auto it = string_end_nodes.cbegin(); it != string_end_nodes.cend(); ++it)
        outfile << "e " << it->first << " " << it->second << endl;
    outfile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x210(%rbp), %rdi
movl $0x10, %edx
callq 0x47b0
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x210(%rbp,%rax), %rdi
callq 0x41d0
movb %al, -0x261(%rbp)
jmp 0x2e713
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0x2e71f
jmp 0x2e745
movl $0x1, -0x220(%rbp)
jmp 0x2eb3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x2eb53
leaq -0x238(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x2fb80
movq -0x270(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x2ce00
jmp 0x2e76d
movq -0x270(%rbp), %rdi
addq $0x20, %rdi
callq 0x30500
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x40f0
movq %rax, -0x280(%rbp)
jmp 0x2e795
movq -0x280(%rbp), %rdi
leaq 0x37bc5(%rip), %rsi     # 0x66368
callq 0x43c0
movq %rax, -0x288(%rbp)
jmp 0x2e7b1
leaq -0x238(%rbp), %rdi
callq 0x313c0
movq -0x288(%rbp), %rdi
movq %rax, %rsi
callq 0x40f0
movq %rax, -0x290(%rbp)
jmp 0x2e7d5
movq -0x290(%rbp), %rdi
leaq 0x37b85(%rip), %rsi     # 0x66368
callq 0x43c0
movq %rax, -0x298(%rbp)
jmp 0x2e7f1
movq -0x270(%rbp), %rdi
addq $0x38, %rdi
callq 0x313e0
movq -0x298(%rbp), %rdi
movq %rax, %rsi
callq 0x40f0
movq %rax, -0x2a0(%rbp)
jmp 0x2e819
movq -0x2a0(%rbp), %rdi
movq 0x65771(%rip), %rsi     # 0x93f98
callq 0x4400
jmp 0x2e82e
movl $0x0, -0x23c(%rbp)
movq -0x270(%rbp), %rdi
movl -0x23c(%rbp), %eax
movq %rax, -0x2a8(%rbp)
addq $0x20, %rdi
callq 0x30500
movq %rax, %rcx
movq -0x2a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2e939
leaq 0x37eae(%rip), %rsi     # 0x6671d
leaq -0x210(%rbp), %rdi
callq 0x43c0
movq %rax, -0x2b0(%rbp)
jmp 0x2e884
movq -0x2b0(%rbp), %rdi
movl -0x23c(%rbp), %esi
callq 0x4540
movq %rax, -0x2b8(%rbp)
jmp 0x2e89f
movq -0x2b8(%rbp), %rdi
leaq 0x37abb(%rip), %rsi     # 0x66368
callq 0x43c0
movq %rax, -0x2c0(%rbp)
jmp 0x2e8bb
movq -0x270(%rbp), %rdi
addq $0x20, %rdi
movl -0x23c(%rbp), %eax
movl %eax, %esi
callq 0x30c00
movq -0x2c0(%rbp), %rdi
movq %rax, %rsi
callq 0x4380
movq %rax, -0x2c8(%rbp)
jmp 0x2e8eb
movq -0x2c8(%rbp), %rdi
movq 0x6569f(%rip), %rsi     # 0x93f98
callq 0x4400
jmp 0x2e900
jmp 0x2e902
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x2e838
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2fc80
jmp 0x2eb53
leaq -0x238(%rbp), %rdi
callq 0x2fba0
movq %rax, -0x248(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x2fc10
movq %rax, -0x250(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x2fbd0
testb $0x1, %al
jne 0x2e97b
jmp 0x2ea28
leaq 0x37d9e(%rip), %rsi     # 0x66720
leaq -0x210(%rbp), %rdi
callq 0x43c0
movq %rax, -0x2d0(%rbp)
jmp 0x2e997
leaq -0x248(%rbp), %rdi
callq 0x2fc40
movq -0x2d0(%rbp), %rdi
movq (%rax), %rax
movl (%rax), %esi
callq 0x4540
movq %rax, -0x2d8(%rbp)
jmp 0x2e9bd
movq -0x2d8(%rbp), %rdi
leaq 0x3799d(%rip), %rsi     # 0x66368
callq 0x43c0
movq %rax, -0x2e0(%rbp)
jmp 0x2e9d9
leaq -0x248(%rbp), %rdi
callq 0x2fc40
movq -0x2e0(%rbp), %rdi
movq (%rax), %rax
movl 0x4(%rax), %esi
callq 0x4540
movq %rax, -0x2e8(%rbp)
jmp 0x2ea00
movq -0x2e8(%rbp), %rdi
movq 0x6558a(%rip), %rsi     # 0x93f98
callq 0x4400
jmp 0x2ea15
jmp 0x2ea17
leaq -0x248(%rbp), %rdi
callq 0x2fc60
jmp 0x2e94c
movq -0x270(%rbp), %rdi
addq $0x38, %rdi
callq 0x31400
movq %rax, -0x258(%rbp)
movq -0x270(%rbp), %rdi
addq $0x38, %rdi
callq 0x31460
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x31430
testb $0x1, %al
jne 0x2ea72
jmp 0x2eb1a
leaq 0x37caa(%rip), %rsi     # 0x66723
leaq -0x210(%rbp), %rdi
callq 0x43c0
movq %rax, -0x2f0(%rbp)
jmp 0x2ea8e
leaq -0x258(%rbp), %rdi
callq 0x31490
movq -0x2f0(%rbp), %rdi
movq %rax, %rsi
callq 0x4380
movq %rax, -0x2f8(%rbp)
jmp 0x2eab2
movq -0x2f8(%rbp), %rdi
leaq 0x378a8(%rip), %rsi     # 0x66368
callq 0x43c0
movq %rax, -0x300(%rbp)
jmp 0x2eace
leaq -0x258(%rbp), %rdi
callq 0x31490
movq -0x300(%rbp), %rdi
movl 0x20(%rax), %esi
callq 0x4540
movq %rax, -0x308(%rbp)
jmp 0x2eaf2
movq -0x308(%rbp), %rdi
movq 0x65498(%rip), %rsi     # 0x93f98
callq 0x4400
jmp 0x2eb07
jmp 0x2eb09
leaq -0x258(%rbp), %rdi
callq 0x314b0
jmp 0x2ea3f
leaq -0x210(%rbp), %rdi
callq 0x4570
jmp 0x2eb28
leaq -0x238(%rbp), %rdi
callq 0x2fc80
movl $0x0, -0x220(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x45c0
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x45c0
movq -0x218(%rbp), %rdi
callq 0x46e0
nopl (%rax,%rax)