// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rsi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movq %rdi, 0x10(%rsp)
movups %xmm0, 0x10(%rdi)
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xd0(%rsp), %rdi
callq 0x2240
movq (%rbx), %rsi
leaq 0xd0(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2150
leaq 0xd0(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2140
movq 0x10(%rsp), %rax
leaq 0x10(%rax), %rbx
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
leaq 0xb0(%rsp), %r15
leaq 0x60(%rsp), %r13
cmpl 0x4(%rsp), %ebp
jge 0x789d
leaq 0xd0(%rsp), %rdi
movq %r14, %rsi
callq 0x22b0
movq %r15, %rdi
movq %r14, %rsi
callq 0x22d0
movq %r13, %rdi
movq %r15, %rsi
callq 0x4009
movq %r14, %rdi
movq %r13, %rsi
callq 0x2290
movq %r13, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x20d0
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r15
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x7889
movb (%r14,%r12), %al
movb %al, 0x60(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8b80
incq %r12
jmp 0x786c
incl %ebp
leaq 0x20(%rsp), %r14
leaq 0xb0(%rsp), %r15
jmp 0x7818
movq 0x10(%rsp), %rcx
movl 0x18(%rcx), %eax
subl 0x10(%rcx), %eax
movl %eax, (%rcx)
leaq 0x4(%rcx), %rbp
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
callq 0x2140
movq 0x10(%rsp), %rax
leaq 0x28(%rax), %r14
xorl %ebx, %ebx
movl $0x7fffffff, 0x8(%rsp)  # imm = 0x7FFFFFFF
leaq 0xd0(%rsp), %r15
leaq 0x4(%rsp), %r12
cmpl (%rbp), %ebx
jge 0x7911
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movl 0x4(%rsp), %r13d
movq %r14, %rdi
movq %r12, %rsi
callq 0x8b9a
movl 0x8(%rsp), %eax
cmpl %eax, %r13d
cmovll %r13d, %eax
movl %eax, 0x8(%rsp)
incl %ebx
jmp 0x78de
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rax
movq 0x30(%rcx), %rcx
movl 0x8(%rsp), %edx
cmpq %rcx, %rax
je 0x792f
subl %edx, (%rax)
addq $0x4, %rax
jmp 0x7922
movq 0x10(%rsp), %rbx
leaq 0x8(%rbx), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x2140
leaq 0xc(%rbx), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x2140
leaq 0x40(%rbx), %r15
xorl %ebx, %ebx
leaq 0xd0(%rsp), %r12
leaq 0x4(%rsp), %r13
cmpl (%r14), %ebx
jge 0x7986
movq %r12, %rdi
movq %r13, %rsi
callq 0x2140
movq %r15, %rdi
movq %r13, %rsi
callq 0x8b9a
incl %ebx
jmp 0x7967
movq 0x10(%rsp), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rcx
movl 0x8(%rsp), %edx
cmpq %rcx, %rax
je 0x79a4
subl %edx, (%rax)
addq $0x4, %rax
jmp 0x7997
leaq 0xd0(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2140
movslq (%rbp), %rsi
leaq 0x68(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x93e8
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x3706
xorl %ebx, %ebx
leaq 0x20(%rsp), %r12
leaq 0x1c(%rsp), %rbp
leaq 0x90(%rsp), %r13
leaq 0x3(%rsp), %r15
cmpl 0x4(%rsp), %ebx
jge 0x7b44
leaq 0xd0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
movq %r12, %rsi
callq 0x22b0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2140
movl 0x8(%rsp), %eax
subl %eax, 0xc(%rsp)
subl %eax, 0x1c(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x22d0
movq %rbx, 0x58(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x4009
movq %r12, %rdi
movq %r14, %rsi
callq 0x2290
movq %r14, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20d0
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x7b2b
movb (%r12,%rbx), %al
movb %al, 0x3(%rsp)
movslq 0xc(%rsp), %rax
imulq $0x30, %rax, %rdi
addq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x8f26
testq %rax, %rax
je 0x7ae1
movslq 0xc(%rsp), %rax
imulq $0x30, %rax, %rdi
addq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x8c0a
movq %rax, %rdi
movq %rbp, %rsi
callq 0x8b9a
jmp 0x7b23
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x8b9a
movslq 0xc(%rsp), %rax
imulq $0x30, %rax, %rdi
addq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x8c0a
movq %rax, %rdi
movq %r14, %rsi
callq 0x943e
movq %r14, %rdi
callq 0x329e
incq %rbx
jmp 0x7a92
movq 0x58(%rsp), %rbx
incl %ebx
leaq 0x20(%rsp), %r12
leaq 0x90(%rsp), %r13
jmp 0x7a12
movq 0x10(%rsp), %rbx
leaq 0x58(%rbx), %rdi
leaq 0x40(%rsp), %rsi
callq 0x8c58
leaq 0x40(%rsp), %rdi
callq 0x3730
leaq 0xd0(%rsp), %rdi
callq 0x2070
leaq 0x20(%rsp), %rdi
callq 0x20d0
movq %rbx, %rax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7beb
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3706
jmp 0x7bf8
movq %rax, %rbx
jmp 0x7c05
jmp 0x7bd7
jmp 0x7bd7
jmp 0x7beb
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x20d0
jmp 0x7bee
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x20d0
jmp 0x7bf8
jmp 0x7bd7
jmp 0x7bd7
jmp 0x7bd7
jmp 0x7bd7
jmp 0x7beb
movq %rax, %rbx
jmp 0x7bf8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x329e
jmp 0x7bee
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3730
leaq 0xd0(%rsp), %rdi
callq 0x2070
leaq 0x20(%rsp), %rdi
callq 0x20d0
movq 0x10(%rsp), %rdi
callq 0x303e
movq %rbx, %rdi
callq 0x2370