// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebx
movq 0x8(%rdx), %rax
movq 0x10(%rdx), %rcx
movq 0x10(%rax), %r12
movq 0x10(%rcx), %rax
movq %rax, -0x48(%rbp)
leaq 0x3057(%rip), %rsi      # 0xbe08
xorl %eax, %eax
callq 0x2110
leaq 0x3280(%rip), %rsi      # 0xc03f
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x3283(%rip), %rsi      # 0xc052
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x3285(%rip), %rsi      # 0xc064
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x3222(%rip), %rsi      # 0xc011
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x3275(%rip), %rsi      # 0xc074
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq 0x3284(%rip), %rsi      # 0xc093
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
pushq $0x1
popq %rsi
movl $0x4000, %edi           # imm = 0x4000
callq 0x39f8
movzbl %al, %edx
leaq 0x3182(%rip), %rsi      # 0xbfb1
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
movl %ebx, %edi
movq %r15, %rsi
callq 0x3b77
leaq 0x317a(%rip), %rsi      # 0xbfc3
leaq 0x302b(%rip), %rdx      # 0xbe7b
leaq 0x2fe0(%rip), %rcx      # 0xbe37
movl %ebx, %edi
xorl %eax, %eax
callq 0x2110
leaq -0x29(%rbp), %r15
xorl %ecx, %ecx
movq %r12, -0x38(%rbp)
cmpq %r12, %rcx
je 0x8f5c
movq 0x8(%r14), %rax
movq (%rax), %rax
movq (%rax,%rcx,8), %r13
cmpl $0x2d, 0x8(%r13)
jne 0x8f54
movq %rcx, -0x40(%rbp)
movb $0x0, -0x29(%rbp)
movl 0x30(%r13), %ecx
cmpl $-0x1, %ecx
je 0x8ed6
cmpb $0x1, 0x34(%r13)
jne 0x8f13
xorl %r12d, %r12d
cmpq %r12, -0x48(%rbp)
je 0x8f36
movq 0x10(%r14), %rax
movq (%rax), %rax
movq (%rax,%r12,8), %rax
movl 0x30(%r13), %ecx
movq 0x10(%rax), %r9
movl %ebx, %edi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %r8
callq 0x8f7a
incq %r12
jmp 0x8ea4
leaq 0x38(%r13), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x8f36
movl 0xc(%r12), %ecx
cmpl $-0x1, %ecx
je 0x8eda
movq 0x10(%r14), %rax
movq (%rax), %rax
movslq 0x8(%r12), %rdx
movq (%rax,%rdx,8), %rax
movq 0x10(%rax), %r9
movl %ebx, %edi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %r8
callq 0x8f7a
jmp 0x8eda
movq 0x10(%r14), %rax
movq (%rax), %rax
movslq 0x18(%r14), %rdx
movq (%rax,%rdx,8), %rax
movq 0x10(%rax), %r9
movl %ebx, %edi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %r8
callq 0x8f7a
cmpb $0x1, -0x29(%rbp)
jne 0x8f4c
movl %ebx, %edi
leaq 0x30ee(%rip), %rsi      # 0xc033
xorl %eax, %eax
callq 0x2110
movq -0x38(%rbp), %r12
movq -0x40(%rbp), %rcx
incq %rcx
jmp 0x8e6a
leaq 0x30ae(%rip), %rsi      # 0xc011
movl %ebx, %edi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110