// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/preprocess_regex.c
// Function: dependency_macro
static int
dependency_macro(lexical_spec_t* spec,
                                spec_entry_t* entry, bitset_t** set_macro) {
    if (!set_macro)
        { return (ERROR); }
    else if (entry->kind == T_KEYWORD)
        { return (DONE); }

    vector_t* depend_vect = new_vector();
    int exit_st = DONE;

    search_kind_regex_node(entry->regex_ast, AST_BOUND_NAME, depend_vect);
    for (size_t i = 0; i < SIZE_VECTOR(depend_vect); ++i) {
        regex_node_t* bound_node = (regex_node_t*)AT_VECTOR(depend_vect, i);

        bool find_dependence = false;
        int depend_not_token = -1;

        int index = get_index_vector(spec->entry_vect,
                                bound_node->bound_name, &cmp_token_entry);
        if (index != -1) {
            find_dependence = true;
            spec_entry_t* crt_entry = (spec_entry_t*)
                                AT_VECTOR(spec->entry_vect, index);

            if ((crt_entry->kind == T_KEYWORD))
                { depend_not_token = T_KEYWORD; }
            else {
                if (!*set_macro)
                    { *set_macro = new_bitset(); }
                ADD_BITSET(*set_macro, GET_INDEX(crt_entry));
                bound_node->index_token = index;

                if (crt_entry->use_look) {
                    warnf(0, "The token %s use lookahead operator. It's "
                            "feature is disable when expand.", crt_entry->name);
                }
            }
        }
        else {
            int index = get_index_vector(spec->state_vect,
                                            bound_node->bound_name, &strcmp);
            if (index != -1) {
                find_dependence = true;
                depend_not_token = T_STATE;
            }
        }

        if (!find_dependence || (depend_not_token != -1)) {
            if (!find_dependence) {
                errorf(0, "Macro name %s is not defined anywhere.",
                                bound_node->bound_name);
            }
            else if (depend_not_token != -1) {
                errorf(0, "Macro name %s is a %s.", bound_node->bound_name,
                        (depend_not_token == T_KEYWORD) ? "keyword" : "state" );
            }

            exit_st = ERROR;
            break;
        }
    }

    if (exit_st)
        { del_bitset(*set_macro); }
    del_vector(depend_vect);

    return (exit_st);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xb537
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb787
movq -0x18(%rbp), %rax
cmpl $0x42, 0x8(%rax)
jne 0xb54d
movl $0x0, -0x4(%rbp)
jmp 0xb787
jmp 0xb54f
callq 0x1f00
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x28(%rbp), %rdx
movl $0x8, %esi
callq 0xa6e0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xb766
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movb $0x0, -0x41(%rbp)
movl $0xffffffff, -0x48(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x6c84(%rip), %rdx     # 0x4940
callq 0x2300
movl %eax, -0x4c(%rbp)
cmpl $-0x1, -0x4c(%rbp)
je 0xb6b0
movb $0x1, -0x41(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x42, 0x8(%rax)
jne 0xb607
movl $0x42, -0x48(%rbp)
jmp 0xb6ae
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xb620
callq 0x12b0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0xb64b
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
callq 0x1440
jmp 0xb67c
movq -0x58(%rbp), %rax
movq (%rax), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x6, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movslq -0x4c(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
testb $0x1, 0x1a(%rax)
je 0xb6ac
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x3ab0(%rip), %rsi      # 0xf155
movb $0x0, %al
callq 0x43e0
jmp 0xb6ae
jmp 0xb6e2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x7911(%rip), %rdx      # 0x12fd8
callq 0x2300
movl %eax, -0x5c(%rbp)
cmpl $-0x1, -0x5c(%rbp)
je 0xb6e0
movb $0x1, -0x41(%rbp)
movl $0x43, -0x48(%rbp)
jmp 0xb6e2
testb $0x1, -0x41(%rbp)
je 0xb6ee
cmpl $-0x1, -0x48(%rbp)
je 0xb753
testb $0x1, -0x41(%rbp)
jne 0xb710
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x3a98(%rip), %rsi      # 0xf19f
movb $0x0, %al
callq 0x4230
jmp 0xb74a
cmpl $-0x1, -0x48(%rbp)
je 0xb748
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x48(%rbp), %esi
leaq 0x3abd(%rip), %rcx      # 0xf1e5
leaq 0x3aae(%rip), %rax      # 0xf1dd
cmpl $0x42, %esi
cmoveq %rax, %rcx
xorl %eax, %eax
movl %eax, %edi
leaq 0x3a85(%rip), %rsi      # 0xf1c6
movb $0x0, %al
callq 0x4230
jmp 0xb74a
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xb766
jmp 0xb755
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xb57d
cmpl $0x0, -0x2c(%rbp)
je 0xb778
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x1320
movq -0x28(%rbp), %rdi
callq 0x2010
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq