// File: /workspace/github_c_makefile_star2_O1/MaoKo[P]FGFX/fgfl/src/gen_dfa.c
// Function: gen_kind_final_table
void
gen_kind_final_table(int filde, lexical_spec_t const* spec, char const* header,
                            spec_entry_t const* state, size_t kind) {
    if ((kind == ANCHOR_FINAL_TABLE) && (!spec->size_final_anchor))
        { return; }

    size_t size_states = SIZE_VECTOR(spec->states);
    dprintf(filde, STATIC SP "uint%u_t" NL,
                                min_size_type(size_states, true));
    gen_verbatim_file(filde, header);

    dprintf(filde, SEP);
    gen_state_name(filde, state);

    dprintf(filde, "%sfinal_table[%zu][2] = " BEG_BLOCK NL,
                (kind != FINAL_TABLE) ? "anchor_" : "", ((kind != FINAL_TABLE) 
                ? spec->size_final_anchor : spec->size_final) + 1);

    for (size_t i = 1; i < size_states; ++i) {
        dfa_state_t* crt_state = (dfa_state_t*)AT_VECTOR(spec->states, i);

        if (!crt_state->is_final)
            { continue; }
        else if ((kind == ANCHOR_FINAL_TABLE)
                            && (crt_state->final_anchor_entry == NO_FINAL))
            { continue; }
        else if ((kind == FINAL_TABLE) && (crt_state->final_entry == NO_FINAL))
            { continue; }

        spec_entry_t* crt_entry = (spec_entry_t*)AT_VECTOR(spec->entry_vect,
            ((kind != FINAL_TABLE) ? (size_t)crt_state->final_anchor_entry
                                   : (size_t)crt_state->final_entry)); 

        dprintf(filde,  TAB BEG_BLOCK SP "%ld" COMMA SP TAB TOKEN_PREFIX
                        SEP "%s" SP END_BLOCK COMMA NL, i, crt_entry->name);
    }

    dprintf(filde, TAB BEG_BLOCK SP "0" SP END_BLOCK COMMA NL);
    dprintf(filde, END_BLOCK SEMI NL NL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
movq %rdx, %r13
movq %rsi, %r15
movl %edi, %ebx
cmpq $0x3, %r8
jne 0x9563
cmpq $0x0, 0x38(%r15)
je 0x96a1
movq %rcx, -0x30(%rbp)
movq 0x28(%r15), %rax
movq 0x10(%rax), %r12
movq %r12, %rdi
movl $0x1, %esi
callq 0x3e58
movzbl %al, %edx
leaq 0x2a70(%rip), %rsi      # 0xbff6
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r13, %rsi
callq 0x3fe6
leaq 0x19a6(%rip), %rsi      # 0xaf46
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movq -0x30(%rbp), %rax
leaq 0x2b41(%rip), %r13      # 0xc0f5
movq %r13, %rcx
movq %r13, %rdx
testq %rax, %rax
je 0x95ca
movq 0x10(%rax), %rdx
leaq 0x197c(%rip), %rcx      # 0xaf46
leaq 0x2aad(%rip), %rsi      # 0xc07e
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
xorl %eax, %eax
cmpq $0x2, %r14
setne %al
leaq 0x29e8(%rip), %rdx      # 0xbfd2
cmoveq %r13, %rdx
movq 0x30(%r15,%rax,8), %rcx
incq %rcx
leaq 0x29ba(%rip), %rsi      # 0xbfb7
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
cmpq $0x2, %r12
jb 0x9673
movl $0x1, %r13d
movq 0x28(%r15), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rax
cmpb $0x1, 0x22(%rax)
jne 0x966b
cmpq $0x3, %r14
jne 0x962f
cmpl $-0x1, 0x28(%rax)
je 0x966b
movl $0x28, %ecx
cmpq $0x2, %r14
jne 0x9645
movl $0x24, %ecx
cmpl $-0x1, 0x24(%rax)
je 0x966b
movq 0x8(%r15), %rdx
movq (%rdx), %rdx
movslq (%rax,%rcx), %rax
movq (%rdx,%rax,8), %rax
movq 0x10(%rax), %rcx
movl %ebx, %edi
leaq 0x2979(%rip), %rsi      # 0xbfda
movq %r13, %rdx
xorl %eax, %eax
callq 0x2110
incq %r13
cmpq %r13, %r12
jne 0x9612
leaq 0x2972(%rip), %rsi      # 0xbfec
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x29cb(%rip), %rsi      # 0xc055
movl %ebx, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq