// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/fgfl/src/gen_dfa.c
// Function: gen_terminated_table
void
gen_terminated_table(int filde, lexical_spec_t const* spec,
                                            char const* header, size_t kind) {
    vector_t* dst_vect = new_vector();
    if (!dst_vect)
        { return; }

    for (size_t i = 0; i < SIZE_VECTOR(spec->entry_vect); ++i) {
        spec_entry_t* entry = (spec_entry_t*)AT_VECTOR(spec->entry_vect, i);
        if ((entry->kind == T_TERMINAL) && (!entry->fragment)) {
            if (kind == SKIP_TABLE && entry->must_skip)
                { PUSH_BACK_VECTOR(dst_vect, entry); }
            else if (kind == LOOK_TABLE && entry->use_look)
                { PUSH_BACK_VECTOR(dst_vect, entry); }
        }
    }

    size_t size_table = SIZE_VECTOR(dst_vect);
    if (size_table) {
        dprintf(filde, STATIC SP "int%u_t" NL,
                                min_size_type(size_table, false));

        gen_verbatim_file(filde, header);
        dprintf(filde, "_%s_table[%zu] = " BEG_BLOCK NL,
                ((kind == SKIP_TABLE) ? "skip" : "look"), size_table + 1);

        for (size_t i = 0; i < size_table; ++i) {
            spec_entry_t* entry = (spec_entry_t*)AT_VECTOR(dst_vect, i);
            dprintf(filde, TAB TOKEN_PREFIX SEP "%s" COMMA NL, entry->name);
        }
        dprintf(filde, TAB "-1" COMMA NL END_BLOCK SEMI NL NL);
    }
    else {
        dprintf(filde, DEFINE(%s_TABLE_NOT_DEFINE,) NL NL,
                                ((kind == SKIP_TABLE) ? "SKIP" : "LOOK"));
    }
    del_vector(dst_vect);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movl %edi, %r14d
callq 0x2924
testq %rax, %rax
je 0x918d
movq %rax, %rbx
movq %r12, -0x30(%rbp)
xorl %r12d, %r12d
movq 0x8(%r13), %rax
cmpq 0x10(%rax), %r12
jae 0x90ec
movq (%rax), %rax
movq (%rax,%r12,8), %rdx
cmpl $0x2d, 0x8(%rdx)
jne 0x90df
cmpb $0x0, 0x18(%rdx)
jne 0x90df
testq %r15, %r15
je 0x90e4
cmpq $0x1, %r15
jne 0x90df
cmpb $0x0, 0x1b(%rdx)
je 0x90df
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x2a16
incq %r12
jmp 0x90a5
cmpb $0x1, 0x1a(%rdx)
je 0x90d3
jmp 0x90df
movq 0x10(%rbx), %r13
testq %r13, %r13
je 0x919c
movq %r13, %rdi
xorl %esi, %esi
callq 0x39f8
movzbl %al, %edx
leaq 0x2ed1(%rip), %rsi      # 0xbfde
movl %r14d, %edi
xorl %eax, %eax
callq 0x2110
movl %r14d, %edi
movq -0x30(%rbp), %rsi
callq 0x3b77
cmpq $0x1, %r15
leaq 0x2ed4(%rip), %rax      # 0xc002
leaq 0x2ed2(%rip), %rdx      # 0xc007
cmoveq %rax, %rdx
leaq 0x1(%r13), %rcx
leaq 0x2eaa(%rip), %rsi      # 0xbfee
movl %r14d, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x2d0d(%rip), %r15      # 0xbe62
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x917a
movq (%rbx), %rax
movq (%rax,%r12,8), %rax
movq 0x10(%rax), %rdx
movl %r14d, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2110
incq %r12
jmp 0x9158
leaq 0x2e8b(%rip), %rsi      # 0xc00c
movl %r14d, %edi
xorl %eax, %eax
callq 0x2110
jmp 0x91c3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x1, %r15
leaq 0xf7e(%rip), %rax       # 0xa125
leaq 0x2e87(%rip), %rdx      # 0xc035
cmoveq %rax, %rdx
leaq 0x2e5d(%rip), %rsi      # 0xc016
movl %r14d, %edi
xorl %eax, %eax
callq 0x2110
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29c6