// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/fgfl/src/gen_dfa.c
// Function: gen_state_table
void
gen_state_table(int filde, lexical_spec_t const* spec,
                            char const* header, spec_entry_t const* state) {
    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, "state_table[%zu][%d] = "
                                    BEG_BLOCK NL, size_states, MAX_ASCII);

    for (size_t i = 0; i < size_states; ++i) {
        dfa_state_t* crt_state = (dfa_state_t*)AT_VECTOR(spec->states, i);
        trans_list_t const* list = ((crt_state)
                                ? crt_state->trans : NULL_TRANS_LST);

        dprintf(filde, "/* %3zu */" TAB BEG_BLOCK, i);
        while (list) {
            trans_list_t const* next = list->next;
            trans_list_t const* min_range = contiguous_range(list);
            if (min_range != list) {
                dprintf(filde, "[%u ... %u]=%u",
                            min_range->input, list->input, list->state);
                next = min_range->next;
            }
            else
                { dprintf(filde, "[%u]=%u", list->input, list->state); }
            if (next)
                { dprintf(filde, COMMA SP); }
            list = next;
        }
        dprintf(filde, 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 %rcx, %r14
movq %rdx, %r15
movl %edi, %ebx
movq %rsi, -0x30(%rbp)
movq 0x28(%rsi), %rax
movq 0x10(%rax), %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x39f8
movzbl %al, %edx
leaq 0x35fa(%rip), %rsi      # 0xbfb2
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r15, %rsi
callq 0x3b77
leaq 0x255b(%rip), %rsi      # 0xaf2d
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r14, %rsi
callq 0x8ae6
leaq 0x34f8(%rip), %rsi      # 0xbee4
movl %ebx, %edi
movq %r12, -0x38(%rbp)
movq %r12, %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0x2110
leaq 0x3503(%rip), %r14      # 0xbf0b
xorl %edx, %edx
cmpq -0x38(%rbp), %rdx
je 0x8ac8
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x8a2e
movq 0x18(%rax), %r15
jmp 0x8a31
xorl %r15d, %r15d
movl %ebx, %edi
leaq 0x34c4(%rip), %rsi      # 0xbefe
movq %rdx, -0x40(%rbp)
xorl %eax, %eax
callq 0x2110
testq %r15, %r15
je 0x8aac
movq (%r15), %r13
movq %r15, %rdi
callq 0x391b
cmpq %r15, %rax
je 0x8a7a
movq %rax, %r12
movl 0x8(%rax), %edx
movl 0x8(%r15), %ecx
movl 0xc(%r15), %r8d
movl %ebx, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2110
movq (%r12), %r15
jmp 0x8a95
movl 0x8(%r15), %edx
movl 0xc(%r15), %ecx
movl %ebx, %edi
leaq 0x348f(%rip), %rsi      # 0xbf1a
xorl %eax, %eax
callq 0x2110
movq %r13, %r15
testq %r15, %r15
je 0x8a45
movl %ebx, %edi
leaq 0x347f(%rip), %rsi      # 0xbf22
xorl %eax, %eax
callq 0x2110
jmp 0x8a45
movl %ebx, %edi
leaq 0x34ae(%rip), %rsi      # 0xbf63
xorl %eax, %eax
callq 0x2110
movq -0x40(%rbp), %rdx
incq %rdx
jmp 0x8a0a
leaq 0x3542(%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