// File: /workspace/github_c_makefile_star2_O1/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 %r8, %r13
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movb $0x1, 0xc(%rsi)
testq %r8, %r8
je 0x848b
movq (%r14), %rax
movl 0x4(%r13), %ecx
cmpq %rcx, %rax
jae 0x848b
movq 0x8(%r13), %rcx
movq %rax, %rdx
shrq $0x6, %rdx
movq (%rcx,%rdx,8), %rcx
btq %rax, %rcx
jae 0x848b
xorl %r15d, %r15d
cmpq %r12, %rax
jne 0x873a
movq 0x10(%r14), %rdx
leaq 0x38e5(%rip), %rsi      # 0xbd5c
xorl %edi, %edi
xorl %eax, %eax
callq 0x4060
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x873a
movq (%r14), %rcx
movl 0x4(%r13), %eax
cmpq %rax, %rcx
jae 0x84ad
movl $0x1, %eax
shlq %cl, %rax
movq 0x8(%r13), %rdx
shrq $0x6, %rcx
orq %rax, (%rdx,%rcx,8)
jmp 0x84b8
movq %r13, %rdi
movq %rcx, %rsi
callq 0x25a8
xorl %eax, %eax
cmpl $0x42, 0x8(%r14)
movq %r15, -0x68(%rbp)
movq %r14, -0x70(%rbp)
movq %rbx, -0x50(%rbp)
jne 0x84da
movq $0x0, -0x30(%rbp)
jmp 0x86be
callq 0x2b3c
movq %rax, %rbx
movq 0x20(%r14), %rdi
movl $0x8, %esi
movq %rax, %rdx
callq 0x7e56
cmpq $0x0, 0x10(%rbx)
je 0x8683
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
xorl %r14d, %r14d
movq %r12, -0x40(%rbp)
movq %r13, -0x60(%rbp)
movq %rbx, -0x58(%rbp)
movq (%rbx), %rax
movq (%rax,%r14,8), %rbx
movq 0x8(%r15), %rdi
movq 0x8(%rbx), %rsi
leaq -0x4065(%rip), %rdx     # 0x44ce
callq 0x2d4a
cmpl $-0x1, %eax
movq %rbx, -0x48(%rbp)
je 0x859d
movq 0x8(%r15), %rcx
movq (%rcx), %rcx
movslq %eax, %r12
movq (%rcx,%r12,8), %r13
movl $0x42, %ebx
movb $0x1, %r15b
cmpl $0x42, 0x8(%r13)
je 0x85f0
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
jne 0x8573
callq 0x247c
movq %rax, %rdi
movq (%r13), %rcx
movl 0x4(%rdi), %eax
cmpq %rax, %rcx
movq -0x48(%rbp), %rbx
movq %rdi, -0x30(%rbp)
jae 0x85c4
movl $0x1, %eax
shlq %cl, %rax
movq 0x8(%rdi), %rdx
shrq $0x6, %rcx
orq %rax, (%rdx,%rcx,8)
jmp 0x85cc
movq 0x10(%r15), %rdi
movq 0x8(%rbx), %rsi
movq 0x7a24(%rip), %rdx      # 0xffd0
callq 0x2d4a
xorl %ebx, %ebx
cmpl $-0x1, %eax
setne %r15b
sete %bl
negl %ebx
orl $0x43, %ebx
jmp 0x85f4
movq %rcx, %rsi
callq 0x25a8
movq %r12, 0x10(%rbx)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpb $0x1, 0x1a(%r13)
jne 0x85f0
movq 0x10(%r13), %rdx
xorl %edi, %edi
leaq 0x37a0(%rip), %rsi      # 0xbd89
xorl %eax, %eax
callq 0x22f9
movq -0x40(%rbp), %r12
cmpl $-0x1, %ebx
sete %r13b
andb %r15b, %r13b
jne 0x8663
testb %r15b, %r15b
je 0x8642
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x38(%rbp)
cmpl $-0x1, %ebx
je 0x8663
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
cmpl $0x42, %ebx
leaq 0x37f4(%rip), %rcx      # 0xbe19
leaq 0x37e5(%rip), %rax      # 0xbe11
cmoveq %rax, %rcx
xorl %edi, %edi
leaq 0x37c1(%rip), %rsi      # 0xbdfa
xorl %eax, %eax
callq 0x4060
jmp 0x8663
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %edi, %edi
leaq 0x3780(%rip), %rsi      # 0xbdd3
xorl %eax, %eax
callq 0x4060
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x38(%rbp)
testb %r13b, %r13b
je 0x8695
incq %r14
movq -0x58(%rbp), %rbx
cmpq 0x10(%rbx), %r14
movq -0x60(%rbp), %r13
movq -0x68(%rbp), %r15
jb 0x851d
jmp 0x869d
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
jmp 0x869d
movq -0x60(%rbp), %r13
movq -0x58(%rbp), %rbx
movq -0x38(%rbp), %r14
testl %r14d, %r14d
movq -0x30(%rbp), %rdi
je 0x86af
callq 0x24ca
movq %rbx, %rdi
callq 0x2bde
cmpl $-0x1, %r14d
sete %al
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testb %al, %al
jne 0x873a
movq -0x30(%rbp), %rdi
callq 0x292b
xorl %r15d, %r15d
cmpl $-0x1, %eax
je 0x8719
movq -0x68(%rbp), %rbx
movq %r12, %r14
movq -0x50(%rbp), %r12
movq 0x8(%rbx), %rcx
movq (%rcx), %rcx
cltq
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x8416
cmpl $-0x1, %eax
cmovel %eax, %r15d
movq -0x30(%rbp), %rdi
callq 0x292b
cmpl $-0x1, %eax
jne 0x86e4
jmp 0x871d
movq -0x50(%rbp), %r12
movq 0x10(%r12), %rsi
movq -0x70(%rbp), %rax
movq (%rax), %rdx
movq %r12, %rdi
callq 0x2c31
movq -0x30(%rbp), %rdi
callq 0x24ca
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq