// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/dfa.c
// Function: build_final_table
static void
build_final_table(vector_t* states) {
    for (size_t i = 1; i < SIZE_VECTOR(states); ++i) {
        dfa_state_t* crt_state = (dfa_state_t*)AT_VECTOR(states, i);

        int min_final = NO_FINAL;
        int min_anchor = NO_FINAL;

        int it;
        while ((it = IT_NEXT(crt_state->set_state)) != IT_NULL) {
            nfa_state_t* nfa_state = NFA_STATE_AT(it);

            if (nfa_state->final_type != NO_FINAL) {
                if ((!nfa_state->is_anchor) && ((min_final == NO_FINAL)
                                || (min_final > nfa_state->final_type)))
                    { min_final = nfa_state->final_type; }
                else if ((nfa_state->is_anchor) && ((min_anchor == NO_FINAL)
                                || (min_anchor > nfa_state->final_type)))
                    { min_anchor = nfa_state->final_type; }
            }
        }
        IT_RESET(crt_state->set_state);

        if ((min_final != NO_FINAL) || (min_anchor != NO_FINAL)) {
            crt_state->final_entry = min_final;
            if ((min_final == NO_FINAL) || (min_anchor <= min_final))
                { crt_state->final_anchor_entry = min_anchor; }

            crt_state->is_final = true;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x1, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xbedf
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1ac0
movl %eax, -0x24(%rbp)
cmpl $-0x1, %eax
je 0xbe46
leaq 0x15fdd(%rip), %rax     # 0x21db0
movq (%rax), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0xbe41
movq -0x30(%rbp), %rax
testb $0x1, 0xc(%rax)
jne 0xbe17
cmpl $-0x1, -0x1c(%rbp)
je 0xbe0b
movl -0x1c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0xbe17
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0xbe3f
movq -0x30(%rbp), %rax
testb $0x1, 0xc(%rax)
je 0xbe3d
cmpl $-0x1, -0x20(%rbp)
je 0xbe33
movl -0x20(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0xbe3d
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0xbe3f
jmp 0xbe41
jmp 0xbdb7
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xbe53
jmp 0xbe96
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
testb $0x1, 0x54(%rax)
jne 0xbe77
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x50(%rax)
xorl %eax, %eax
movl %eax, -0x34(%rbp)
jmp 0xbe93
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl %eax, 0x50(%rcx)
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl $-0x1, -0x1c(%rbp)
jne 0xbea2
cmpl $-0x1, -0x20(%rbp)
je 0xbecc
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
cmpl $-0x1, -0x1c(%rbp)
je 0xbeba
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0xbec4
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x22(%rax)
jmp 0xbece
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xbd84
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)