// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x43, -0x14(%rbp)
je 0x5687
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
leaq 0x8d18(%rip), %rsi      # 0xe342
callq 0x11b0
cmpl $0x0, %eax
je 0x5653
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
leaq 0x8f81(%rip), %rsi      # 0xe5ca
callq 0x11b0
cmpl $0x0, %eax
jne 0x5687
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdx
leaq 0x8f5b(%rip), %rsi      # 0xe5ce
movb $0x0, %al
callq 0x4230
movq $0x0, -0x8(%rbp)
jmp 0x58c5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rsi
leaq -0xd64(%rip), %rdx      # 0x4940
callq 0x2300
movl %eax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpl $-0x1, -0x18(%rbp)
je 0x56d3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
jmp 0x5717
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rsi
leaq -0xdb0(%rip), %rdx      # 0x4940
callq 0x2300
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
je 0x5715
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
jmp 0x5717
cmpq $0x0, -0x20(%rbp)
je 0x57e4
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x14(%rbp), %eax
je 0x57d7
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
cmpl $0x2d, -0x14(%rbp)
jne 0x5751
leaq 0x8ee4(%rip), %rax      # 0xe62f
movq %rax, -0x38(%rbp)
jmp 0x576d
movl -0x14(%rbp), %edx
leaq 0x8904(%rip), %rax      # 0xe05f
leaq 0x88f4(%rip), %rcx      # 0xe056
cmpl $0x42, %edx
cmoveq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x2d, 0x8(%rax)
jne 0x578c
leaq 0x8ea9(%rip), %rax      # 0xe62f
movq %rax, -0x48(%rbp)
jmp 0x57ac
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x88c5(%rip), %rax      # 0xe05f
leaq 0x88b5(%rip), %rcx      # 0xe056
cmpl $0x42, %edx
cmoveq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rdx
movq -0x48(%rbp), %r8
xorl %eax, %eax
movl %eax, %edi
leaq 0x8e3d(%rip), %rsi      # 0xe600
movb $0x0, %al
callq 0x4230
movq $0x0, -0x8(%rbp)
jmp 0x58c5
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x58c5
cmpl $0x43, -0x14(%rbp)
jne 0x57f8
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x5804
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x40, %edi
callq 0x38d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x582e
movq $0x0, -0x8(%rbp)
jmp 0x58c5
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x10b0
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x1190
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x5884
movq -0x20(%rbp), %rdi
callq 0x48e0
movq $0x0, -0x8(%rbp)
jmp 0x58c5
movq -0x20(%rbp), %rax
cmpl $0x2d, 0x8(%rax)
jne 0x5899
movq -0x20(%rbp), %rax
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x2090
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop