// File: /workspace/github_c_makefile_star2_O3/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, -0x38(%rbp)
movq 0x28(%rsi), %rax
movq 0x10(%rax), %rdi
movq %rdi, -0x30(%rbp)
movl $0x1, %esi
callq 0x3d5c
movzbl %al, %edx
leaq 0x2eca(%rip), %rsi      # 0xbff6
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r15, %rsi
callq 0x3eea
leaq 0x1e00(%rip), %r15      # 0xaf46
movl %ebx, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2110
testq %r14, %r14
je 0x915d
movq 0x10(%r14), %rdx
jmp 0x9167
leaq 0x2f91(%rip), %r15      # 0xc0f5
movq %r15, %rdx
leaq 0x2f10(%rip), %rsi      # 0xc07e
movl %ebx, %edi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2110
leaq 0x2da7(%rip), %rsi      # 0xbf28
movl %ebx, %edi
movq -0x30(%rbp), %r14
movq %r14, %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0x2110
testq %r14, %r14
je 0x9272
xorl %r15d, %r15d
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rax
testq %rax, %rax
je 0x9242
movq 0x18(%rax), %r12
movl %ebx, %edi
leaq 0x2d7b(%rip), %rsi      # 0xbf42
movq %r15, %rdx
xorl %eax, %eax
callq 0x2110
testq %r12, %r12
jne 0x91eb
jmp 0x9255
movl %ebx, %edi
leaq 0x2d85(%rip), %rsi      # 0xbf66
xorl %eax, %eax
callq 0x2110
movq %r13, %r12
movq (%r12), %r13
movq %r12, %rdi
callq 0x3c6e
cmpq %r12, %rax
je 0x9221
movq %rax, %r14
movl 0x8(%rax), %edx
movl 0x8(%r12), %ecx
movl 0xc(%r12), %r8d
movl %ebx, %edi
leaq 0x2d3a(%rip), %rsi      # 0xbf4f
xorl %eax, %eax
callq 0x2110
movq (%r14), %r13
jmp 0x923b
movl 0x8(%r12), %edx
movl 0xc(%r12), %ecx
movl %ebx, %edi
leaq 0x2d2a(%rip), %rsi      # 0xbf5e
xorl %eax, %eax
callq 0x2110
testq %r13, %r13
jne 0x91d8
jmp 0x9255
movl %ebx, %edi
leaq 0x2cf7(%rip), %rsi      # 0xbf42
movq %r15, %rdx
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
leaq 0x2d49(%rip), %rsi      # 0xbfa7
xorl %eax, %eax
callq 0x2110
incq %r15
cmpq -0x30(%rbp), %r15
jne 0x91a2
leaq 0x2ddc(%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