// File: /workspace/github_c_makefile_star2_O3/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 0x4da5
leaq 0x620c(%rip), %rsi      # 0xaf92
movq %r12, %rdi
callq 0x2210
testl %eax, %eax
je 0x4dc3
leaq 0x6481(%rip), %rsi      # 0xb21a
movq %r12, %rdi
callq 0x2210
testl %eax, %eax
je 0x4dc3
movq 0x8(%r14), %rdi
leaq -0x9de(%rip), %rdx      # 0x43d2
movq %r12, %rsi
callq 0x2d45
cmpl $-0x1, %eax
je 0x4de0
leaq 0x8(%r14), %rcx
jmp 0x4e03
movslq 0x28(%r15), %rdi
leaq 0x6450(%rip), %rsi      # 0xb21e
xorl %r15d, %r15d
movq %r12, %rdx
xorl %eax, %eax
callq 0x3f64
jmp 0x4ee6
movq (%r14), %rax
movq 0x10(%r14), %rdi
movq 0x10(%rax), %rax
movq (%rax), %rsi
leaq -0xa23(%rip), %rdx      # 0x43d2
callq 0x2d45
cmpl $-0x1, %eax
je 0x4e6d
leaq 0x10(%r14), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
cltq
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x4e6d
movl 0x8(%r15), %eax
cmpl %ebx, %eax
je 0x4ee6
cmpl $0x42, %ebx
leaq 0x5e7c(%rip), %rdx      # 0xaca6
leaq 0x5e7e(%rip), %r8       # 0xacaf
movq %r8, %rcx
cmoveq %rdx, %rcx
cmpl $0x2d, %ebx
leaq 0x643d(%rip), %rsi      # 0xb27f
cmoveq %rsi, %rcx
cmpl $0x42, %eax
cmoveq %rdx, %r8
movq 0x10(%r15), %rdx
cmpl $0x2d, %eax
cmoveq %rsi, %r8
leaq 0x63f1(%rip), %rsi      # 0xb250
xorl %r15d, %r15d
xorl %edi, %edi
xorl %eax, %eax
callq 0x3f64
jmp 0x4ee6
xorl %eax, %eax
cmpl $0x43, %ebx
sete %al
movq 0x8(%r14,%rax,8), %r12
movl $0x40, %edi
callq 0x3a4e
testq %rax, %rax
je 0x4ee3
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 0x4edb
cmpl $0x2d, %ebx
jne 0x4ec6
movl $0xffffffff, 0x30(%r15) # imm = 0xFFFFFFFF
movq 0x10(%r12), %rsi
movq %rsi, (%r15)
movq %r12, %rdi
movq %r15, %rdx
callq 0x2c21
jmp 0x4ee6
movq %r15, %rdi
callq 0x4395
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq