// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/fgfl/src/lexical_spec.c
// Function: add_entry_lexeme
static spec_entry_t*
add_entry_lexeme(lexical_spec_t* spec, int kind) {
    if ((kind != T_STATE) && ((!strcmp(C_LEXEME(spec->lex), "ERROR"))
                            || (!strcmp(C_LEXEME(spec->lex), "EOF")))) {
        errorf(CURRENT_LINE(spec->lex),
                    "Can't redefine %s. Name reserved for special use.",
                    C_LEXEME(spec->lex));
        return (NULL);
    }

    int index = get_index_vector(spec->entry_vect,
                            C_LEXEME(spec->lex), &cmp_token_entry);

    spec_entry_t* entry = NULL;
    if (index != -1)
        { entry = (spec_entry_t*)AT_VECTOR(spec->entry_vect, index); }
    else {
        index = get_index_vector(spec->state_vect,
                            C_LEXEME(spec->lex), &cmp_token_entry);
        if (index != -1)
            { entry = (spec_entry_t*)AT_VECTOR(spec->state_vect, index); }
    }

    if (entry) {
        if (entry->kind != kind) {
            errorf(0, "Attempt to define %s into a %s but it is a %s.",
                entry->name, KIND_IN2_STR(kind), KIND_IN2_STR(entry->kind));
            return (NULL);
        }
        return (entry);
    }

    vector_t* src_vect = ((kind == T_STATE)
                        ? spec->state_vect : spec->entry_vect);

    entry = NEW(spec_entry_t, 1);
    if (!entry)
        { return (NULL); }
    memset(entry, 0, sizeof(*entry));

    entry->kind = kind;
    entry->name = strdup(C_LEXEME(spec->lex));

    if (!entry->name) {
        del_spec_entry(entry);
        return (NULL);
    }

    if (entry->kind == T_TERMINAL)
        { entry->default_action = NONE_ACTION; }

    entry->index = SIZE_VECTOR(src_vect);
    PUSH_BACK_VECTOR(src_vect, entry);

    return (entry);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %r15
movq 0x10(%r15), %rax
movq (%rax), %r12
cmpl $0x43, %esi
je 0x4b78
leaq 0x6420(%rip), %rsi      # 0xaf79
movq %r12, %rdi
callq 0x2210
testl %eax, %eax
je 0x4b96
leaq 0x6695(%rip), %rsi      # 0xb201
movq %r12, %rdi
callq 0x2210
testl %eax, %eax
je 0x4b96
movq 0x8(%r14), %rdi
leaq -0xa0d(%rip), %rdx      # 0x4176
movq %r12, %rsi
callq 0x2b36
cmpl $-0x1, %eax
je 0x4bb3
leaq 0x8(%r14), %rcx
jmp 0x4bd6
movslq 0x28(%r15), %rdi
leaq 0x6664(%rip), %rsi      # 0xb205
xorl %r15d, %r15d
movq %r12, %rdx
xorl %eax, %eax
callq 0x3bdc
jmp 0x4cb4
movq (%r14), %rax
movq 0x10(%r14), %rdi
movq 0x10(%rax), %rax
movq (%rax), %rsi
leaq -0xa52(%rip), %rdx      # 0x4176
callq 0x2b36
cmpl $-0x1, %eax
je 0x4c40
leaq 0x10(%r14), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
cltq
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x4c40
movl 0x8(%r15), %eax
cmpl %ebx, %eax
je 0x4cb4
cmpl $0x42, %ebx
leaq 0x5535(%rip), %rdx      # 0xa132
leaq 0x5537(%rip), %r8       # 0xa13b
movq %r8, %rcx
cmoveq %rdx, %rcx
cmpl $0x2d, %ebx
leaq 0x6651(%rip), %rsi      # 0xb266
cmoveq %rsi, %rcx
cmpl $0x42, %eax
cmoveq %rdx, %r8
movq 0x10(%r15), %rdx
cmpl $0x2d, %eax
cmoveq %rsi, %r8
leaq 0x6605(%rip), %rsi      # 0xb237
xorl %r15d, %r15d
xorl %edi, %edi
xorl %eax, %eax
callq 0x3bdc
jmp 0x4cb4
xorl %eax, %eax
cmpl $0x43, %ebx
sete %al
movq 0x8(%r14,%rax,8), %r12
pushq $0x40
popq %rdi
callq 0x372f
testq %rax, %rax
je 0x4cb1
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movl %ebx, 0x8(%rax)
movq (%r14), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x21f0
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x4ca9
cmpl $0x2d, %ebx
jne 0x4c94
orl $-0x1, 0x30(%r15)
movq 0x10(%r12), %rsi
movq %rsi, (%r15)
movq %r12, %rdi
movq %r15, %rdx
callq 0x2a16
jmp 0x4cb4
movq %r15, %rdi
callq 0x4139
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq