// File: JameyWoo[P]re2graph/algorithms.cpp
// Function: writeDfaData(DFA, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void writeDfaData(DFA dfa, string filename) {
    /**
     * 将dfa数据写入到filename文件中.
     * 按照输入的格式, 相当于将输入反了一遍.
     * 和输入有一些差异的是, 由于我在保存dfa的时候, 将起始状态变成了0, 所以这个输出更正规
     */
    ofstream write;
    write.open(filename, ios::out | ios::trunc);  // ? 是否设置成没有则创建
    write << dfa.chars.size() << endl;
    for (auto c : dfa.chars) {
        write << c << ' ';
    }
    write << endl
          << dfa.state_cnt << endl;
    for (auto c : dfa.states) {
        write << c << ' ';
    }
    write << endl
          << dfa.start_state << '\n'
          << dfa.end_state_cnt << endl;
    for (auto c : dfa.end_states) {
        write << c << ' ';
    }
    write << endl;
    // todo: 添加转换条件的写入
    vector<string> jumps;
    for (auto s : dfa.states) {
        for (auto iter : dfa.jump_map[s]) {
            jumps.push_back(to_string(s) + " " + iter.first + " " + to_string(iter.second) + "\n");
        }
    }
    write << jumps.size() << endl;
    for (auto s : jumps) {
        write << s;
    }
    // cout << "DFA write over!" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x408(%rbp)
