// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/tools/src/lexer.c
// Function: advance_token
long
advance_token(lexer_t* lex) {
    if (!lex)
        { return (ERROR); }
    long found_token;
    if (lex->last_token != -1)
        { found_token = lex->last_token; }
    else {
        reset_buffer(lex->last_lexeme);
        while (1) {
            found_token = get_next_token(lex);
            if (!check_present_table(fgfx_skip_table, found_token))
                { break; }
            reset_buffer(lex->last_lexeme);
        }
    }

    if (found_token == T_DIRECTIVE) {
        static void* directive_tab[][2] = {
            { (void*)T_SKIP,        "$SKIP" },
            { (void*)T_TOKEN,       "$TOKEN" },
            { (void*)T_KEYWORD,     "$KEYWORD" },
            { (void*)T_STATE,       "$STATE" },
            { (void*)T_BEGIN,       "$BEGIN" },
            { (void*)T_PUSH,        "$PUSH" },
            { (void*)T_POP,         "$POP" },
            { (void*)T_FRAGMENT,    "$FRAGMENT" },
            { (void*)T_INITIAL,     "$INITIAL" },
            { (void*)T_EXTERN,      "$EXTERN" },
            { (void*)T_ALIAS,       "$ALIAS" },
            { (void*)T_PRODUCTION,  "$PRODUCTION" },
            { (void*)T_PRECEDENCE,  "$PRECEDENCE" },
            { (void*)T_MIMIC,       "$MIMIC" },
            { (void*)T_EMPTY,       "$EMPTY" },
            { (void*)T_START,       "$START" },
            { (void*)T_LEFT,        "$LEFT" },
            { (void*)T_RIGHT,       "$RIGHT" },
            { (void*)T_NONASSOC,    "$NONASSOC" },
            { (void*)T_STAY,        "$STAY" },
        };
        for (size_t i = 0; i < *(&directive_tab + 1) - directive_tab; ++i) {
            if (!strcmp(C_LEXEME(lex), directive_tab[i][1]))
                { return ((long)*directive_tab[i]); }
        }
        errorf(CURRENT_LINE(lex), "Bad directive %s.", C_LEXEME(lex));
        return (T_ERROR);
    }
    else if (found_token == T_CCE) {
        static void* cce_tab[][2] = {
            { (void*)T_CCE_ALNUM,   "[:alnum:]"  },
            { (void*)T_CCE_ALPHA,   "[:alpha:]"  },
            { (void*)T_CCE_CNTRL,   "[:cntrl:]"  },
            { (void*)T_CCE_DIGIT,   "[:digit:]"  },
            { (void*)T_CCE_GRAPH,   "[:graph:]"  },
            { (void*)T_CCE_LOWER,   "[:lower:]"  },
            { (void*)T_CCE_PRINT,   "[:print:]"  },
            { (void*)T_CCE_PUNCT,   "[:punct:]"  },
            { (void*)T_CCE_SPACE,   "[:space:]"  },
            { (void*)T_CCE_BLANK,   "[:blank:]"  },
            { (void*)T_CCE_UPPER,   "[:upper:]"  },
            { (void*)T_CCE_XDIGIT,  "[:xdigit:]" },
        };
        for (size_t i = 0; i < *(&cce_tab + 1) - cce_tab; ++i) {
            if (!strcmp(C_LEXEME(lex), cce_tab[i][1]))
                { return ((long)*cce_tab[i]); }
        }
        errorf(CURRENT_LINE(lex),
                        "Bad character class expression %s.", C_LEXEME(lex));
        return (T_ERROR);
    }
    else if (found_token == T_N_CCE) {
        static void* n_cce_tab[][2] = {
            { (void*)T_N_CCE_ALNUM,     "[:^alnum:]"  },
            { (void*)T_N_CCE_ALPHA,     "[:^alpha:]"  },
            { (void*)T_N_CCE_CNTRL,     "[:^cntrl:]"  },
            { (void*)T_N_CCE_DIGIT,     "[:^digit:]"  },
            { (void*)T_N_CCE_GRAPH,     "[:^graph:]"  },
            { (void*)T_N_CCE_LOWER,     "[:^lower:]"  },
            { (void*)T_N_CCE_PRINT,     "[:^print:]"  },
            { (void*)T_N_CCE_PUNCT,     "[:^punct:]"  },
            { (void*)T_N_CCE_SPACE,     "[:^space:]"  },
            { (void*)T_N_CCE_BLANK,     "[:^blank:]"  },
            { (void*)T_N_CCE_UPPER,     "[:^upper:]"  },
            { (void*)T_N_CCE_XDIGIT,    "[:^xdigit:]" },
        };
        for (size_t i = 0; i < *(&n_cce_tab + 1) - n_cce_tab; ++i) {
            if (!strcmp(C_LEXEME(lex), n_cce_tab[i][1]))
                { return ((long)*n_cce_tab[i]); }
        }
        errorf(CURRENT_LINE(lex),
                    "Bad negate character class expression %s.", C_LEXEME(lex));
        return (T_ERROR);
    }
    lex->last_token = -1;
    return (found_token);
}

