// File: /workspace/github_cpp_makefile_star2_O3/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, %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 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xd0(%rsp), %rdi
callq 0x2230
movq (%r14), %rsi
leaq 0xd0(%rsp), %rdi
movl $0x8, %edx
callq 0x2130
leaq 0xd0(%rsp), %rdi
movq %rsp, %rsi
callq 0x2120
cmpl $0x0, (%rsp)
jle 0xad28
leaq 0x10(%rbx), %r14
leaq 0x88(%rsp), %r12
movq $0x0, 0x8(%rsp)
leaq 0x20(%rsp), %r13
leaq 0x78(%rsp), %rbp
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
callq 0x22a0
movq %r12, 0x78(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x44cc
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4b7f
movq %r13, %rdi
movq %r15, %rsi
callq 0x2290
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xaca6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0xacc0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0xad01
movq 0x20(%rsp), %r13
xorl %ebp, %ebp
movb (%r13,%rbp), %al
movb %al, 0x40(%rsp)
movq 0x18(%rbx), %rsi
cmpq 0x20(%rbx), %rsi
je 0xacec
movb %al, (%rsi)
incq 0x18(%rbx)
jmp 0xacf9
movq %r14, %rdi
leaq 0x40(%rsp), %rdx
callq 0xee84
incq %rbp
cmpq %rbp, %r12
jne 0xacd1
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
cmpl (%rsp), %eax
leaq 0x88(%rsp), %r12
leaq 0x20(%rsp), %r13
leaq 0x78(%rsp), %rbp
jl 0xac45
movl 0x18(%rbx), %eax
subl 0x10(%rbx), %eax
movl %eax, (%rbx)
leaq 0x4(%rbx), %r14
leaq 0xd0(%rsp), %rdi
movq %r14, %rsi
callq 0x2120
movq %r14, 0x18(%rsp)
cmpl $0x0, (%r14)
jle 0xadb4
leaq 0x28(%rbx), %r15
movl $0x7fffffff, 0x8(%rsp)  # imm = 0x7FFFFFFF
xorl %r14d, %r14d
leaq 0xd0(%rsp), %rbp
movq %rsp, %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2120
movl (%rsp), %eax
movl 0x8(%rsp), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0x8(%rsp)
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0xad9a
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x30(%rbx)
jmp 0xada5
movq %r15, %rdi
movq %r13, %rdx
callq 0xef76
incl %r14d
movq 0x18(%rsp), %rax
cmpl (%rax), %r14d
jl 0xad69
jmp 0xadbc
movl $0x7fffffff, 0x8(%rsp)  # imm = 0x7FFFFFFF
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
cmpq %rcx, %rax
movl 0x8(%rsp), %edx
je 0xadd8
subl %edx, (%rax)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0xadcd
leaq 0x8(%rbx), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x2120
leaq 0xc(%rbx), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2120
cmpl $0x0, (%r15)
jle 0xae47
leaq 0x40(%rbx), %r14
xorl %r12d, %r12d
leaq 0xd0(%rsp), %r13
movq %rsp, %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2120
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0xae34
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rbx)
jmp 0xae3f
movq %r14, %rdi
movq %rbp, %rdx
callq 0xef76
incl %r12d
cmpl (%r15), %r12d
jl 0xae10
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rcx
cmpq %rcx, %rax
movl 0x8(%rsp), %edx
je 0xae63
subl %edx, (%rax)
addq $0x4, %rax
cmpq %rcx, %rax
jne 0xae58
leaq 0xd0(%rsp), %rdi
movq %rsp, %rsi
callq 0x2120
movq 0x18(%rsp), %rax
movslq (%rax), %rsi
leaq 0x48(%rsp), %rax
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0xb8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq 0xdd56
leaq 0x40(%rsp), %rdi
callq 0x40f8
cmpl $0x0, (%rsp)
jle 0xb0ad
leaq 0xa8(%rsp), %r12
xorl %ebp, %ebp
leaq 0x40(%rsp), %r14
leaq 0x7(%rsp), %r15
leaq 0xd0(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x22a0
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2120
movl 0x8(%rsp), %eax
subl %eax, 0x14(%rsp)
subl %eax, 0x10(%rsp)
movq %r12, 0x98(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %r13
movq %r13, %rdi
callq 0x44cc
movq %r14, %rdi
movq %r13, %rsi
callq 0x4b7f
movq %rbp, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x2290
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xaf6e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xaf8b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0xb095
movq 0x20(%rsp), %rbp
addq %rbp, %r12
movb (%rbp), %al
movb %al, 0x7(%rsp)
movslq 0x14(%rsp), %rcx
movq 0xb8(%rsp), %rdx
leaq (%rcx,%rcx,2), %rsi
shlq $0x4, %rsi
movq 0x10(%rdx,%rsi), %rcx
testq %rcx, %rcx
je 0xaff7
leaq (%rdx,%rsi), %rdi
addq %rdx, %rsi
addq $0x8, %rsi
movq %rsi, %rdx
xorl %r8d, %r8d
cmpb %al, 0x20(%rcx)
setl %r8b
cmovgeq %rcx, %rdx
movq 0x10(%rcx,%r8,8), %rcx
testq %rcx, %rcx
jne 0xafd5
cmpq %rsi, %rdx
je 0xaff7
cmpb 0x20(%rdx), %al
jge 0xb064
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq %r14, %rdi
xorl %esi, %esi
leaq 0x10(%rsp), %rdx
callq 0xef76
movslq 0x14(%rsp), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0xd41c
movq %rax, %rdi
movq %r14, %rsi
callq 0xddf0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xb056
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
incq %rbp
cmpq %r12, %rbp
jne 0xafa1
jmp 0xb095
movq %r15, %rsi
callq 0xd41c
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb086
movl 0x10(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb056
movq %rax, %rdi
leaq 0x10(%rsp), %rdx
callq 0xef76
jmp 0xb056
movq 0x18(%rsp), %rbp
incl %ebp
cmpl (%rsp), %ebp
leaq 0xa8(%rsp), %r12
jl 0xaed8
leaq 0x58(%rbx), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xd482
leaq 0xb8(%rsp), %rdi
callq 0x410c
leaq 0xd0(%rsp), %rdi
callq 0x2070
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xb0f4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb171
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x40f8
jmp 0xb1a2
movq %rax, %r14
jmp 0xb1af
jmp 0xb176
jmp 0xb176
jmp 0xb171
movq %rax, %r14
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0xb195
movq 0xa8(%rsp), %rsi
incq %rsi
jmp 0xb190
jmp 0xb176
jmp 0xb176
movq %rax, %r14
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0xb1a2
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0xb1a2
jmp 0xb176
jmp 0xb176
jmp 0xb171
movq %rax, %r14
jmp 0xb195
movq %rax, %r14
jmp 0xb1a2
movq %rax, %r14
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xb195
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
leaq 0xb8(%rsp), %rdi
callq 0x410c
leaq 0xd0(%rsp), %rdi
callq 0x2070
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xb1cb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x3ac4
movq %r14, %rdi
callq 0x2350