// File: JameyWoo[P]re2graph/algorithms.cpp
// Function: read_from_nfa(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
NFA read_from_nfa(string file) {
    NFA nfa;
    int num;
    string str;
    ifstream readfile;
    readfile.open(file.c_str(), ios::in);

    // 读入nfa中的字符
    readfile >> num;
    for (int i = 0; i < num; ++i) {
        readfile >> str;
        str = parse_range(str);  // 进行范围解析, 返回解析出的字符组成的字符串
        for (auto s : str) {
            nfa.chars.push_back(s);
        }
    }
    nfa.char_cnt = nfa.chars.size();  // 这才是真的字符数量

    // 读入状态, 都是数字, 如果不是0开始, 比如1开始, 则正规化为0开始
    readfile >> nfa.state_cnt;
    int min_state = INT_MAX;
    for (int i = 0; i < nfa.state_cnt; ++i) {
        readfile >> num;
        min_state = min(min_state, num);
        nfa.states.push_back(num);
    }
    for (auto &s : nfa.states) {  // ! 状态正规化, 全都变为0开始
        s -= min_state;           // 减去最小
    }

    // 读入起始状态和接受(终止)状态
    readfile >> nfa.start_state >> nfa.end_state_cnt;
    for (int i = 0; i < nfa.end_state_cnt; ++i) {
        readfile >> num;
        nfa.end_states.push_back(num);
    }
    for (auto &s : nfa.end_states) {  // 这里也要同步正规化状态
        s -= min_state;
    }

    // 读入状态转化函数(边)
    readfile >> num;
    vector<map<char, vector<int>>> tmp = vector<map<char, vector<int>>>(nfa.state_cnt, map<char, vector<int>>());
    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 (tmp[x].count(c) == 0) {
                vector<int> tos;
                tos.push_back(y);
                tmp[x][c] = tos;
            } else {
                tmp[x][c].push_back(y);
            }
        }
    }
    nfa.jump = tmp;
    // cout << "NFA load over! " << endl;
    return nfa;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rsi, -0x3f0(%rbp)
