// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/gen_dfa.c
// Function: gen_action_state
void
gen_action_state(int filde, char const* header, lexical_spec_t* spec) {
    size_t size_entry = SIZE_VECTOR(spec->entry_vect);
    size_t size_state = SIZE_VECTOR(spec->state_vect);

    gen_action_state_enum_macro(filde);
    dprintf(filde, NL STATIC SP "uint%u_t" NL, min_size_type(0x4000, true));

    gen_verbatim_file(filde, header);
    dprintf(filde, "_action_table[%s][%s] = "
                                BEG_BLOCK NL, MACRO_TOKEN, MACRO_STATE);

    for (size_t i = 0; i < size_entry; ++i) {
        spec_entry_t* crt_entry = (spec_entry_t*)AT_VECTOR(spec->entry_vect, i);
        if (crt_entry->kind != T_TERMINAL)
            { continue; }

        bool already_print = false;
        if (crt_entry->default_action != NONE_ACTION) {
            spec_entry_t* crt_state = (spec_entry_t*)
                            AT_VECTOR(spec->state_vect, spec->start_state);

            if (crt_entry->all_state) {
                for (size_t j = 0; j < size_state; ++j) {
                    crt_state = (spec_entry_t*)AT_VECTOR(spec->state_vect, j);
                    gen_action_entry(filde, spec, crt_entry,
                                    crt_entry->default_action, &already_print,
                                    crt_state->name);
                }
            }
            else {
                gen_action_entry(filde, spec, crt_entry,
                    crt_entry->default_action, &already_print, crt_state->name);
            }
        }
        else {
            trans_list_t* it_lst = crt_entry->state_lst;
            while (it_lst) {
                if (it_lst->state != NONE_STATE) {
                    spec_entry_t* in_state = ((spec_entry_t*)AT_VECTOR(
                            spec->state_vect, (size_t)it_lst->input));

                    gen_action_entry(filde, spec, crt_entry, it_lst->state, 
                                        &already_print, in_state->name);
                }
                it_lst = it_lst->next;
            }
        }
        if (already_print)
            { dprintf(filde, 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 -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x4(%rbp), %edi
callq 0xd130
movl -0x4(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x4000, %edi           # imm = 0x4000
movl $0x1, %esi
callq 0x3f70
movl -0x64(%rbp), %edi
movzbl %al, %edx
leaq 0x2464(%rip), %rsi      # 0xf3c1
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x4170
movl -0x4(%rbp), %edi
leaq 0x2459(%rip), %rsi      # 0xf3d3
leaq 0x230a(%rip), %rdx      # 0xf28b
leaq 0x22bf(%rip), %rcx      # 0xf247
movb $0x0, %al
callq 0x10d0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xd117
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x2d, 0x8(%rax)
je 0xcfcb
jmp 0xd106
movb $0x0, -0x39(%rbp)
movq -0x38(%rbp), %rax
cmpl $-0x1, 0x30(%rax)
je 0xd083
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
testb $0x1, 0x34(%rax)
je 0xd05e
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xd05c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x38(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x48(%rbp), %rax
movq 0x10(%rax), %r9
leaq -0x39(%rbp), %r8
callq 0xd1c0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xd00a
jmp 0xd081
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x38(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x48(%rbp), %rax
movq 0x10(%rax), %r9
leaq -0x39(%rbp), %r8
callq 0xd1c0
jmp 0xd0ed
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xd0eb
movq -0x58(%rbp), %rax
cmpl $-0x1, 0xc(%rax)
je 0xd0de
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x58(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x58(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x60(%rbp), %rax
movq 0x10(%rax), %r9
leaq -0x39(%rbp), %r8
callq 0xd1c0
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xd08f
jmp 0xd0ed
testb $0x1, -0x39(%rbp)
je 0xd104
movl -0x4(%rbp), %edi
leaq 0x2346(%rip), %rsi      # 0xf443
movb $0x0, %al
callq 0x10d0
jmp 0xd106
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xcf97
movl -0x4(%rbp), %edi
leaq 0x2300(%rip), %rsi      # 0xf421
movb $0x0, %al
callq 0x10d0
addq $0x70, %rsp
popq %rbp
retq
nop