// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
movb $0x1, 0xc(%rax)
cmpq $0x0, -0x30(%rbp)
je 0xb2de
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0xb2e6
xorl %eax, %eax
testb $0x1, %al
jne 0xb31c
jmp 0xb35b
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0xb35b
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0xb34f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x3dec(%rip), %rsi      # 0xf128
movb $0x0, %al
callq 0x4230
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb452
movl $0x0, -0x4(%rbp)
jmp 0xb452
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0xb380
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x1440
jmp 0xb3ae
movq -0x18(%rbp), %rax
movq (%rax), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xb510
cmpl $-0x1, %eax
jne 0xb3d5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb452
movl $0x0, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1ac0
movl %eax, -0x3c(%rbp)
cmpl $-0x1, %eax
je 0xb42b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0xb2a0
cmpl $-0x1, %eax
jne 0xb429
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
jmp 0xb3dc
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
callq 0x2090
movq -0x38(%rbp), %rdi
callq 0x1320
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)