movq %rsi, -0x400(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x34b0
movl $0x10, %edi
movl $0x20, %esi
callq 0x14600
movl %eax, -0x3f4(%rbp)
jmp 0x11254
movl -0x3f4(%rbp), %edx
movq -0x400(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x3140
jmp 0x1126f
movq -0x408(%rbp), %rdi
addq $0x10, %rdi
callq 0x4e30
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x3090
movq %rax, -0x410(%rbp)
jmp 0x11297
movq -0x410(%rbp), %rdi
movq 0x31d0b(%rip), %rsi     # 0x42fb0
callq 0x3300
jmp 0x112ac
movq -0x408(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rdi
callq 0x131a0
movq %rax, -0x230(%rbp)
movq -0x228(%rbp), %rdi
callq 0x131d0
movq %rax, -0x238(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x13200
testb $0x1, %al
jne 0x112fd
jmp 0x11367
leaq -0x230(%rbp), %rdi
callq 0x13240
movb (%rax), %al
movb %al, -0x239(%rbp)
movsbl -0x239(%rbp), %esi
leaq -0x210(%rbp), %rdi
callq 0x3390
movq %rax, -0x418(%rbp)
jmp 0x1132d
movq -0x418(%rbp), %rdi
movl $0x20, %esi
callq 0x3390
jmp 0x11340
jmp 0x11342
leaq -0x230(%rbp), %rdi
callq 0x13420
jmp 0x112e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x119e5
movq 0x31c42(%rip), %rsi     # 0x42fb0
leaq -0x210(%rbp), %rdi
callq 0x3300
movq %rax, -0x420(%rbp)
jmp 0x11383
movq -0x420(%rbp), %rdi
movq -0x408(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x34d0
movq %rax, -0x428(%rbp)
jmp 0x113a2
movq -0x428(%rbp), %rdi
movq 0x31c00(%rip), %rsi     # 0x42fb0
callq 0x3300
jmp 0x113b7
movq -0x408(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
callq 0x12900
movq %rax, -0x250(%rbp)
movq -0x248(%rbp), %rdi
callq 0x12930
movq %rax, -0x258(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0x11408
jmp 0x1145a
leaq -0x250(%rbp), %rdi
callq 0x129a0
movl (%rax), %eax
movl %eax, -0x25c(%rbp)
movl -0x25c(%rbp), %esi
leaq -0x210(%rbp), %rdi
callq 0x34d0
movq %rax, -0x430(%rbp)
jmp 0x11437
movq -0x430(%rbp), %rdi
movl $0x20, %esi
callq 0x3390
jmp 0x1144a
jmp 0x1144c
leaq -0x250(%rbp), %rdi
callq 0x12aa0
jmp 0x113ef
movq 0x31b4f(%rip), %rsi     # 0x42fb0
leaq -0x210(%rbp), %rdi
callq 0x3300
movq %rax, -0x438(%rbp)
jmp 0x11476
movq -0x438(%rbp), %rdi
movq -0x408(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x34d0
movq %rax, -0x440(%rbp)
jmp 0x11495
movq -0x440(%rbp), %rdi
movl $0xa, %esi
callq 0x3390
movq %rax, -0x448(%rbp)
jmp 0x114af
movq -0x448(%rbp), %rdi
movq -0x408(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x34d0
movq %rax, -0x450(%rbp)
jmp 0x114ce
movq -0x450(%rbp), %rdi
movq 0x31ad4(%rip), %rsi     # 0x42fb0
callq 0x3300
jmp 0x114e3
movq -0x408(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rdi
callq 0x12900
movq %rax, -0x270(%rbp)
movq -0x268(%rbp), %rdi
callq 0x12930
movq %rax, -0x278(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0x11534
jmp 0x11586
leaq -0x270(%rbp), %rdi
callq 0x129a0
movl (%rax), %eax
movl %eax, -0x27c(%rbp)
movl -0x27c(%rbp), %esi
leaq -0x210(%rbp), %rdi
callq 0x34d0
movq %rax, -0x458(%rbp)
jmp 0x11563
movq -0x458(%rbp), %rdi
movl $0x20, %esi
callq 0x3390
jmp 0x11576
jmp 0x11578
leaq -0x270(%rbp), %rdi
callq 0x12aa0
jmp 0x1151b
movq 0x31a23(%rip), %rsi     # 0x42fb0
leaq -0x210(%rbp), %rdi
callq 0x3300
jmp 0x1159b
leaq -0x298(%rbp), %rdi
callq 0x14620
movq -0x408(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x12900
movq %rax, -0x2a8(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x12930
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0x115fb
jmp 0x118c6
leaq -0x2a8(%rbp), %rdi
callq 0x129a0
movq -0x408(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x2b4(%rbp)
addq $0x58, %rdi
movslq -0x2b4(%rbp), %rsi
callq 0x13320
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rdi
callq 0x13f70
movq %rax, -0x2c8(%rbp)
movq -0x2c0(%rbp), %rdi
callq 0x13fa0
movq %rax, -0x2d0(%rbp)
leaq -0x2c8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x13fd0
testb $0x1, %al
jne 0x1166f
jmp 0x118b3
leaq -0x2c8(%rbp), %rdi
callq 0x14000
movq (%rax), %rax
movq %rax, -0x2d8(%rbp)
movl -0x2b4(%rbp), %esi
leaq -0x398(%rbp), %rdi
callq 0x14790
jmp 0x11699
leaq 0x1ba9e(%rip), %rdx     # 0x2d13e
leaq -0x378(%rbp), %rdi
leaq -0x398(%rbp), %rsi
callq 0x141b0
jmp 0x116b5
movsbl -0x2d8(%rbp), %edx
leaq -0x358(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x14740
jmp 0x116d1
leaq 0x1ba66(%rip), %rdx     # 0x2d13e
leaq -0x338(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x141b0
jmp 0x116ed
movl -0x2d4(%rbp), %esi
leaq -0x3b8(%rbp), %rdi
callq 0x14790
jmp 0x11701
leaq -0x318(%rbp), %rdi
leaq -0x338(%rbp), %rsi
leaq -0x3b8(%rbp), %rdx
callq 0x14670
jmp 0x1171d
leaq 0x1bae3(%rip), %rdx     # 0x2d207
leaq -0x2f8(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0x141b0
jmp 0x11739
leaq -0x298(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x14640
jmp 0x1174e
leaq -0x2f8(%rbp), %rdi
callq 0x31c0
leaq -0x318(%rbp), %rdi
callq 0x31c0
leaq -0x3b8(%rbp), %rdi
callq 0x31c0
leaq -0x338(%rbp), %rdi
callq 0x31c0
leaq -0x358(%rbp), %rdi
callq 0x31c0
leaq -0x378(%rbp), %rdi
callq 0x31c0
leaq -0x398(%rbp), %rdi
callq 0x31c0
leaq -0x2c8(%rbp), %rdi
callq 0x14020
jmp 0x11653
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x119d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x118a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x11896
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1188a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1187e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x11872
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x11866
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x31c0
leaq -0x318(%rbp), %rdi
callq 0x31c0
leaq -0x3b8(%rbp), %rdi
callq 0x31c0
leaq -0x338(%rbp), %rdi
callq 0x31c0
leaq -0x358(%rbp), %rdi
callq 0x31c0
leaq -0x378(%rbp), %rdi
callq 0x31c0
leaq -0x398(%rbp), %rdi
callq 0x31c0
jmp 0x119d9
jmp 0x118b5
leaq -0x2a8(%rbp), %rdi
callq 0x12aa0
jmp 0x115df
leaq -0x298(%rbp), %rdi
callq 0x148b0
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x3090
movq %rax, -0x460(%rbp)
jmp 0x118ea
movq -0x460(%rbp), %rdi
movq 0x316b8(%rip), %rsi     # 0x42fb0
callq 0x3300
jmp 0x118ff
leaq -0x298(%rbp), %rax
movq %rax, -0x3c0(%rbp)
movq -0x3c0(%rbp), %rdi
callq 0x148d0
movq %rax, -0x3c8(%rbp)
movq -0x3c0(%rbp), %rdi
callq 0x14900
movq %rax, -0x3d0(%rbp)
leaq -0x3c8(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x14930
testb $0x1, %al
jne 0x1194c
jmp 0x119b8
leaq -0x3c8(%rbp), %rdi
callq 0x14970
movq %rax, %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x3120
jmp 0x11969
leaq -0x210(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x32b0
jmp 0x1197e
leaq -0x3f0(%rbp), %rdi
callq 0x31c0
leaq -0x3c8(%rbp), %rdi
callq 0x14990
jmp 0x11933
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x31c0
jmp 0x119d9
leaq -0x298(%rbp), %rdi
callq 0x149b0
leaq -0x210(%rbp), %rdi
callq 0x3440
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq -0x298(%rbp), %rdi
callq 0x149b0
leaq -0x210(%rbp), %rdi
callq 0x3440
movq -0x218(%rbp), %rdi
callq 0x34e0
nopl (%rax)