// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2e8, %rsp            # imm = 0x2E8
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xe0(%rsp), %rdi
callq 0x2230
movq (%r14), %rsi
leaq 0xe0(%rsp), %rdi
movl $0x8, %edx
callq 0x2130
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2120
cmpl $0x0, 0x10(%rsp)
jle 0xad88
leaq 0x10(%rbx), %r14
leaq 0x98(%rsp), %r12
movq $0x0, 0x18(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x88(%rsp), %rbp
leaq 0xe0(%rsp), %rdi
movq %r13, %rsi
callq 0x22a0
movq %r12, 0x88(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x44e2
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4b9c
movq %r13, %rdi
movq %r15, %rsi
callq 0x2290
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xacff
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xad1c
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x38(%rsp), %r12
testq %r12, %r12
je 0xad5d
movq 0x30(%rsp), %r13
xorl %ebp, %ebp
movb (%r13,%rbp), %al
movb %al, 0x50(%rsp)
movq 0x18(%rbx), %rsi
cmpq 0x20(%rbx), %rsi
je 0xad48
movb %al, (%rsi)
incq 0x18(%rbx)
jmp 0xad55
movq %r14, %rdi
leaq 0x50(%rsp), %rdx
callq 0xee8c
incq %rbp
cmpq %rbp, %r12
jne 0xad2d
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0x18(%rsp)
cmpl 0x10(%rsp), %eax
leaq 0x98(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x88(%rsp), %rbp
jl 0xac9b
movl 0x18(%rbx), %eax
subl 0x10(%rbx), %eax
movl %eax, (%rbx)
leaq 0x4(%rbx), %r14
leaq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0x2120
movq %r14, 0x28(%rsp)
cmpl $0x0, (%r14)
jle 0xae17
leaq 0x28(%rbx), %r15
movl $0x7fffffff, 0x18(%rsp) # imm = 0x7FFFFFFF
xorl %r14d, %r14d
leaq 0xe0(%rsp), %rbp
leaq 0x10(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2120
movl 0x10(%rsp), %eax
movl 0x18(%rsp), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0x18(%rsp)
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0xadfd
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x30(%rbx)
jmp 0xae08
movq %r15, %rdi
movq %r13, %rdx
callq 0xef7e
incl %r14d
movq 0x28(%rsp), %rax
cmpl (%rax), %r14d
jl 0xadcb
jmp 0xae1f
movl $0x7fffffff, 0x18(%rsp) # imm = 0x7FFFFFFF
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
cmpq %rcx, %rax
movl 0x18(%rsp), %edx
je 0xae3b
subl %edx, (%rax)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0xae30
leaq 0x8(%rbx), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x2120
leaq 0xc(%rbx), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2120
cmpl $0x0, (%r15)
jle 0xaead
leaq 0x40(%rbx), %r14
xorl %r12d, %r12d
leaq 0xe0(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2120
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0xae9a
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rbx)
jmp 0xaea5
movq %r14, %rdi
movq %rbp, %rdx
callq 0xef7e
incl %r12d
cmpl (%r15), %r12d
jl 0xae75
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rcx
cmpq %rcx, %rax
movl 0x18(%rsp), %edx
je 0xaec9
subl %edx, (%rax)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0xaebe
leaq 0xe0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2120
movq 0x28(%rsp), %rax
movslq (%rax), %rsi
leaq 0x58(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x8(%rax)
movaps %xmm0, 0x18(%rax)
movaps %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq $0x0, 0x20(%rax)
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
leaq 0x24(%rsp), %rcx
callq 0xdd9e
leaq 0x50(%rsp), %rdi
callq 0x411a
cmpl $0x0, 0x10(%rsp)
jle 0xb151
leaq 0xb8(%rsp), %r12
movl $0x0, 0x28(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %r14
leaq 0xe0(%rsp), %rdi
leaq 0x24(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
movq %r13, %rsi
callq 0x22a0
movq %rax, %rdi
leaq 0x14(%rsp), %rsi
callq 0x2120
movl 0x18(%rsp), %eax
subl %eax, 0x24(%rsp)
subl %eax, 0x14(%rsp)
movq %r12, 0xa8(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
callq 0x44e2
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4b9c
movq %r13, %rdi
movq %r14, %rsi
callq 0x2290
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xafda
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
je 0xaff7
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x38(%rsp), %r12
testq %r12, %r12
je 0xb130
movq 0x30(%rsp), %r13
addq %r13, %r12
movb (%r13), %cl
movb %cl, 0xf(%rsp)
movslq 0x24(%rsp), %rax
movq 0xc8(%rsp), %rdi
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rdi,%rax), %rdx
addq $0x8, %rdx
movq 0x8(%rdx), %r8
movq %rdx, %rsi
testq %r8, %r8
je 0xb05a
movq %rdx, %rsi
xorl %r9d, %r9d
cmpb %cl, 0x20(%r8)
setl %r9b
cmovgeq %r8, %rsi
movq 0x10(%r8,%r9,8), %r8
testq %r8, %r8
jne 0xb041
movq %rdx, %r8
cmpq %rdx, %rsi
je 0xb06c
cmpb 0x20(%rsi), %cl
cmovlq %rdx, %rsi
movq %rsi, %r8
cmpq %rdx, %r8
je 0xb09b
addq %rax, %rdi
leaq 0xf(%rsp), %rsi
callq 0xd4c0
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb0c7
movl 0x14(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb124
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x58(%rsp), %rsi
testq %rsi, %rsi
je 0xb0d6
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0xb0e3
movq %rax, %rdi
leaq 0x14(%rsp), %rdx
callq 0xef7e
jmp 0xb124
movq %r14, %rdi
leaq 0x14(%rsp), %rdx
callq 0xef7e
movslq 0x24(%rsp), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0xc8(%rsp), %rdi
leaq 0xf(%rsp), %rsi
callq 0xd4c0
movq %rax, %rdi
movq %r14, %rsi
callq 0xde38
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xb124
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
incq %r13
cmpq %r12, %r13
jne 0xb00d
movl 0x28(%rsp), %eax
incl %eax
movl %eax, 0x28(%rsp)
cmpl 0x10(%rsp), %eax
leaq 0xb8(%rsp), %r12
leaq 0x30(%rsp), %r13
jl 0xaf4d
leaq 0x58(%rbx), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xd524
leaq 0xc8(%rsp), %rdi
callq 0x412e
leaq 0xe0(%rsp), %rdi
callq 0x2070
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb198
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb21d
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x411a
jmp 0xb249
movq %rax, %r14
jmp 0xb256
jmp 0xb218
jmp 0xb218
jmp 0xb21d
movq %rax, %r14
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb23c
movq 0xb8(%rsp), %rsi
incq %rsi
jmp 0xb237
jmp 0xb218
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xb249
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb249
jmp 0xb218
jmp 0xb218
jmp 0xb218
jmp 0xb21d
movq %rax, %r14
jmp 0xb249
movq %rax, %r14
jmp 0xb23c
movq %rax, %r14
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xb23c
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
leaq 0xc8(%rsp), %rdi
callq 0x412e
leaq 0xe0(%rsp), %rdi
callq 0x2070
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb272
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x3ae6
movq %r14, %rdi
callq 0x2350