// Assembly:
testq %rdi, %rdi
je 0x30ad
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %r13d
cmpl $-0x1, %r13d
movq %rdi, -0x30(%rbp)
je 0x30b1
cmpl $0x1b, %r13d
je 0x348b
cmpl $0x2c, %r13d
je 0x3457
cmpl $0x1c, %r13d
jne 0x34c3
movq 0x10(%rbx), %rax
movq (%rax), %rbx
pushq $-0x10
popq %rcx
leaq 0xbbcd(%rip), %r14      # 0xec50
leaq 0x10(%rcx), %r15
cmpq $0xc0, %r15
je 0x34ee
movq 0x18(%rcx,%r14), %rsi
movq %rbx, %rdi
callq 0x2120
movq %r15, %rcx
testl %eax, %eax
jne 0x3083
jmp 0x34bd
pushq $-0x1
popq %rax
retq
leaq 0x10(%rbx), %r14
movq 0x10(%rbx), %rdi
callq 0x2e51
leaq 0x8(%rbx), %rax
movq %rax, -0x60(%rbp)
movq %r14, -0x40(%rbp)
cmpb $0x0, 0x19dc7(%rip)     # 0x1ce98
jne 0x310e
movq 0x20(%rbx), %rax
leaq -0x1(%rax), %rcx
cmpq $0xa, %rcx
ja 0x3107
leaq 0xbc28(%rip), %rcx      # 0xed10
movq -0x8(%rcx,%rax,8), %rcx
leaq 0xbc74(%rip), %rdx      # 0xed68
movq -0x8(%rdx,%rax,8), %rax
movq %rcx, 0x19d88(%rip)     # 0x1ce88
movq %rax, 0x19d89(%rip)     # 0x1ce90
movb $0x1, 0x19d8a(%rip)     # 0x1ce98
movq 0x19d7b(%rip), %rsi     # 0x1ce90
pushq $0x1
popq %r14
movl %r14d, %edi
movq %rsi, -0x78(%rbp)
callq 0x3605
andl $0x0, -0x54(%rbp)
movq %rax, %r15
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x19d42(%rip), %rax     # 0x1ce88
movq %rax, -0x80(%rbp)
xorl %r13d, %r13d
movq $0x0, -0x48(%rbp)
xorl %esi, %esi
cmpq %r13, -0x38(%rbp)
movq %r15, -0x70(%rbp)
je 0x31e6
movq -0x68(%rbp), %rax
movq (%rax), %rax
movsbq (%rax,%r13), %rax
movl %r14d, %ecx
shlq $0x8, %rcx
addq -0x80(%rbp), %rcx
movzbl (%rax,%rcx), %r14d
testl %r14d, %r14d
movq -0x30(%rbp), %rbx
je 0x31f0
movq %rsi, -0x50(%rbp)
cmpb $0xa, %al
jne 0x3195
incl 0x28(%rbx)
movq %rbx, %r12
leaq 0x1(%r13), %rbx
movl %r14d, %edi
movq -0x78(%rbp), %rsi
callq 0x3605
movq %rax, %r15
cmpq $0x6f, %rax
movq -0x48(%rbp), %rax
cmovneq %rbx, %rax
movq %rax, -0x48(%rbp)
cmovel -0x70(%rbp), %r15d
movl 0x20(%r12), %edi
movl %r14d, %esi
callq 0x362d
movq -0x50(%rbp), %rsi
testq %rsi, %rsi
cmovneq %rsi, %r13
testb %al, %al
cmovneq %r13, %rsi
movq %rbx, %r13
jmp 0x3157
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rbx
jmp 0x31fb
leaq 0x1(%r13), %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
movq -0x40(%rbp), %r15
movq (%r15), %rdi
movq -0x48(%rbp), %rdx
subq %rsi, %rdx
movq -0x68(%rbp), %rsi
callq 0x2f2a
testl %r14d, %r14d
je 0x3229
movq (%r15), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
movq %r13, %rdx
callq 0x2f2a
xorl %r12d, %r12d
movl $0x0, -0x50(%rbp)
movq -0x70(%rbp), %r15
movl %r15d, %r13d
testl %r14d, %r14d
je 0x330a
movl (%rbx), %edi
leaq -0x54(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0x2110
testl %eax, %eax
je 0x331b
movq -0x38(%rbp), %r15
incq %r15
movl %r14d, %eax
movslq -0x54(%rbp), %r12
shlq $0x8, %rax
addq 0x19c16(%rip), %rax     # 0x1ce88
movzbl (%r12,%rax), %r14d
movq 0x19c12(%rip), %rsi     # 0x1ce90
movl %r14d, %edi
callq 0x3605
movq %rax, %rcx
cmpq $0x6f, %rax
movq %r15, -0x38(%rbp)
movq -0x48(%rbp), %rax
cmovneq %r15, %rax
movq %rcx, %r15
movq %rax, -0x48(%rbp)
cmovel %r13d, %r15d
movl -0x50(%rbp), %r13d
testb $0x1, %r13b
je 0x32b4
movq -0x40(%rbp), %rdx
jmp 0x32d1
movl 0x20(%rbx), %edi
movl %r14d, %esi
callq 0x362d
pushq $0x1
popq %rcx
testb %al, %al
movq -0x40(%rbp), %rdx
jne 0x32ce
movzbl %r13b, %ecx
movl %ecx, %r13d
movq -0x60(%rbp), %rax
testb $0x1, %r13b
jne 0x32f2
movq %rdx, %rax
cmpl $0xa, %r12d
jne 0x32f2
movq %rdx, %rax
testb %r14b, %r14b
je 0x32f2
incl 0x28(%rbx)
movq %rdx, %rax
movl %r13d, -0x50(%rbp)
movq (%rax), %rdi
movsbl %r12b, %esi
callq 0x2cf4
movb $0x1, %r12b
jmp 0x3237
cmpl $0x6f, %r13d
je 0x3327
testb $0x1, %r12b
jne 0x338d
jmp 0x33ae
testb $0x1, %r12b
je 0x335d
cmpl $0x6f, %r13d
jne 0x3389
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdx
cmpb $0xa, (%rdx)
jne 0x3345
cmpb $0x0, 0x1(%rdx)
leaq 0x601c(%rip), %rax      # 0x935d
cmoveq %rax, %rdx
movslq 0x28(%rbx), %rdi
leaq 0x6010(%rip), %rsi      # 0x9360
xorl %eax, %eax
callq 0x3b9c
pushq $0x6f
popq %r13
jmp 0x33ae
movq 0x18(%rbx), %rax
cmpq $0x0, 0x10(%rax)
pushq $0x70
popq %r13
je 0x342f
xorl %edi, %edi
leaq 0x5fa3(%rip), %rsi      # 0x931c
xorl %eax, %eax
callq 0x3b9c
pushq $0x6f
popq %r13
jmp 0x342f
incq -0x38(%rbp)
testb $0x1, -0x50(%rbp)
jne 0x33ae
movq -0x60(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rdx
subq -0x48(%rbp), %rdx
callq 0x2ed4
movl %r13d, %eax
movq 0x20(%rbx), %rdx
imulq $0x18, %rax, %rax
leaq 0x6080(%rip), %rcx      # 0x9440
addq %rcx, %rax
movzwl (%rax,%rdx,2), %ebx
testl %ebx, %ebx
je 0x33f9
btl $0xc, %ebx
jb 0x33ff
btl $0xd, %ebx
movq -0x30(%rbp), %r14
movq 0x18(%r14), %rdi
jb 0x3412
movq (%rdi), %rax
movq 0x10(%rdi), %rsi
movq -0x8(%rax,%rsi,8), %rax
movq %rax, 0x20(%r14)
decq %rsi
callq 0x2a66
jmp 0x3425
movq -0x30(%rbp), %rbx
jmp 0x342f
andl $0xefff, %ebx           # imm = 0xEFFF
movq -0x30(%rbp), %rax
movq %rbx, 0x20(%rax)
movq %rax, %rbx
jmp 0x3428
movq 0x10(%rdi), %rsi
callq 0x29d6
andl $0xcfff, %ebx           # imm = 0xCFFF
movq %rbx, 0x20(%r14)
movq %r14, %rbx
movb $0x0, 0x19a69(%rip)     # 0x1ce98
leaq 0xbcca(%rip), %rdi      # 0xf100
movl %r13d, %esi
callq 0x3014
testb %al, %al
je 0x3054
movq -0x40(%rbp), %r14
movq (%r14), %rdi
callq 0x2e51
jmp 0x30ca
movq 0x10(%rbx), %rax
movq (%rax), %rbx
pushq $-0x10
popq %rcx
leaq 0xb5e8(%rip), %r14      # 0xea50
leaq 0x10(%rcx), %r15
cmpq $0x140, %r15            # imm = 0x140
je 0x34cc
movq 0x18(%rcx,%r14), %rsi
movq %rbx, %rdi
callq 0x2120
movq %r15, %rcx
testl %eax, %eax
jne 0x3468
jmp 0x34bd
movq 0x10(%rbx), %rax
movq (%rax), %rbx
pushq $-0x10
popq %rcx
leaq 0xb6f4(%rip), %r14      # 0xeb90
leaq 0x10(%rcx), %r15
cmpq $0xc0, %r15
je 0x34dd
movq 0x18(%rcx,%r14), %rsi
movq %rbx, %rdi
callq 0x2120
movq %r15, %rcx
testl %eax, %eax
jne 0x349c
movq (%r15,%r14), %rax
jmp 0x350a
movslq %r13d, %rax
orl $-0x1, 0x4(%rbx)
jmp 0x350a
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x5ce4(%rip), %rsi      # 0x91bf
jmp 0x34fd
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x5d5e(%rip), %rsi      # 0x924a
jmp 0x34fd
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x5df5(%rip), %rsi      # 0x92f2
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3b9c
pushq $0x6f
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq