// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rsi, %r15
movl %edi, -0x2c(%rbp)
cmpq $0x3, %r8
jne 0x9400
cmpq $0x0, 0x38(%r15)
je 0x9553
movq %rcx, -0x38(%rbp)
movq 0x28(%r15), %rax
movq 0x10(%rax), %r12
movq %r12, %rdi
movl $0x1, %esi
callq 0x3d5c
movzbl %al, %edx
leaq 0x2bd3(%rip), %rsi      # 0xbff6
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r13, %rsi
callq 0x3eea
leaq 0x1b06(%rip), %r13      # 0xaf46
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2110
movq -0x38(%rbp), %rax
leaq 0x2c9e(%rip), %rbx      # 0xc0f5
movq %rbx, %rcx
movq %rbx, %rdx
testq %rax, %rax
je 0x9469
movq 0x10(%rax), %rdx
movq %r13, %rcx
leaq 0x2c0e(%rip), %rsi      # 0xc07e
movl -0x2c(%rbp), %r13d
movl %r13d, %edi
xorl %eax, %eax
callq 0x2110
xorl %eax, %eax
cmpq $0x2, %r14
setne %al
leaq 0x2b44(%rip), %rdx      # 0xbfd2
cmoveq %rbx, %rdx
movq 0x30(%r15,%rax,8), %rcx
incq %rcx
leaq 0x2b16(%rip), %rsi      # 0xbfb7
movl %r13d, %edi
xorl %eax, %eax
callq 0x2110
cmpq $0x2, %r12
jb 0x9522
xorl %eax, %eax
cmpq $0x2, %r14
setne %al
leaq 0x24(,%rax,4), %rbx
movl $0x1, %r13d
movq 0x28(%r15), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rax
cmpb $0x1, 0x22(%rax)
jne 0x951a
cmpq $0x3, %r14
jne 0x94e7
cmpl $-0x1, 0x28(%rax)
jne 0x94f3
jmp 0x951a
cmpq $0x2, %r14
jne 0x94f3
cmpl $-0x1, 0x24(%rax)
je 0x951a
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 0x2aca(%rip), %rsi      # 0xbfda
movq %r13, %rdx
xorl %eax, %eax
callq 0x2110
incq %r13
cmpq %r13, %r12
jne 0x94c8
leaq 0x2ac3(%rip), %rsi      # 0xbfec
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x2b19(%rip), %rsi      # 0xc055
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