// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/dfa_minimization.c
// Function: minimizing_dfa
void
minimizing_dfa(lexical_spec_t* spec) {
    if (!spec)
        { return; }
    vector_t* groups = init_groups(spec);

    int next_group_id = SIZE_VECTOR(groups);
    bool change;

    do {
        change = false;

        bitset_t* new_group = NULL_BITSET;
        ++next_group_id;

        for (int i = SIZE_VECTOR(groups) - 1; i >= 0; --i) {
            bitset_t* crt_group = (bitset_t*)AT_VECTOR(groups, (size_t)i);
            if (count_elt_bitset(crt_group) == 1)
                { continue; }

            int first = IT_NEXT(crt_group);
            int next;

            while ((next = IT_NEXT(crt_group)) != IT_NULL) {
                dfa_state_t* first_st = DFA_STATE_AT(spec, first);
                dfa_state_t* next_st = DFA_STATE_AT(spec, next);

                for (size_t j = MIN_ASCII; j < MAX_ASCII; ++j) {
                    int first_i = input_to_state(first_st->trans, j);
                    int next_i = input_to_state(next_st->trans, j);

                    if (first_i != next_i) {
                        dfa_state_t* first_out = DFA_STATE_AT(spec, first_i);
                        dfa_state_t* next_out = DFA_STATE_AT(spec, next_i);

                        if ((!first_out || !next_out)
                                || (first_out->group != next_out->group)) {
                            next_st->group = next_group_id;

                            if (!new_group) {
                                new_group = new_bitset();
                                change = true;
                            }

                            ADD_BITSET(new_group, (size_t)next);
                            OFF_BITSET(crt_group, (size_t)next);

                            break;
                        }
                    }
                }
            }
            IT_RESET(crt_group);
        }
        if (new_group)
            { PUSH_BACK_VECTOR(groups, new_group); }
    } while (change);
    merge_dfa_state(spec, groups);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x9498
jmp 0x972c
movq -0x8(%rbp), %rdi
callq 0x9740
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movq $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
subq $0x1, %rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x96f7
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1e10
cmpq $0x1, %rax
jne 0x9505
jmp 0x96e9
movq -0x30(%rbp), %rdi
callq 0x1ac0
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1ac0
movl %eax, -0x38(%rbp)
cmpl $-0x1, %eax
je 0x96ad
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x100, -0x50(%rbp)     # imm = 0x100
jae 0x96a8
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x9a40
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x9a40
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x9695
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x95ee
cmpq $0x0, -0x68(%rbp)
je 0x95ee
movq -0x60(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x68(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
je 0x9693
movl -0x14(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x2c(%rax)
cmpq $0x0, -0x20(%rbp)
jne 0x960c
callq 0x12b0
movq %rax, -0x20(%rbp)
movb $0x1, -0x15(%rbp)
movslq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x962b
movq -0x20(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x1440
jmp 0x9653
movslq -0x38(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
shrq $0x6, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movslq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jb 0x9665
jmp 0x9691
movslq -0x38(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
xorq $-0x1, %rdx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
shrq $0x6, %rcx
andq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x96a8
jmp 0x9695
jmp 0x9697
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x955c
jmp 0x9511
cmpq $0x0, -0x30(%rbp)
jne 0x96b6
jmp 0x96e9
movq -0x30(%rbp), %rax
testb $0x1, 0x54(%rax)
jne 0x96d2
movq -0x30(%rbp), %rax
movl $0x0, 0x50(%rax)
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x96e6
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movq -0x30(%rbp), %rcx
movl %eax, 0x50(%rcx)
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x94d4
cmpq $0x0, -0x20(%rbp)
je 0x9713
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x2090
jmp 0x9715
testb $0x1, -0x15(%rbp)
jne 0x94b0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9a90
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)