movq %rdi, -0x3e8(%rbp)
movq %rdi, %rax
movq %rax, -0x3e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x11e40
leaq -0x38(%rbp), %rdi
callq 0x3410
leaq -0x240(%rbp), %rdi
callq 0x3360
jmp 0xfa0b
movq -0x3f0(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq -0x240(%rbp), %rdi
movl $0x8, %edx
callq 0x31e0
jmp 0xfa2d
leaq -0x240(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x31b0
jmp 0xfa3f
movl $0x0, -0x250(%rbp)
movl -0x250(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xfbaa
leaq -0x240(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x33e0
jmp 0xfa6a
leaq -0x290(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3120
jmp 0xfa7c
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x9370
jmp 0xfa91
leaq -0x38(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x33b0
leaq -0x270(%rbp), %rdi
callq 0x31c0
leaq -0x290(%rbp), %rdi
callq 0x31c0
leaq -0x38(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rdi
callq 0x3290
movq %rax, -0x2a0(%rbp)
movq -0x298(%rbp), %rdi
callq 0x3180
movq %rax, -0x2a8(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x8b00
testb $0x1, %al
jne 0xfb06
jmp 0xfb94
leaq -0x2a0(%rbp), %rdi
callq 0x8bb0
movq -0x3e8(%rbp), %rdi
movb (%rax), %al
movb %al, -0x2a9(%rbp)
addq $0x10, %rdi
leaq -0x2a9(%rbp), %rsi
callq 0x11f90
jmp 0xfb33
jmp 0xfb35
leaq -0x2a0(%rbp), %rdi
callq 0x8b80
jmp 0xfaea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x101da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x101ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x31c0
jmp 0x101ce
jmp 0xfb96
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0xfa49
movq -0x3e8(%rbp), %rdi
addq $0x10, %rdi
callq 0x4e30
movq -0x3e8(%rbp), %rsi
movl %eax, (%rsi)
addq $0x4, %rsi
leaq -0x240(%rbp), %rdi
callq 0x31b0
jmp 0xfbd5
movl $0x7fffffff, -0x2b0(%rbp) # imm = 0x7FFFFFFF
movl $0x0, -0x2b4(%rbp)
movq -0x3e8(%rbp), %rcx
movl -0x2b4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0xfc5e
leaq -0x240(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x31b0
jmp 0xfc0d
leaq -0x2b0(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x142d0
movq %rax, -0x3f8(%rbp)
jmp 0xfc26
movq -0x3e8(%rbp), %rdi
movq -0x3f8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2b0(%rbp)
addq $0x28, %rdi
leaq -0x18(%rbp), %rsi
callq 0x12030
jmp 0xfc4b
jmp 0xfc4d
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0xfbe9
movq -0x3e8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rdi
callq 0x12900
movq %rax, -0x2c8(%rbp)
movq -0x2c0(%rbp), %rdi
callq 0x12930
movq %rax, -0x2d0(%rbp)
leaq -0x2c8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0xfcaf
jmp 0xfce3
leaq -0x2c8(%rbp), %rdi
callq 0x129a0
movq %rax, -0x2d8(%rbp)
movl -0x2b0(%rbp), %edx
movq -0x2d8(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
leaq -0x2c8(%rbp), %rdi
callq 0x12aa0
jmp 0xfc96
movq -0x3e8(%rbp), %rsi
addq $0x8, %rsi
leaq -0x240(%rbp), %rdi
callq 0x31b0
movq %rax, -0x400(%rbp)
jmp 0xfd03
movq -0x400(%rbp), %rdi
movq -0x3e8(%rbp), %rsi
addq $0xc, %rsi
callq 0x31b0
jmp 0xfd1c
movl $0x0, -0x2dc(%rbp)
movq -0x3e8(%rbp), %rcx
movl -0x2dc(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0xfd73
leaq -0x240(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x31b0
jmp 0xfd4a
movq -0x3e8(%rbp), %rdi
addq $0x40, %rdi
leaq -0x18(%rbp), %rsi
callq 0x12030
jmp 0xfd60
jmp 0xfd62
movl -0x2dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2dc(%rbp)
jmp 0xfd26
movq -0x3e8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x12900
movq %rax, -0x2f0(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x12930
movq %rax, -0x2f8(%rbp)
leaq -0x2f0(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x12960
testb $0x1, %al
jne 0xfdc4
jmp 0xfdf8
leaq -0x2f0(%rbp), %rdi
callq 0x129a0
movq %rax, -0x300(%rbp)
movl -0x2b0(%rbp), %edx
movq -0x300(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
leaq -0x2f0(%rbp), %rdi
callq 0x12aa0
jmp 0xfdab
leaq -0x240(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x31b0
jmp 0xfe0a
movq -0x3e8(%rbp), %rax
movslq 0x4(%rax), %rax
movq %rax, -0x418(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x330(%rbp)
movaps %xmm0, -0x340(%rbp)
movaps %xmm0, -0x350(%rbp)
leaq -0x350(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x14310
leaq -0x351(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x120a0
movq -0x418(%rbp), %rsi
movq -0x410(%rbp), %rdx
movq -0x408(%rbp), %rcx
leaq -0x318(%rbp), %rdi
callq 0x14330
jmp 0xfe7d
leaq -0x351(%rbp), %rdi
callq 0x5d70
leaq -0x350(%rbp), %rdi
callq 0x6f60
movl $0x0, -0x358(%rbp)
movl -0x358(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x1017c
leaq -0x240(%rbp), %rdi
leaq -0x35c(%rbp), %rsi
callq 0x31b0
movq %rax, -0x420(%rbp)
jmp 0xfeca
movq -0x420(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x33e0
movq %rax, -0x428(%rbp)
jmp 0xfee3
movq -0x428(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x31b0
jmp 0xfef8
movl -0x2b0(%rbp), %ecx
movl -0x35c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x35c(%rbp)
movl -0x2b0(%rbp), %ecx
movl -0x360(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x360(%rbp)
leaq -0x3a0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3120
jmp 0xff32
leaq -0x380(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x9370
jmp 0xff47
leaq -0x38(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x33b0
leaq -0x380(%rbp), %rdi
callq 0x31c0
leaq -0x3a0(%rbp), %rdi
callq 0x31c0
leaq -0x38(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq -0x3a8(%rbp), %rdi
callq 0x3290
movq %rax, -0x3b0(%rbp)
movq -0x3a8(%rbp), %rdi
callq 0x3180
movq %rax, -0x3b8(%rbp)
leaq -0x3b0(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x8b00
testb $0x1, %al
jne 0xffbc
jmp 0x10166
leaq -0x3b0(%rbp), %rdi
callq 0x8bb0
movb (%rax), %al
movb %al, -0x3b9(%rbp)
movslq -0x35c(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x121f0
movq %rax, %rdi
leaq -0x3b9(%rbp), %rsi
callq 0x13260
movq %rax, -0x430(%rbp)
jmp 0xfffb
movq -0x430(%rbp), %rax
cmpq $0x0, %rax
jne 0x10111
leaq -0x3d8(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x7230
movq -0x438(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x12030
jmp 0x10034
movslq -0x35c(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x121f0
movq %rax, %rdi
leaq -0x3b9(%rbp), %rsi
callq 0x12210
movq %rax, -0x440(%rbp)
jmp 0x1005f
movq -0x440(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x143b0
jmp 0x10074
leaq -0x3d8(%rbp), %rdi
callq 0x4d70
jmp 0x10153
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x351(%rbp), %rdi
callq 0x5d70
leaq -0x350(%rbp), %rdi
callq 0x6f60
jmp 0x101ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x101c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x31c0
jmp 0x101c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x4d70
jmp 0x101c2
movslq -0x35c(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x121f0
movq %rax, %rdi
leaq -0x3b9(%rbp), %rsi
callq 0x12210
movq %rax, -0x448(%rbp)
jmp 0x1013c
movq -0x448(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x12030
jmp 0x10151
jmp 0x10153
jmp 0x10155
leaq -0x3b0(%rbp), %rdi
callq 0x8b80
jmp 0xffa0
jmp 0x10168
movl -0x358(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x358(%rbp)
jmp 0xfe9f
movq -0x3e8(%rbp), %rdi
addq $0x58, %rdi
leaq -0x318(%rbp), %rsi
callq 0x12310
jmp 0x10195
movb $0x1, -0x11(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x7180
leaq -0x240(%rbp), %rdi
callq 0x30b0
leaq -0x38(%rbp), %rdi
callq 0x31c0
testb $0x1, -0x11(%rbp)
jne 0x101fd
jmp 0x101f1
leaq -0x318(%rbp), %rdi
callq 0x7180
leaq -0x240(%rbp), %rdi
callq 0x30b0
leaq -0x38(%rbp), %rdi
callq 0x31c0
movq -0x3e8(%rbp), %rdi
callq 0x4880
jmp 0x1020d
movq -0x3e8(%rbp), %rdi
callq 0x4880
movq -0x3e0(%rbp), %rax
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
movq -0x248(%rbp), %rdi
callq 0x34e0
nopl (%rax)