// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x3, -0x28(%rbp)
jne 0xcd32
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0xcd32
jmp 0xceeb
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x3f70
movl -0x58(%rbp), %edi
movzbl %al, %edx
leaq 0x265f(%rip), %rsi      # 0xf3c2
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x4170
movl -0x4(%rbp), %edi
leaq 0x1576(%rip), %rsi      # 0xe2f6
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0xcb50
movl -0x4(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rdx
leaq 0x271d(%rip), %rax      # 0xf4c1
leaq 0x25f3(%rip), %rcx      # 0xf39e
cmpq $0x2, %rdx
cmovneq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpq $0x2, -0x28(%rbp)
je 0xcdcc
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xcdd8
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rdx
movl -0x54(%rbp), %edi
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
leaq 0x2595(%rip), %rsi      # 0xf383
movb $0x0, %al
callq 0x10d0
movq $0x1, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xcec9
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0x22(%rax)
jne 0xce31
jmp 0xceb8
cmpq $0x3, -0x28(%rbp)
jne 0xce44
movq -0x40(%rbp), %rax
cmpl $-0x1, 0x28(%rax)
jne 0xce44
jmp 0xceb8
cmpq $0x2, -0x28(%rbp)
jne 0xce57
movq -0x40(%rbp), %rax
cmpl $-0x1, 0x24(%rax)
jne 0xce57
jmp 0xceb8
jmp 0xce59
jmp 0xce5b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x2, -0x28(%rbp)
je 0xce7f
movq -0x40(%rbp), %rax
movslq 0x28(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0xce8b
movq -0x40(%rbp), %rax
movslq 0x24(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl -0x4(%rbp), %edi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x24f5(%rip), %rsi      # 0xf3a6
movb $0x0, %al
callq 0x10d0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xcdfd
movl -0x4(%rbp), %edi
leaq 0x24e5(%rip), %rsi      # 0xf3b8
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
leaq 0x253d(%rip), %rsi      # 0xf421
movb $0x0, %al
callq 0x10d0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)