// File: JameyWoo[P]re2graph/algorithms.cpp
// Function: readDfaData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
DFA readDfaData(string input_file) {
    /*
    各行的含义注解:
    3           // 字符集中的字符个数 (以下两行也可合并成一行)
    / * ^       // 以空格分隔的字符集。^代表任意非/和*的字符
    5           // 状态个数 (以下两行也可合并成一行)
    1 2 3 4 5   // 状态编号。若约定总是用从1开始的连续数字表示，则此行可省略
    1           // 开始状态的编号。若约定为1，则此行可省略
    1           // 结束状态个数。若约定为1，则此行可省略
    5           // 结束状态的编号
    7           // 转移函数的个数
    1 / 2       // 转移函数
    2 * 3
    3 * 4
    3 ^ 3
    4 ^ 3
    4 * 4
    4 / 5
    */
    DFA dfa;
    ifstream readfile;
    readfile.open(input_file.c_str(), ios::in);
    readfile >> dfa.char_cnt;
    string str;
    int num;
    for (int i = 0; i < dfa.char_cnt; ++i) {
        readfile >> str;
        str = parse_range(str);  // 进行范围解析, 返回解析出的字符组成的字符串
        for (auto s : str) {
            dfa.chars.push_back(s);
        }
    }
    readfile >> dfa.state_cnt;
    int min_state = INT_MAX;
    for (int i = 0; i < dfa.state_cnt; ++i) {
        readfile >> num;
        min_state = min(min_state, num);
        dfa.states.push_back(num);
    }
    for (auto &s : dfa.states) {
        s -= min_state;
    }
    readfile >> dfa.start_state >> dfa.end_state_cnt;
    for (int i = 0; i < dfa.end_state_cnt; ++i) {
        readfile >> num;
        dfa.end_states.push_back(num);
    }
    for (auto &s : dfa.end_states) {
        s -= min_state;
    }
    readfile >> num;
    for (int i = 0; i < dfa.state_cnt; ++i) {  // 先把空hash添加到vector
        map<char, int> tmp;
        dfa.jump_map.push_back(tmp);
    }
    for (int i = 0; i < num; ++i) {
        int x, y;
        readfile >> x >> str >> y;
        x -= min_state;
        y -= min_state;
        str = parse_range(str);
        for (auto c : str) {
            // if (dfa.jump_map[x].count(c)) {
            //     correct       = false;
            //     wrong_message = "一个状态输入同一个字符有多个下一状态";
            // }
            dfa.jump_map[x][c] = y;
        }
    }
    // cout << "DFA read over! " << endl;
    return dfa;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movq %rsi, -0x3c8(%rbp)
movq %rdi, -0x3c0(%rbp)
movq %rdi, %rax
movq %rax, -0x3b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x48d0
leaq -0x220(%rbp), %rdi
callq 0x3360
jmp 0x10b02
movq -0x3c8(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x31e0
jmp 0x10b24
movq -0x3c0(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x31b0
jmp 0x10b39
leaq -0x250(%rbp), %rdi
callq 0x3410
movl $0x0, -0x258(%rbp)
movq -0x3c0(%rbp), %rcx
movl -0x258(%rbp), %eax
cmpl (%rcx), %eax
jge 0x10cd9
leaq -0x220(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x33e0
jmp 0x10b79
leaq -0x298(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3120
jmp 0x10b8e
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x9370
jmp 0x10ba3
leaq -0x250(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x33b0
leaq -0x278(%rbp), %rdi
callq 0x31c0
leaq -0x298(%rbp), %rdi
callq 0x31c0
leaq -0x250(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x3290
movq %rax, -0x2a8(%rbp)
movq -0x2a0(%rbp), %rdi
callq 0x3180
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x8b00
testb $0x1, %al
jne 0x10c1e
jmp 0x10cc3
leaq -0x2a8(%rbp), %rdi
callq 0x8bb0
movq -0x3c0(%rbp), %rdi
movb (%rax), %al
movb %al, -0x2b1(%rbp)
addq $0x10, %rdi
leaq -0x2b1(%rbp), %rsi
callq 0x11f90
jmp 0x10c4b
jmp 0x10c4d
leaq -0x2a8(%rbp), %rdi
callq 0x8b80
jmp 0x10c02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x111f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x111cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x111c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x31c0
jmp 0x111c0
jmp 0x10cc5
movl -0x258(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x258(%rbp)
jmp 0x10b4f
movq -0x3c0(%rbp), %rsi
addq $0x4, %rsi
leaq -0x220(%rbp), %rdi
callq 0x31b0
jmp 0x10cf2
movl $0x7fffffff, -0x2b8(%rbp) # imm = 0x7FFFFFFF
movl $0x0, -0x2bc(%rbp)
movq -0x3c0(%rbp), %rcx
movl -0x2bc(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x10d84
leaq -0x220(%rbp), %rdi
leaq -0x254(%rbp), %rsi
callq 0x31b0
jmp 0x10d2d
leaq -0x2b8(%rbp), %rdi
leaq -0x254(%rbp), %rsi
callq 0x142d0
movq %rax, -0x3d0(%rbp)
jmp 0x10d49
movq -0x3c0(%rbp), %rdi
movq -0x3d0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2b8(%rbp)
addq $0x28, %rdi
leaq -0x254(%rbp), %rsi
callq 0x12030
jmp 0x10d71
jmp 0x10d73
movl -0x2bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x10d06
movq -0x3c0(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x12900
movq %rax, -0x2d0(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x12930
movq %rax, -0x2d8(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0x10dd5
jmp 0x10e09
leaq -0x2d0(%rbp), %rdi
callq 0x129a0
movq %rax, -0x2e0(%rbp)
movl -0x2b8(%rbp), %edx
movq -0x2e0(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
leaq -0x2d0(%rbp), %rdi
callq 0x12aa0
jmp 0x10dbc
movq -0x3c0(%rbp), %rsi
addq $0x8, %rsi
leaq -0x220(%rbp), %rdi
callq 0x31b0
movq %rax, -0x3d8(%rbp)
jmp 0x10e29
movq -0x3d8(%rbp), %rdi
movq -0x3c0(%rbp), %rsi
addq $0xc, %rsi
callq 0x31b0
jmp 0x10e42
movl $0x0, -0x2e4(%rbp)
movq -0x3c0(%rbp), %rcx
movl -0x2e4(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x10e9f
leaq -0x220(%rbp), %rdi
leaq -0x254(%rbp), %rsi
callq 0x31b0
jmp 0x10e73
movq -0x3c0(%rbp), %rdi
addq $0x40, %rdi
leaq -0x254(%rbp), %rsi
callq 0x12030
jmp 0x10e8c
jmp 0x10e8e
movl -0x2e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e4(%rbp)
jmp 0x10e4c
movq -0x3c0(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x2f0(%rbp)
movq -0x2f0(%rbp), %rdi
callq 0x12900
movq %rax, -0x2f8(%rbp)
movq -0x2f0(%rbp), %rdi
callq 0x12930
movq %rax, -0x300(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0x10ef0
jmp 0x10f24
leaq -0x2f8(%rbp), %rdi
callq 0x129a0
movq %rax, -0x308(%rbp)
movl -0x2b8(%rbp), %edx
movq -0x308(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
leaq -0x2f8(%rbp), %rdi
callq 0x12aa0
jmp 0x10ed7
leaq -0x220(%rbp), %rdi
leaq -0x254(%rbp), %rsi
callq 0x31b0
jmp 0x10f39
movl $0x0, -0x30c(%rbp)
movq -0x3c0(%rbp), %rcx
movl -0x30c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x10fc1
leaq -0x340(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x130c0
movq -0x3c0(%rbp), %rdi
movq -0x3e0(%rbp), %rsi
addq $0x58, %rdi
callq 0x14a10
jmp 0x10f81
leaq -0x340(%rbp), %rdi
callq 0x8600
movl -0x30c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30c(%rbp)
jmp 0x10f43
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x8600
jmp 0x111c0
movl $0x0, -0x344(%rbp)
movl -0x344(%rbp), %eax
cmpl -0x254(%rbp), %eax
jge 0x1119c
leaq -0x220(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x31b0
movq %rax, -0x3e8(%rbp)
jmp 0x10ff9
movq -0x3e8(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x33e0
movq %rax, -0x3f0(%rbp)
jmp 0x11015
movq -0x3f0(%rbp), %rdi
leaq -0x34c(%rbp), %rsi
callq 0x31b0
jmp 0x1102a
movl -0x2b8(%rbp), %ecx
movl -0x348(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x348(%rbp)
movl -0x2b8(%rbp), %ecx
movl -0x34c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34c(%rbp)
leaq -0x390(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3120
jmp 0x11067
leaq -0x370(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x9370
jmp 0x1107c
leaq -0x250(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x33b0
leaq -0x370(%rbp), %rdi
callq 0x31c0
leaq -0x390(%rbp), %rdi
callq 0x31c0
leaq -0x250(%rbp), %rax
movq %rax, -0x398(%rbp)
movq -0x398(%rbp), %rdi
callq 0x3290
movq %rax, -0x3a0(%rbp)
movq -0x398(%rbp), %rdi
callq 0x3180
movq %rax, -0x3a8(%rbp)
leaq -0x3a0(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x8b00
testb $0x1, %al
jne 0x110f7
jmp 0x11186
leaq -0x3a0(%rbp), %rdi
callq 0x8bb0
movq -0x3c0(%rbp), %rdi
movb (%rax), %al
movb %al, -0x3a9(%rbp)
movl -0x34c(%rbp), %eax
movl %eax, -0x3fc(%rbp)
addq $0x58, %rdi
movslq -0x348(%rbp), %rsi
callq 0x13320
movq %rax, %rdi
leaq -0x3a9(%rbp), %rsi
callq 0x13340
movq %rax, -0x3f8(%rbp)
jmp 0x11146
movq -0x3f8(%rbp), %rax
movl -0x3fc(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x3a0(%rbp), %rdi
callq 0x8b80
jmp 0x110db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x31c0
jmp 0x111c0
jmp 0x11188
movl -0x344(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x344(%rbp)
jmp 0x10fcb
movb $0x1, -0x11(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x31c0
leaq -0x220(%rbp), %rdi
callq 0x30b0
testb $0x1, -0x11(%rbp)
jne 0x111e6
jmp 0x111da
leaq -0x250(%rbp), %rdi
callq 0x31c0
leaq -0x220(%rbp), %rdi
callq 0x30b0
jmp 0x111f6
movq -0x3c0(%rbp), %rdi
callq 0x4a00
movq -0x3b8(%rbp), %rax
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
movq -0x3c0(%rbp), %rdi
callq 0x4a00
movq -0x228(%rbp), %rdi
callq 0x34e0
nop