// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/dfa.c
// Function: build_state_table
static vector_t*
build_state_table(nfa_state_t* master) {
    vector_t* states = new_vector();
    
    PUSH_BACK_VECTOR(states, NULL_DFA_STATE); //  Dead State
    new_dfa_state(dup_bitset(master->eclos), states);
    
    size_t j = 1;
    size_t p = 1;

    while (j <= p) {
        dfa_state_t* crt_state = (dfa_state_t*)AT_VECTOR(states, j);
        for (size_t i = MIN_ASCII; i < MAX_ASCII; ++i) {
            bitset_t* next = dfa_edge(crt_state->set_state, i);
            if (next == NULL_BITSET)
                { continue; }

            size_t hash_new_set = hash_bitset(next);

            trans_list_t* new_trans_list = NEW(trans_list_t, 1);
            new_trans_list->input = i;

            size_t l = 1;
            for (; l <= p; ++l) {
                dfa_state_t* cmp_state = (dfa_state_t*)AT_VECTOR(states, l);
                if ((hash_new_set == cmp_state->hash_state)
                        && (eq_bitset(next, cmp_state->set_state)))
                    { break; }
            }
            if (l <= p) {
                new_trans_list->state = l;
                del_bitset(next);
            }
            else {
                new_trans_list->state = ++p;
                new_dfa_state(next, states);
            }
            new_trans_list->next = crt_state->trans;
            crt_state->trans = new_trans_list;
        }
        ++j;
    }

    return (states);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
callq 0x1f00
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2090
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1370
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb790
movq $0x1, -0x18(%rbp)
movq $0x1, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0xbc52
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0xbc41
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0xc580
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xbb4d
jmp 0xbc30
movq -0x38(%rbp), %rdi
callq 0x1bb0
movq %rax, -0x40(%rbp)
movl $0x10, %edi
callq 0x38d0
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq $0x1, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0xbbd1
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xbbc1
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1730
testb $0x1, %al
jne 0xbbbf
jmp 0xbbc1
jmp 0xbbd1
jmp 0xbbc3
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xbb7d
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0xbbf3
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rdi
callq 0x1320
jmp 0xbc15
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xb790
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xbb1c
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xbaf3
movq -0x10(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)