// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/lexical_spec.c
// Function: spec_state_prefix
int
spec_state_prefix(lexical_spec_t* spec,
                                trans_list_t** state_seen, bool* all_state) {
    if (peek_token(spec->lex) == T_LPAREN) {
        trans_list_t* state_lst = NULL;
        advance_token(spec->lex);

        if (peek_token(spec->lex) == T_STAR) {
            (*all_state) = true;
            advance_token(spec->lex);
        }
        else if (peek_token(spec->lex) == T_TERMINAL) {
            while (peek_token(spec->lex) == T_TERMINAL) {
                advance_token(spec->lex);

                spec_entry_t* crt_state = add_entry_lexeme(spec, T_STATE);
                if (!crt_state) {
                    del_trans_list(state_lst);
                    return (ERROR);
                }
                crt_state->is_used = true;

                if (cmp_input_trans_list(state_lst,
                                                GET_INDEX(crt_state)) != -1) {
                    warnf(CURRENT_LINE(spec->lex),
                                "State %s already present in the state list.",
                                crt_state->name);
                }
                trans_list_t* new_lst = new_trans_list(GET_INDEX(crt_state),
                                            NONE_STATE, NULL_TRANS_LST);
                if (!state_lst)
                    { state_lst = new_lst; }
                else
                    { append_trans_list(state_lst, new_lst); }

                if (peek_token(spec->lex) == T_COMMA)
                    { advance_token(spec->lex); }
            }
        }
        else {
            errorf(CURRENT_LINE(spec->lex),
                    "Only a state list or the '*' must follow the open paren.");
            return (ERROR);
        }

        if (advance_token(spec->lex) != T_RPAREN) {
            errorf(CURRENT_LINE(spec->lex),
                    "Missing a close paren after the state list.");
            del_trans_list(state_lst);
            return (ERROR);
        }
        (*state_seen) = state_lst;
    }
    return (DONE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3300
cmpl $0x34, %eax
jne 0x55e5
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cc0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3300
cmpl $0x1, %eax
jne 0x5476
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cc0
jmp 0x559d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3300
cmpl $0x2d, %eax
jne 0x5579
jmp 0x548d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3300
cmpl $0x2d, %eax
jne 0x5577
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cc0
movq -0x10(%rbp), %rdi
movl $0x43, %esi
callq 0x5600
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x54dc
movq -0x28(%rbp), %rdi
callq 0x3c00
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x55ec
movq -0x30(%rbp), %rax
movb $0x1, 0xc(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl %eax, %esi
callq 0x3ca0
cmpl $-0x1, %eax
je 0x551c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x28(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x9024(%rip), %rsi      # 0xe539
movb $0x0, %al
callq 0x43e0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x3a10
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5548
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x5555
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3b20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3300
cmpl $0x31, %eax
jne 0x5572
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cc0
jmp 0x548d
jmp 0x559b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x8fda(%rip), %rsi      # 0xe565
movb $0x0, %al
callq 0x4230
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x55ec
jmp 0x559d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cc0
cmpq $0x35, %rax
je 0x55da
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x8fdd(%rip), %rsi      # 0xe59e
movb $0x0, %al
callq 0x4230
movq -0x28(%rbp), %rdi
callq 0x3c00
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x55ec
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)