// File: /workspace/github_c_makefile_star2_O3/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 0x335f
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %r15d
cmpl $-0x1, %r15d
movq %rdi, -0x30(%rbp)
je 0x3367
cmpl $0x1b, %r15d
je 0x380a
cmpl $0x2c, %r15d
je 0x37c9
cmpl $0x1c, %r15d
jne 0x3861
movq 0x10(%rbx), %rax
movq (%rax), %r14
movl $0x8, %ebx
leaq 0xb926(%rip), %r15      # 0xec50
movq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x2120
testl %eax, %eax
je 0x385a
addq $0x10, %rbx
cmpq $0xc8, %rbx
jne 0x332a
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x6b0c(%rip), %rsi      # 0x9e66
jmp 0x3849
movq $-0x1, %rax
retq
leaq 0x10(%rbx), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rbx), %rdi
callq 0x3088
leaq 0x8(%rbx), %rax
movq %rax, -0x50(%rbp)
cmpb $0x0, 0x19b01(%rip)     # 0x1ce88
jne 0x33c4
movq 0x20(%rbx), %rax
leaq -0x1(%rax), %rcx
cmpq $0xa, %rcx
ja 0x33bd
leaq 0xb972(%rip), %rcx      # 0xed10
movq -0x8(%rcx,%rax,8), %rcx
leaq 0xb9be(%rip), %rdx      # 0xed68
movq -0x8(%rdx,%rax,8), %rax
movq %rcx, 0x19ac2(%rip)     # 0x1ce78
movq %rax, 0x19ac3(%rip)     # 0x1ce80
movb $0x1, 0x19ac4(%rip)     # 0x1ce88
movq 0x19ab5(%rip), %rax     # 0x1ce80
movb (%rax), %cl
movl $0x6f, %r15d
testb %cl, %cl
je 0x33f6
leaq 0x2(%rax), %rdx
movl %ecx, %esi
cmpb $0x1, %sil
je 0x33f1
movb (%rdx), %sil
addq $0x2, %rdx
testb %sil, %sil
jne 0x33dd
jmp 0x33f6
movzbl -0x1(%rdx), %r15d
movl $0x0, -0x34(%rbp)
movq -0x50(%rbp), %rdx
movq (%rdx), %rsi
movq 0x10(%rsi), %rdx
testq %rdx, %rdx
je 0x3519
movq %rsi, -0x40(%rbp)
movq (%rsi), %rdi
movq 0x19a59(%rip), %r9      # 0x1ce78
leaq 0x2(%rax), %r10
movl $0x1, %r14d
xorl %r11d, %r11d
xorl %r13d, %r13d
xorl %esi, %esi
movq %r13, %r12
movq %r11, %r8
movsbq (%rdi,%r13), %r11
incq %r13
movl %r14d, %ebx
shlq $0x8, %rbx
addq %r9, %rbx
movzbl (%r11,%rbx), %r14d
testl %r14d, %r14d
je 0x3509
cmpb $0xa, %r11b
movq -0x30(%rbp), %r11
jne 0x3467
incl 0x28(%r11)
movb (%rax), %cl
testb %cl, %cl
je 0x34b6
movq %r10, %r11
movl %ecx, %ebx
cmpb %r14b, %bl
je 0x3482
movb (%r11), %bl
addq $0x2, %r11
testb %bl, %bl
jne 0x3470
jmp 0x34b2
cmpb $0x6f, -0x1(%r11)
movq -0x30(%rbp), %r11
je 0x34b6
movq %r10, %r11
movl %ecx, %ebx
cmpb %r14b, %bl
je 0x34aa
movb (%r11), %bl
addq $0x2, %r11
testb %bl, %bl
jne 0x3492
movl $0x6f, %r15d
jmp 0x34af
movzbl -0x1(%r11), %r15d
movq %r13, %rsi
movq -0x30(%rbp), %r11
movl 0x20(%r11), %r11d
cmpl $0x3, %r11d
je 0x34d2
cmpl $0x5, %r11d
jne 0x34e3
movb $0x1, %r11b
leaq 0x5cf0(%rip), %rbx      # 0x91c0
jmp 0x34dc
movb $0x1, %r11b
leaq 0x5c64(%rip), %rbx      # 0x9140
cmpb $0x0, (%rbx,%r14,2)
jne 0x34e6
xorl %r11d, %r11d
testq %r8, %r8
cmovneq %r8, %r12
testb %r11b, %r11b
movq %r12, %r11
cmoveq %r8, %r11
cmpq %rdx, %r13
jne 0x3431
movq %rdx, %r12
movq %r11, %r8
movq %rdx, %r13
movq -0x30(%rbp), %rbx
incq %r13
movq %rsi, %rdx
movq -0x40(%rbp), %rsi
jmp 0x352d
movl $0x1, %r14d
movl $0x1, %r13d
xorl %edx, %edx
xorl %r12d, %r12d
xorl %r8d, %r8d
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movq %rdx, -0x40(%rbp)
subq %r8, %rdx
callq 0x3186
testl %r14d, %r14d
je 0x36a7
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdi
movq %r12, %rdx
callq 0x3186
movl (%rbx), %edi
movl $0x1, %edx
leaq -0x34(%rbp), %rsi
callq 0x2110
testl %eax, %eax
je 0x3737
movq %rax, -0x58(%rbp)
xorl %r12d, %r12d
movl %r14d, %ecx
movslq -0x34(%rbp), %rax
shlq $0x8, %rcx
addq 0x198ee(%rip), %rcx     # 0x1ce78
movzbl (%rax,%rcx), %r14d
movq 0x198ea(%rip), %rcx     # 0x1ce80
movb (%rcx), %dl
testb %dl, %dl
je 0x35de
addq $0x2, %rcx
movq %rcx, %rsi
movl %edx, %edi
cmpb %r14b, %dil
je 0x35b8
movb (%rsi), %dil
addq $0x2, %rsi
testb %dil, %dil
jne 0x35a5
jmp 0x35de
cmpb $0x6f, -0x1(%rsi)
je 0x35de
cmpb %r14b, %dl
je 0x35d5
movb (%rcx), %dl
addq $0x2, %rcx
testb %dl, %dl
jne 0x35be
movl $0x6f, %r15d
jmp 0x35da
movzbl -0x1(%rcx), %r15d
movq %r13, -0x40(%rbp)
testb $0x1, %r12b
je 0x35ea
movq -0x50(%rbp), %rcx
jmp 0x363b
movl 0x20(%rbx), %ecx
cmpl $0x3, %ecx
je 0x3602
cmpl $0x5, %ecx
jne 0x3616
movb $0x1, %bl
leaq 0x5bc0(%rip), %rcx      # 0x91c0
jmp 0x360b
movb $0x1, %bl
leaq 0x5b35(%rip), %rcx      # 0x9140
cmpb $0x0, (%rcx,%r14,2)
movq -0x50(%rbp), %rcx
jne 0x363e
cmpl $0xa, %eax
jne 0x3637
testb %r14b, %r14b
je 0x3637
movq -0x30(%rbp), %rbx
incl 0x28(%rbx)
movq 0x10(%rbx), %rdi
movl $0xa, %esi
callq 0x2f24
jmp 0x3655
movq -0x48(%rbp), %rcx
movl %r12d, %ebx
movq (%rcx), %rdi
movsbl %al, %esi
callq 0x2f24
testq %r14, %r14
je 0x367d
movl %ebx, %r12d
movq -0x30(%rbp), %rbx
movl (%rbx), %edi
movl $0x1, %edx
leaq -0x34(%rbp), %rsi
callq 0x2110
incq %r13
testl %eax, %eax
jne 0x3578
cmpl $0x0, -0x58(%rbp)
je 0x3737
movl %r12d, %ebx
cmpl $0x6f, %r15d
movq -0x40(%rbp), %rcx
je 0x36ad
testb $0x1, %bl
jne 0x36e7
movq -0x50(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
subq %rcx, %r13
movq %r13, %rdx
callq 0x3112
jmp 0x36e7
cmpl $0x6f, %r15d
jne 0x36e7
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdx
cmpb $0xa, (%rdx)
jne 0x36cb
cmpb $0x0, 0x1(%rdx)
leaq 0x680a(%rip), %rax      # 0x9ed1
cmoveq %rax, %rdx
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x67fa(%rip), %rsi      # 0x9ed4
xorl %eax, %eax
callq 0x3f24
movl $0x6f, %r15d
movl %r15d, %eax
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rdx
leaq (%rax,%rax,2), %rax
leaq 0x5b03(%rip), %rcx      # 0x9200
leaq (%rcx,%rax,8), %rax
movzwl (%rax,%rdx,2), %ebx
testl %ebx, %ebx
je 0x375a
btl $0xc, %ebx
jb 0x3760
btl $0xd, %ebx
movq -0x30(%rbp), %r14
movq 0x18(%r14), %rdi
jb 0x377b
movq (%rdi), %rax
movq 0x10(%rdi), %rsi
movq -0x8(%rax,%rsi,8), %rax
movq %rax, 0x20(%r14)
decq %rsi
callq 0x2c71
jmp 0x378e
movq 0x18(%rbx), %rax
cmpq $0x0, 0x10(%rax)
je 0x3773
xorl %edi, %edi
leaq 0x6745(%rip), %rsi      # 0x9e90
xorl %eax, %eax
callq 0x3f24
movl $0x6f, %r15d
jmp 0x3798
movq -0x30(%rbp), %rbx
jmp 0x3798
andl $0xefff, %ebx           # imm = 0xEFFF
movq -0x30(%rbp), %rax
movq %rbx, 0x20(%rax)
movq %rax, %rbx
jmp 0x3791
movl $0x70, %r15d
jmp 0x3798
movq 0x10(%rdi), %rsi
callq 0x2be1
andl $0xcfff, %ebx           # imm = 0xCFFF
movq %rbx, 0x20(%r14)
movq %r14, %rbx
movb $0x0, 0x196f0(%rip)     # 0x1ce88
leaq 0x5991(%rip), %rax      # 0x9130
movsbl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x37af
incq %rax
cmpl %ecx, %r15d
jne 0x379f
cmpb $-0x1, %cl
je 0x32f9
movq -0x48(%rbp), %rax
movq (%rax), %rdi
callq 0x3088
jmp 0x3380
movq 0x10(%rbx), %rax
movq (%rax), %r14
movl $0x8, %ebx
leaq 0xb274(%rip), %r15      # 0xea50
movq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x2120
testl %eax, %eax
je 0x385a
addq $0x10, %rbx
cmpq $0x148, %rbx            # imm = 0x148
jne 0x37dc
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x652b(%rip), %rsi      # 0x9d33
jmp 0x3849
movq 0x10(%rbx), %rax
movq (%rax), %r14
movl $0x8, %ebx
leaq 0xb373(%rip), %r15      # 0xeb90
movq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x2120
testl %eax, %eax
je 0x385a
addq $0x10, %rbx
cmpq $0xc8, %rbx
jne 0x381d
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rdi
leaq 0x6575(%rip), %rsi      # 0x9dbe
movq %r14, %rdx
xorl %eax, %eax
callq 0x3f24
movl $0x6f, %eax
jmp 0x386b
movq -0x8(%rbx,%r15), %rax
jmp 0x386b
movslq %r15d, %rax
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq