// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %r8, %r14
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, -0x2c(%rbp)
cmpq $0x3, %r8
jne 0x8c4a
cmpq $0x0, 0x38(%r15)
je 0x8d6e
movq 0x28(%r15), %rax
movq 0x10(%rax), %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
movq %rcx, -0x38(%rbp)
callq 0x39f8
movzbl %al, %edx
leaq 0x3347(%rip), %rsi      # 0xbfb2
movl -0x2c(%rbp), %r13d
movl %r13d, %edi
xorl %eax, %eax
callq 0x2110
movl %r13d, %edi
movq %rbx, %rsi
callq 0x3b77
leaq 0x22a2(%rip), %rsi      # 0xaf2d
movl %r13d, %edi
xorl %eax, %eax
callq 0x2110
movl %r13d, %edi
movq -0x38(%rbp), %rsi
callq 0x8ae6
xorl %ebx, %ebx
cmpq $0x2, %r14
setne %bl
leaq 0x3400(%rip), %rax      # 0xc0b1
leaq 0x32d6(%rip), %rdx      # 0xbf8e
cmoveq %rax, %rdx
movq 0x30(%r15,%rbx,8), %rcx
incq %rcx
leaq 0x32a8(%rip), %rsi      # 0xbf73
movl %r13d, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x24(,%rbx,4), %rbx
pushq $0x1
popq %r13
cmpq %r12, %r13
jae 0x8d3d
movq 0x28(%r15), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rax
cmpb $0x1, 0x22(%rax)
jne 0x8d38
cmpq $0x3, %r14
jne 0x8d05
cmpl $-0x1, 0x28(%rax)
jne 0x8d11
jmp 0x8d38
cmpq $0x2, %r14
jne 0x8d11
cmpl $-0x1, 0x24(%rax)
je 0x8d38
movq 0x8(%r15), %rcx
movq (%rcx), %rcx
movslq (%rax,%rbx), %rax
movq (%rcx,%rax,8), %rax
movq 0x10(%rax), %rcx
movl -0x2c(%rbp), %edi
leaq 0x3268(%rip), %rsi      # 0xbf96
movq %r13, %rdx
xorl %eax, %eax
callq 0x2110
incq %r13
jmp 0x8ce1
leaq 0x3264(%rip), %rsi      # 0xbfa8
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x32ba(%rip), %rsi      # 0xc011
movl %ebx, %edi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq