// File: /workspace/github_cpp_makefile_star2_O1/JameyWoo[P]re2graph/algorithms.cpp
// Function: get_closure(NFA, std::vector<std::set<int, std::less<int>, std::allocator<int>>, std::allocator<std::set<int, std::less<int>, std::allocator<int>>>>&, int, std::vector<bool, std::allocator<bool>>&)
void get_closure(NFA nfa, vector<set<int>> &closures, int state, vector<bool> &visted) {
    /**
     * ! 获取nfa某状态闭包的函数. 存储在closures中
     * !  参数解释: 
     * NFA nfa: 要求闭包的nfa
     * vector<set<int>> &closures: 闭包存储的数据结构
     * int state: 当前要求闭包的状态. 由于dfa, 先求出它可以扩展的状态, 再回来求它
     * vector<bool> &visted: 回溯的标记, 先标记为true, 回溯之后标记为false
     */
    if (closures[state].size()) return;
    for (auto x : nfa.jump[state]) {                                                 // 当前状态的map集
        if (x.first == '~') {                                                        // 当边为 空 时, 可以滑动求闭包
            for (auto y : x.second) {                                                // 遍历下一状态
                if (visted[y] == false) {                                            // 当前递归路径没有被访问过
                    visted[y] = true;                                                // 标记访问
                    get_closure(nfa, closures, y, visted);                           // 递归得到下一状态闭包
                    closures[state].insert(closures[y].begin(), closures[y].end());  // 更新当前状态闭包
                    visted[y] = false;                                               // 撤销标记
                }
            }
        }
    }
    closures[state].insert(state);  // ! ...插入自己......
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, 0xc(%rsp)
movslq %edx, %rax
movq (%rsi), %rdx
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
cmpq $0x0, 0x28(%rdx,%rax)
jne 0x73af
movq %rcx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x58(%rsp)
movq 0x58(%rdi), %rcx
addq %rax, %rcx
addq $0x8, %rcx
movq 0x10(%rcx), %rax
movq %rcx, 0x40(%rsp)
cmpq %rcx, %rax
je 0x7392
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
leaq 0x3f(%r14), %rbx
movq %rbx, 0x50(%rsp)
movb 0x20(%rax), %cl
movb %cl, 0x20(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x28(%rax), %rsi
leaq 0x28(%rsp), %rdi
callq 0x3c86
cmpb $0x7e, 0x20(%rsp)
movq 0x18(%rsp), %rsi
jne 0x7366
movq 0x28(%rsp), %r15
movq 0x30(%rsp), %rdi
cmpq %rdi, %r15
je 0x7366
movq %rdi, 0x60(%rsp)
movslq (%r15), %rbp
leaq 0x3f(%rbp), %r12
testq %rbp, %rbp
cmovnsq %rbp, %r12
sarq $0x6, %r12
shlq $0x3, %r12
movq (%rsi), %rax
addq %r12, %rax
movq %rbp, %rcx
andq %rbx, %rcx
xorl %edx, %edx
cmpq %r14, %rcx
setbe %dl
movl $0x1, %r13d
movl %ebp, %ecx
shlq %cl, %r13
movq -0x8(%rax,%rdx,8), %rcx
btq %rbp, %rcx
jb 0x7359
leaq -0x8(,%rdx,8), %rbx
orq %r13, %rcx
movq %rcx, (%rax,%rbx)
leaq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x3a32
leaq 0x68(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %ebp, %edx
movq 0x18(%rsp), %rcx
callq 0x717f
leaq 0xc0(%rsp), %rdi
callq 0x412e
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x72d1
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x72ee
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x7308
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movslq 0xc(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rcx, %rdi
leaq (,%rbp,2), %rax
addq %rbp, %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
addq $0x8, %rdx
movq 0x10(%rdx), %rsi
callq 0xfda4
movq 0x18(%rsp), %rsi
addq (%rsi), %r12
notq %r13
andq %r13, (%rbx,%r12)
movq 0x50(%rsp), %rbx
movq 0x60(%rsp), %rdi
addq $0x4, %r15
cmpq %rdi, %r15
jne 0x722f
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x737d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0x48(%rsp), %rdi
callq 0x2160
cmpq 0x40(%rsp), %rax
jne 0x71ed
leaq 0xc(%rsp), %rsi
movslq (%rsi), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
movq 0x10(%rsp), %rax
addq (%rax), %rdi
callq 0xffc0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3ae6
jmp 0x73d3
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x73ea
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2350