// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/tools/src/lexer.c
// Function: get_next_token
static int
get_next_token(lexer_t* lex) {
    (void)fgfx_look_table;

    static uint8_t (*state_table)[256] = NULL;
    static uint8_t (*final_table)[2] = NULL;

    static bool need_recompute = true;

    if (need_recompute) {
        change_lexer_state(lex, &state_table, &final_table);
        need_recompute = false;
    }

    int state = START_STATE;
    int last_match = is_final_state(START_STATE, final_table);

    int rd = 0;

    size_t read_char = 0;
    size_t pos_last_match = 0;

    size_t i;
    size_t buff_look = 0;
    for (i = 0; i < SIZE_BUFFER(lex->push_back); ++i) {
        int char_at = CHAR_AT(lex->push_back, i);
        ++read_char;

        state = state_table[state][char_at];

        if (state == DEAD_STATE)
            { break; }
        else { 
            if (char_at == '\n')
                { ++(lex->lineno); }
            if (is_final_state(state, final_table) != T_ERROR) {
                last_match = is_final_state(state, final_table);
                pos_last_match = read_char;
            }

            if (must_look_ahead(lex->crt_state, state) && !buff_look)
                { buff_look = i; }
        }
    }

    move_front_buffer(lex->last_lexeme, lex->push_back,
                                            pos_last_match - buff_look);
    if (state != DEAD_STATE)
        { move_front_buffer(lex->last_lexeme, lex->push_back, i); }

    int first_read = true;
    bool unget_input = false;

    while (state != DEAD_STATE) {
        int exit_st = read(lex->filde, &rd, 1);
        ++read_char;

        if (!exit_st) {
            if (first_read) {
                if (EMPTY_VECTOR(lex->stack_state))
                    { return (T_EOF); }

                errorf(0, "The input is terminated but many "
                                            "states still live on the stack.");
                return (T_ERROR);
            }
            break;
        }

        // Change state
        state = state_table[state][rd];
        if (is_final_state(state, final_table) != T_ERROR) {
            last_match = is_final_state(state, final_table);
            pos_last_match = read_char;
        }

        if (!unget_input && must_look_ahead(lex->crt_state, state))
            { unget_input = true; }

        // Write on buffer
        if (unget_input)
            { write_char_buffer(lex->push_back, rd); }
        else {
            if ((rd == '\n') && (state != DEAD_STATE))
                { ++(lex->lineno); }
            write_char_buffer(lex->last_lexeme, rd);
        }

        first_read = false;
    }

    if (last_match == T_ERROR) {
        char const* error_str = C_LEXEME(lex);
        if (!strcmp(error_str, "\n"))
            { error_str = "\\n"; }

        errorf(CURRENT_LINE(lex),
                        "Lexical error on input '%s'.", error_str);
    }
    else if (!first_read) {
        if (!unget_input) {
            move_back_buffer(lex->push_back,
                            lex->last_lexeme, read_char - pos_last_match);
        }
    }

    change_state(lex, last_match, &need_recompute);
    return (last_match);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
testb $0x1, 0xe531(%rip)      # 0x114b4
je 0x2fa3
movq -0x10(%rbp), %rdi
leaq 0x1ce08(%rip), %rsi     # 0x1fd98
leaq 0x1ce09(%rip), %rdx     # 0x1fda0
callq 0x3460
movb $0x0, 0xe511(%rip)      # 0x114b4
movl $0x1, -0x14(%rbp)
movq 0x1cdef(%rip), %rsi     # 0x1fda0
movl $0x1, %edi
callq 0x3600
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpq 0x10(%rcx), %rax
jae 0x30c0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq 0x1cd74(%rip), %rax     # 0x1fd98
movslq -0x14(%rbp), %rcx
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x3042
jmp 0x30c0
cmpl $0xa, -0x44(%rbp)
jne 0x3055
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movl -0x14(%rbp), %edi
movq 0x1cd41(%rip), %rsi     # 0x1fda0
callq 0x3600
cmpq $0x6f, %rax
je 0x3084
movl -0x14(%rbp), %edi
movq 0x1cd2c(%rip), %rsi     # 0x1fda0
callq 0x3600
movl %eax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, %edi
movl -0x14(%rbp), %esi
callq 0x3670
testb $0x1, %al
jne 0x309c
jmp 0x30ab
cmpq $0x0, -0x40(%rbp)
jne 0x30ab
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x30ad
jmp 0x30af
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2fe5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rdx
subq -0x40(%rbp), %rdx
callq 0x2ab0
cmpl $0x0, -0x14(%rbp)
je 0x30fc
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x38(%rbp), %rdx
callq 0x2ab0
movl $0x1, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x323f
movq -0x10(%rbp), %rax
movl (%rax), %edi
leaq -0x1c(%rbp), %rsi
movl $0x1, %edx
callq 0x10e0
movl %eax, -0x50(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x50(%rbp)
jne 0x317e
cmpl $0x0, -0x48(%rbp)
je 0x3179
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x315b
movl $0x70, -0x4(%rbp)
jmp 0x32d6
xorl %eax, %eax
movl %eax, %edi
leaq 0x90da(%rip), %rsi      # 0xc240
movb $0x0, %al
callq 0x4210
movl $0x6f, -0x4(%rbp)
jmp 0x32d6
jmp 0x323f
movq 0x1cc13(%rip), %rax     # 0x1fd98
movslq -0x14(%rbp), %rcx
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edi
movq 0x1cbfb(%rip), %rsi     # 0x1fda0
callq 0x3600
cmpq $0x6f, %rax
je 0x31ca
movl -0x14(%rbp), %edi
movq 0x1cbe6(%rip), %rsi     # 0x1fda0
callq 0x3600
movl %eax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
testb $0x1, -0x49(%rbp)
jne 0x31ec
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, %edi
movl -0x14(%rbp), %esi
callq 0x3670
testb $0x1, %al
jne 0x31e8
jmp 0x31ec
movb $0x1, -0x49(%rbp)
testb $0x1, -0x49(%rbp)
je 0x3207
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x1c(%rbp), %eax
movsbl %al, %esi
callq 0x2660
jmp 0x3233
cmpl $0xa, -0x1c(%rbp)
jne 0x3220
cmpl $0x0, -0x14(%rbp)
je 0x3220
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x1c(%rbp), %eax
movsbl %al, %esi
callq 0x2660
movl $0x0, -0x48(%rbp)
jmp 0x3107
cmpl $0x6f, -0x18(%rbp)
jne 0x3290
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq 0x9baf(%rip), %rsi      # 0xce0e
callq 0x10f0
cmpl $0x0, %eax
jne 0x3274
leaq 0x9011(%rip), %rax      # 0xc281
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rdi
movq -0x58(%rbp), %rdx
leaq 0x8ffd(%rip), %rsi      # 0xc284
movb $0x0, %al
callq 0x4210
jmp 0x32bd
cmpl $0x0, -0x48(%rbp)
jne 0x32bb
testb $0x1, -0x49(%rbp)
jne 0x32b9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x28(%rbp), %rdx
subq -0x30(%rbp), %rdx
callq 0x2a10
jmp 0x32bb
jmp 0x32bd
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq 0xe1e9(%rip), %rdx      # 0x114b4
callq 0x36d0
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop