// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/fgfl/src/preprocess_regex.c
// Function: recur_node_topsort
static int
recur_node_topsort(lexical_spec_t* spec, spec_entry_t* crt_entry,
            size_t index_entry, vector_t* stack_order, bitset_t* seen_reg) {

    crt_entry->is_used = true;
    if (IS_PRESENT(seen_reg, GET_INDEX(crt_entry))) {
        if (GET_INDEX(crt_entry) == index_entry) {
            errorf(0, "Stack overflow. Cycle detected for regex %s.",
                                            crt_entry->name);
            return (ERROR);
        }
        return (DONE);
    }
    ADD_BITSET(seen_reg, GET_INDEX(crt_entry));

    bitset_t* depend_node = NULL;
    if (dependency_macro(spec, crt_entry, &depend_node) == ERROR)
        { return (ERROR); }

    int i;
    int exit_st = DONE;

    while ((i = IT_NEXT(depend_node)) != IT_NULL) {
        spec_entry_t* new_entry = (spec_entry_t*)AT_VECTOR(spec->entry_vect, i);
        if (recur_node_topsort(spec, new_entry,
                                index_entry, stack_order, seen_reg) == ERROR)
            { exit_st = ERROR; }
    }

    PUSH_BACK_VECTOR(stack_order, (void*)GET_INDEX(crt_entry));
    del_bitset(depend_node);

    return (exit_st);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
movb $0x1, 0xc(%rsi)
movq (%rsi), %rcx
testq %r8, %r8
je 0x7cb8
movl 0x4(%r8), %eax
cmpq %rax, %rcx
jae 0x7cbf
movq 0x8(%r8), %rdx
movq %rcx, %rsi
shrq $0x6, %rsi
movq (%rdx,%rsi,8), %rdx
btq %rcx, %rdx
jae 0x7cbf
xorl %ebx, %ebx
cmpq %r12, %rcx
jne 0x7ee9
movq 0x10(%r15), %rdx
leaq 0x406e(%rip), %rsi      # 0xbd18
xorl %edi, %edi
xorl %eax, %eax
callq 0x3bdc
jmp 0x7e94
movl 0x4, %eax
pushq $0x1
popq %rdx
cmpq %rax, %rcx
movq %r8, -0x68(%rbp)
jae 0x7cdf
movq %rdx, %rax
shlq %cl, %rax
movq 0x8(%r8), %rdx
shrq $0x6, %rcx
orq %rax, (%rdx,%rcx,8)
jmp 0x7cea
movq %r8, %rdi
movq %rcx, %rsi
callq 0x23f9
xorl %ebx, %ebx
cmpl $0x42, 0x8(%r15)
movq %r15, -0x58(%rbp)
jne 0x7cfe
xorl %edi, %edi
jmp 0x7ec1
movq %r14, -0x50(%rbp)
callq 0x2924
movq 0x20(%r15), %rdi
pushq $0x8
popq %rsi
movq %rax, -0x30(%rbp)
movq %rax, %rdx
callq 0x76b3
movq $0x0, -0x38(%rbp)
xorl %ecx, %ecx
movq %r12, -0x40(%rbp)
movq %rcx, %r14
movq -0x30(%rbp), %r15
movq 0x10(%r15), %rax
movq %rax, -0x60(%rbp)
cmpq %rax, %rcx
jae 0x7e7e
movq (%r15), %rax
movq (%rax,%r14,8), %r15
movq 0x8(%r13), %rdi
movq 0x8(%r15), %rsi
leaq -0x3be0(%rip), %rdx     # 0x4176
callq 0x2b36
cmpl $-0x1, %eax
movq %r15, -0x48(%rbp)
je 0x7db3
movq 0x8(%r13), %rcx
movq (%rcx), %rcx
movslq %eax, %r15
movq (%rcx,%r15,8), %r12
cmpl $0x42, 0x8(%r12)
je 0x7e30
movq -0x38(%rbp), %rax
testq %rax, %rax
jne 0x7d8c
callq 0x230c
movq (%r12), %rcx
movq %rax, %rdi
movl 0x4(%rax), %eax
cmpq %rax, %rcx
movq %rdi, -0x38(%rbp)
jae 0x7dd3
pushq $0x1
popq %rax
shlq %cl, %rax
movq 0x8(%rdi), %rdx
shrq $0x6, %rcx
orq %rax, (%rdx,%rcx,8)
jmp 0x7ddb
movq 0x10(%r13), %rdi
movq 0x8(%r15), %rsi
movq 0x820e(%rip), %rdx      # 0xffd0
callq 0x2b36
cmpl $-0x1, %eax
setne %r15b
sete %al
jmp 0x7e09
movq %rcx, %rsi
callq 0x23f9
movq -0x48(%rbp), %rax
movq %r15, 0x10(%rax)
movb $0x1, %r15b
cmpb $0x1, 0x1a(%r12)
jne 0x7e03
movq 0x10(%r12), %rdx
xorl %edi, %edi
leaq 0x3f49(%rip), %rsi      # 0xbd45
xorl %eax, %eax
callq 0x3d40
movb $0x1, %al
movq -0x40(%rbp), %r12
testb %r15b, %r15b
je 0x7e1a
leaq 0x1(%r14), %rcx
testb %al, %al
jne 0x7d28
testb %r15b, %r15b
je 0x7e59
testb %al, %al
jne 0x7e71
leaq 0x3fab(%rip), %rcx      # 0xbdd5
movq -0x30(%rbp), %r15
jmp 0x7e3f
movq -0x40(%rbp), %r12
movq -0x30(%rbp), %r15
leaq 0x3f8e(%rip), %rcx      # 0xbdcd
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x3f68(%rip), %rsi      # 0xbdb6
xorl %edi, %edi
xorl %eax, %eax
callq 0x3bdc
jmp 0x7e75
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x3f27(%rip), %rsi      # 0xbd8f
xorl %edi, %edi
xorl %eax, %eax
callq 0x3bdc
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %rdi
callq 0x2351
movq %r15, %rdi
callq 0x29c6
cmpq -0x60(%rbp), %r14
movq -0x50(%rbp), %r14
movq -0x38(%rbp), %rdi
jae 0x7ec1
pushq $-0x1
popq %rbx
jmp 0x7ee9
movq 0x8(%r13), %rcx
movq (%rcx), %rcx
cltq
movq (%rcx,%rax,8), %rsi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
movq -0x68(%rbp), %r8
callq 0x7c4d
cmpl $-0x1, %eax
cmovel %eax, %ebx
movq %r15, %rdi
movq %rdi, %r15
callq 0x273a
cmpl $-0x1, %eax
jne 0x7e99
movq 0x10(%r14), %rsi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
movq %r14, %rdi
callq 0x2a16
movq %r15, %rdi
callq 0x2351
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq