// File: /workspace/github_c_makefile_star2_O1/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 0x3e58
movzbl %al, %edx
leaq 0x2d56(%rip), %rsi      # 0xbff6
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r15, %rsi
callq 0x3fe6
leaq 0x1c8c(%rip), %r15      # 0xaf46
movl %ebx, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2110
testq %r14, %r14
je 0x92d1
movq 0x10(%r14), %rdx
jmp 0x92db
leaq 0x2e1d(%rip), %r15      # 0xc0f5
movq %r15, %rdx
leaq 0x2d9c(%rip), %rsi      # 0xc07e
movl %ebx, %edi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2110
leaq 0x2c33(%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 0x93d9
leaq 0x2c4c(%rip), %r13      # 0xbf66
xorl %edx, %edx
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x9336
movq 0x18(%rax), %r12
jmp 0x9339
xorl %r12d, %r12d
movl %ebx, %edi
leaq 0x2c00(%rip), %rsi      # 0xbf42
movq %rdx, -0x40(%rbp)
xorl %eax, %eax
callq 0x2110
testq %r12, %r12
jne 0x9363
jmp 0x93b8
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2110
movq %r15, %r12
movq (%r12), %r15
movq %r12, %rdi
callq 0x3d6a
cmpq %r12, %rax
je 0x9399
movq %rax, %r14
movl 0x8(%rax), %edx
movl 0x8(%r12), %ecx
movl 0xc(%r12), %r8d
movl %ebx, %edi
leaq 0x2bc2(%rip), %rsi      # 0xbf4f
xorl %eax, %eax
callq 0x2110
movq (%r14), %r15
jmp 0x93b3
movl 0x8(%r12), %edx
movl 0xc(%r12), %ecx
movl %ebx, %edi
leaq 0x2bb2(%rip), %rsi      # 0xbf5e
xorl %eax, %eax
callq 0x2110
testq %r15, %r15
jne 0x9354
movl %ebx, %edi
leaq 0x2be6(%rip), %rsi      # 0xbfa7
xorl %eax, %eax
callq 0x2110
movq -0x40(%rbp), %rdx
incq %rdx
cmpq -0x30(%rbp), %rdx
jne 0x931c
leaq 0x2c75(%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