// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/fgfl.c
// Function: gen_fgfl_file
static int 
gen_fgfl_file(lexical_spec_t* spec, char const* base_file) {
    char const* header = strjoin(base_file, ".h");
    int filde = open_new_file(header);

    if (filde == -1)
        { return (ERROR); }

    gen_require_macro(filde, base_file);

    bool active_state = (spec->start_state != -1);
    if (active_state)
        { gen_state_enum(filde, spec); }
 
    gen_token_enum(filde, spec);
    gen_token_name(filde, spec, header);

    if (!spec->miss_regex) {
        IFNDEF_ONLY_STATE_TOKEN(filde);
        if (active_state)
            { gen_action_state(filde, header, spec); }

        DFA_MACRO(filde);

        if (!active_state)
            { gen_dfa_final_tables(filde, spec, spec->master, header, NULL); }
        else {
            for (size_t i = 0; i < SIZE_VECTOR(spec->state_vect); ++i) {
                spec_entry_t* crt_state = (spec_entry_t*)
                                        AT_VECTOR(spec->state_vect, i);
                gen_dfa_final_tables(filde, spec,
                                crt_state->state_master, header, crt_state);
            }
        }

        del_nfa_record();

        GEN_LOOK_TABLE(filde, spec, header);
        GEN_SKIP_TABLE(filde, spec, header);

        ENDIF_ONLY_STATE_TOKEN(filde);
    }

    gen_endif(filde, base_file);
    FREE(header);

    if (close(filde) == -1)
        { return (ERROR); }

    return (DONE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x9dcc(%rip), %rsi      # 0xe3b7
callq 0x3820
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3e90
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x4612
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x47a6
movl -0x24(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x4090
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
setne %al
andb $0x1, %al
movb %al, -0x25(%rbp)
testb $0x1, -0x25(%rbp)
je 0x4640
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xc650
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xc770
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xc860
movq -0x10(%rbp), %rax
testb $0x1, 0x1c(%rax)
jne 0x4774
movl -0x24(%rbp), %edi
leaq 0x9d46(%rip), %rsi      # 0xe3ba
movb $0x0, %al
callq 0x10d0
testb $0x1, -0x25(%rbp)
je 0x4691
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0xcf00
movl -0x24(%rbp), %edi
leaq 0x9d3c(%rip), %rsi      # 0xe3d7
movb $0x0, %al
callq 0x10d0
movl -0x24(%rbp), %edi
leaq 0x9d42(%rip), %rsi      # 0xe3ee
movb $0x0, %al
callq 0x10d0
testb $0x1, -0x25(%rbp)
jne 0x46d8
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x20(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x47b0
jmp 0x4735
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jae 0x4733
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x47b0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x46e0
jmp 0x4735
callq 0x6380
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0xd2e0
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0x1, %ecx
callq 0xd2e0
movl -0x24(%rbp), %edi
leaq 0x9c98(%rip), %rsi      # 0xe405
movb $0x0, %al
callq 0x10d0
movl -0x24(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x4120
movq -0x20(%rbp), %rdi
callq 0x1030
movl -0x24(%rbp), %edi
callq 0x10c0
cmpl $-0x1, %eax
jne 0x479f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x47a6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop