// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x2350
pushq $0x30
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20e0
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
subq 0x10(%rax), %rsi
leaq 0x138(%rsp), %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r14
movq 0x18(%rax), %r15
leaq 0x138(%rsp), %rbx
pushq $0x20
popq %rbp
cmpq %r15, %r14
je 0x8531
movsbl (%r14), %esi
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movl %ebp, %esi
callq 0x2270
incq %r14
jmp 0x8511
leaq 0x138(%rsp), %rdi
callq 0x20f0
movq 0x8(%rsp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x2360
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rax
movq 0x28(%rax), %r14
movq 0x30(%rax), %r15
leaq 0x138(%rsp), %rbx
pushq $0x20
popq %rbp
cmpq %r15, %r14
je 0x858e
movl (%r14), %esi
movq %rbx, %rdi
callq 0x2360
movq %rax, %rdi
movl %ebp, %esi
callq 0x2270
addq $0x4, %r14
jmp 0x856e
leaq 0x138(%rsp), %rdi
callq 0x20f0
movq 0x8(%rsp), %rcx
movl 0x8(%rcx), %esi
movq %rax, %rdi
callq 0x2360
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2270
movq 0x8(%rsp), %rcx
movl 0xc(%rcx), %esi
movq %rax, %rdi
callq 0x2360
movq %rax, %rdi
callq 0x20f0
movq 0x8(%rsp), %rax
movq 0x40(%rax), %r14
movq 0x48(%rax), %r15
leaq 0x138(%rsp), %rbx
pushq $0x20
popq %rbp
cmpq %r15, %r14
je 0x8606
movl (%r14), %esi
movq %rbx, %rdi
callq 0x2360
movq %rax, %rdi
movl %ebp, %esi
callq 0x2270
addq $0x4, %r14
jmp 0x85e6
leaq 0x138(%rsp), %rdi
callq 0x20f0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x30(%rax), %rax
movq %rax, 0x30(%rsp)
leaq 0x98(%rsp), %r14
leaq 0x118(%rsp), %r12
leaq 0xd8(%rsp), %r13
cmpq 0x30(%rsp), %rcx
je 0x8798
movq %rcx, 0x38(%rsp)
movslq (%rcx), %rcx
movq 0x8(%rsp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0x40(%rsp)
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x48(%rsp)
movq 0x10(%rax), %rax
cmpq 0x48(%rsp), %rax
je 0x878a
movq %r13, %r15
movq %r12, %r13
movb 0x20(%rax), %r12b
movq %rax, 0x50(%rsp)
movl 0x24(%rax), %ebp
movq %r14, %rdi
movq 0x40(%rsp), %rsi
callq 0x9591
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x69dd(%rip), %r14      # 0xf09e
movq %r14, %rdx
callq 0x9371
movsbl %r12b, %edx
movq %r13, %r12
movq %r13, %rdi
movq %rbx, %rsi
callq 0x956f
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x9371
movq %r15, %rdi
movl %ebp, %esi
callq 0x9591
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
movq %r15, %rdx
callq 0x9508
movq %r15, %r13
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x6a45(%rip), %rdx      # 0xf167
callq 0x9371
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xd362
movq %r15, %rdi
callq 0x20d0
leaq 0xb8(%rsp), %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20d0
leaq 0x58(%rsp), %rdi
callq 0x20d0
movq %r12, %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x20d0
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x20d0
movq 0x50(%rsp), %rdi
callq 0x2170
jmp 0x8682
movq 0x38(%rsp), %rcx
addq $0x4, %rcx
jmp 0x864d
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x5, %rsi
leaq 0x138(%rsp), %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20f0
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r12
leaq 0x78(%rsp), %r14
leaq 0x138(%rsp), %r15
cmpq %r12, %rbx
je 0x87fb
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22d0
movq %r15, %rdi
movq %r14, %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x20d0
addq $0x20, %rbx
jmp 0x87d2
leaq 0x10(%rsp), %rdi
callq 0x95ea
leaq 0x138(%rsp), %rdi
callq 0x22f0
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8885
jmp 0x883b
jmp 0x8885
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x88b9
jmp 0x883b
jmp 0x883b
movq %rax, %rbx
jmp 0x88c8
movq %rax, %rbx
jmp 0x8879
movq %rax, %rbx
jmp 0x886c
movq %rax, %rbx
jmp 0x885f
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20d0
leaq 0xb8(%rsp), %rdi
callq 0x20d0
leaq 0xd8(%rsp), %rdi
callq 0x20d0
leaq 0x58(%rsp), %rdi
callq 0x20d0
jmp 0x8897
movq %rax, %rbx
jmp 0x88be
movq %rax, %rbx
jmp 0x88b1
movq %rax, %rbx
jmp 0x88a4
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x20d0
leaq 0xf8(%rsp), %rdi
callq 0x20d0
leaq 0x98(%rsp), %rdi
callq 0x20d0
leaq 0x10(%rsp), %rdi
callq 0x95ea
leaq 0x138(%rsp), %rdi
callq 0x22f0
movq %rbx, %rdi
callq 0x2370