// File: /workspace/github_c_makefile_star2_O1/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 0x3377
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r13
movl 0x4(%rdi), %r15d
cmpl $-0x1, %r15d
je 0x337f
cmpl $0x1b, %r15d
je 0x389b
cmpl $0x2c, %r15d
je 0x3846
cmpl $0x1c, %r15d
jne 0x38e8
movq 0x10(%r13), %rax
movq (%rax), %r14
leaq 0x6ab4(%rip), %rsi      # 0x9de1
movq %r14, %rdi
callq 0x2120
leaq 0xb934(%rip), %rbx      # 0xec70
testl %eax, %eax
je 0x3903
xorl %r15d, %r15d
cmpq $0xb, %r15
je 0x3940
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x2120
addq $0x10, %rbx
incq %r15
testl %eax, %eax
jne 0x3347
decq %r15
cmpq $0xb, %r15
setae %cl
jmp 0x3905
movq $-0x1, %rax
retq
movq 0x10(%r13), %rdi
callq 0x3087
movq %r13, -0x50(%rbp)
cmpb $0x0, 0x19af5(%rip)     # 0x1ce88
jne 0x33d0
movq 0x20(%r13), %rax
leaq -0x1(%rax), %rcx
cmpq $0xa, %rcx
ja 0x33c9
leaq 0xb986(%rip), %rcx      # 0xed30
movq -0x8(%rcx,%rax,8), %rcx
leaq 0xb9d2(%rip), %rdx      # 0xed88
movq -0x8(%rdx,%rax,8), %rax
movq %rcx, 0x19ab6(%rip)     # 0x1ce78
movq %rax, 0x19ab7(%rip)     # 0x1ce80
movb $0x1, 0x19ab8(%rip)     # 0x1ce88
movq 0x19aa9(%rip), %r8      # 0x1ce80
movb (%r8), %dl
movl $0x6f, %esi
testb %dl, %dl
je 0x33fc
leaq 0x2(%r8), %rcx
cmpb $0x1, %dl
je 0x33f8
movb (%rcx), %dl
addq $0x2, %rcx
testb %dl, %dl
jne 0x33e7
jmp 0x33fc
movzbl -0x1(%rcx), %esi
movl %esi, -0x2c(%rbp)
movl $0x0, -0x44(%rbp)
movq 0x8(%r13), %rsi
movq 0x10(%rsi), %r15
testq %r15, %r15
je 0x356a
movq %rsi, -0x58(%rbp)
movq (%rsi), %rdx
movq 0x19a53(%rip), %rdi     # 0x1ce78
leaq 0x2(%r8), %rsi
movl $0x1, %r12d
xorl %ecx, %ecx
xorl %r9d, %r9d
xorl %eax, %eax
movq %rsi, -0x40(%rbp)
movsbq (%rdx,%r9), %r10
leaq 0x1(%r9), %r14
movl %r12d, %r11d
shlq $0x8, %r11
addq %rdi, %r11
movzbl (%r10,%r11), %r12d
testl %r12d, %r12d
je 0x3554
cmpb $0xa, %r10b
jne 0x3465
incl 0x28(%r13)
movb (%r8), %r10b
testb %r10b, %r10b
movq %r14, -0x38(%rbp)
je 0x3504
movq %rsi, %r11
movl %r10d, %ebx
cmpb %r12b, %bl
je 0x348d
movb (%r11), %bl
addq $0x2, %r11
testb %bl, %bl
jne 0x347b
jmp 0x3504
testb %r10b, %r10b
sete %bl
cmpb $0x6f, -0x1(%r11)
sete %r11b
cmovneq %r14, %rax
movq %rdi, %r14
movq %r15, %rdi
movq %rdx, %r15
movq %r8, %rdx
movq %r13, %r8
movl $0x6f, %r13d
movl -0x2c(%rbp), %esi
cmovnel %r13d, %esi
movl %esi, -0x2c(%rbp)
movq -0x40(%rbp), %rsi
movq %r8, %r13
movq %rdx, %r8
movq %r15, %rdx
movq %rdi, %r15
movq %r14, %rdi
orb %bl, %r11b
movq %rsi, %r11
jne 0x3504
cmpb %r12b, %r10b
je 0x34f4
movb (%r11), %r10b
addq $0x2, %r11
testb %r10b, %r10b
jne 0x34da
movl $0x6f, -0x2c(%rbp)
jmp 0x3500
movzbl -0x1(%r11), %esi
movl %esi, -0x2c(%rbp)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
movl 0x20(%r13), %r11d
cmpl $0x3, %r11d
je 0x352b
cmpl $0x5, %r11d
jne 0x353c
movb $0x1, %r10b
leaq 0x5ca2(%rip), %rbx      # 0x91c0
cmpb $0x0, (%rbx,%r12,2)
jne 0x353f
cmpl $0x3, %r11d
jne 0x353c
movb $0x1, %r10b
leaq 0x5c0b(%rip), %r11      # 0x9140
cmpb $0x0, (%r11,%r12,2)
jne 0x353f
xorl %r10d, %r10d
testq %rcx, %rcx
movq %rcx, %r11
cmoveq %r9, %r11
testb %r10b, %r10b
cmovneq %r11, %rcx
movq -0x38(%rbp), %r14
testq %r12, %r12
je 0x357c
movq %r14, %r9
cmpq %r15, %r14
jne 0x343a
movq %r15, %r14
jmp 0x357f
movl $0x1, %r12d
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x3583
movq %r9, %r15
movq -0x58(%rbp), %rsi
movq 0x10(%r13), %rdi
movq %rax, -0x38(%rbp)
subq %rcx, %rax
movq %rax, %rdx
callq 0x318a
testl %r12d, %r12d
je 0x35ab
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdi
movq %r15, %rdx
callq 0x318a
movl $0x1, %ebx
xorl %r15d, %r15d
testl %r12d, %r12d
je 0x3747
movq -0x50(%rbp), %r13
movl (%r13), %edi
movl $0x1, %edx
leaq -0x44(%rbp), %rsi
callq 0x2110
incq %r14
testl %eax, %eax
je 0x3620
movl %r12d, %ecx
movslq -0x44(%rbp), %rax
shlq $0x8, %rcx
addq 0x1988d(%rip), %rcx     # 0x1ce78
movzbl (%rax,%rcx), %r12d
movq 0x19889(%rip), %rcx     # 0x1ce80
movb (%rcx), %dl
testb %dl, %dl
je 0x36bd
addq $0x2, %rcx
movq %rcx, %rsi
movl %edx, %edi
cmpb %r12b, %dil
je 0x364e
movb (%rsi), %dil
addq $0x2, %rsi
testb %dil, %dil
jne 0x360a
jmp 0x36bd
testl %ebx, %ebx
je 0x3697
movq 0x18(%r13), %rax
movl $0x1, %r13d
cmpq $0x0, 0x10(%rax)
je 0x36a4
xorl %edi, %edi
leaq 0x6852(%rip), %rsi      # 0x9e90
xorl %eax, %eax
callq 0x4020
movl $0x6f, -0x40(%rbp)
jmp 0x36ab
testb %dl, %dl
sete %dil
cmpb $0x6f, -0x1(%rsi)
movq -0x38(%rbp), %rsi
cmovneq %r14, %rsi
movq %rsi, -0x38(%rbp)
sete %sil
movl $0x6f, %r8d
movl -0x2c(%rbp), %r9d
cmovnel %r8d, %r9d
movl %r9d, -0x2c(%rbp)
orb %dil, %sil
jne 0x36bd
cmpb %r12b, %dl
je 0x36b2
movb (%rcx), %dl
addq $0x2, %rcx
testb %dl, %dl
jne 0x367f
movl $0x6f, -0x2c(%rbp)
jmp 0x36b9
xorl %ebx, %ebx
movl $0x6, %r13d
jmp 0x372b
movl $0x70, -0x40(%rbp)
movl $0x1, %ebx
jmp 0x372b
movzbl -0x1(%rcx), %ecx
movl %ecx, -0x2c(%rbp)
movq %r14, -0x38(%rbp)
testb $0x1, %r15b
je 0x36c5
jmp 0x3700
movl %r15d, %esi
movl 0x20(%r13), %ecx
cmpl $0x3, %ecx
je 0x36ec
cmpl $0x5, %ecx
jne 0x36fd
movb $0x1, %r15b
leaq 0x5ae0(%rip), %rdx      # 0x91c0
cmpb $0x0, (%rdx,%r12,2)
jne 0x3700
cmpl $0x3, %ecx
jne 0x36fd
movb $0x1, %r15b
leaq 0x5a4a(%rip), %rcx      # 0x9140
cmpb $0x0, (%rcx,%r12,2)
jne 0x3700
movl %esi, %r15d
testb $0x1, %r15b
je 0x370c
movq 0x8(%r13), %rdi
jmp 0x371e
cmpl $0xa, %eax
jne 0x371a
testb %r12b, %r12b
je 0x371a
incl 0x28(%r13)
movq 0x10(%r13), %rdi
movsbl %al, %esi
callq 0x2f24
xorl %r13d, %r13d
xorl %ebx, %ebx
testl %r13d, %r13d
je 0x35b3
cmpl $0x6, %r13d
movq -0x50(%rbp), %r13
je 0x374b
movl -0x40(%rbp), %r15d
jmp 0x3818
movq -0x50(%rbp), %r13
movl %r15d, %eax
movl -0x2c(%rbp), %r15d
cmpl $0x6f, %r15d
jne 0x3792
movq 0x10(%r13), %rax
movq (%rax), %r14
movq %r14, %rdi
leaq 0x72f1(%rip), %rsi      # 0xaa5a
callq 0x2120
testl %eax, %eax
leaq 0x675a(%rip), %rax      # 0x9ed1
cmoveq %rax, %r14
movslq 0x28(%r13), %rdi
leaq 0x674e(%rip), %rsi      # 0x9ed4
movq %r14, %rdx
xorl %eax, %eax
callq 0x4020
jmp 0x37ae
testl %ebx, %ebx
jne 0x37ae
testb $0x1, %al
jne 0x37ae
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rsi
subq -0x38(%rbp), %r14
movq %r14, %rdx
callq 0x3111
movl %r15d, %eax
movq 0x20(%r13), %rdx
leaq (%rax,%rax,2), %rax
leaq 0x5a40(%rip), %rcx      # 0x9200
leaq (%rcx,%rax,8), %rax
movzwl (%rax,%rdx,2), %ebx
testl %ebx, %ebx
je 0x3818
btl $0xc, %ebx
jb 0x37f6
btl $0xd, %ebx
movq 0x18(%r13), %rdi
jb 0x37fe
movq (%rdi), %rax
movq 0x10(%rdi), %rsi
movq -0x8(%rax,%rsi,8), %rax
movq %rax, 0x20(%r13)
decq %rsi
callq 0x2c7d
jmp 0x3811
andl $0xefff, %ebx           # imm = 0xEFFF
jmp 0x380d
movq 0x10(%rdi), %rsi
callq 0x2bf1
andl $0xcfff, %ebx           # imm = 0xCFFF
movq %rbx, 0x20(%r13)
movb $0x0, 0x19670(%rip)     # 0x1ce88
leaq 0x5911(%rip), %rax      # 0x9130
movsbl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x382f
incq %rax
cmpl %ecx, %r15d
jne 0x381f
cmpb $-0x1, %cl
je 0x3301
movq 0x10(%r13), %rdi
callq 0x3087
jmp 0x338c
movq 0x10(%r13), %rax
movq (%rax), %r14
leaq 0x6444(%rip), %rsi      # 0x9c98
movq %r14, %rdi
callq 0x2120
leaq 0xb20d(%rip), %rbx      # 0xea70
testl %eax, %eax
je 0x38f5
xorl %r15d, %r15d
cmpq $0x13, %r15
je 0x390a
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x2120
addq $0x10, %rbx
incq %r15
testl %eax, %eax
jne 0x386e
decq %r15
cmpq $0x13, %r15
setae %cl
jmp 0x38f7
movq 0x10(%r13), %rax
movq (%rax), %r14
leaq 0x649c(%rip), %rsi      # 0x9d45
movq %r14, %rdi
callq 0x2120
leaq 0xb2f8(%rip), %rbx      # 0xebb0
testl %eax, %eax
je 0x38fc
xorl %r15d, %r15d
cmpq $0xb, %r15
je 0x3925
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x2120
addq $0x10, %rbx
incq %r15
testl %eax, %eax
jne 0x38bf
decq %r15
cmpq $0xb, %r15
setae %cl
jmp 0x38fe
movslq %r15d, %rax
movl $0xffffffff, 0x4(%r13)  # imm = 0xFFFFFFFF
jmp 0x3965
xorl %ecx, %ecx
movq (%rbx), %rax
jmp 0x390d
xorl %ecx, %ecx
movq (%rbx), %rax
jmp 0x3928
xorl %ecx, %ecx
movq (%rbx), %rax
jmp 0x3943
setae %cl
testb %cl, %cl
je 0x3965
movslq 0x28(%r13), %rdi
movq 0x10(%r13), %rax
movq (%rax), %rdx
leaq 0x6410(%rip), %rsi      # 0x9d33
jmp 0x3959
setae %cl
testb %cl, %cl
je 0x3965
movslq 0x28(%r13), %rdi
movq 0x10(%r13), %rax
movq (%rax), %rdx
leaq 0x6480(%rip), %rsi      # 0x9dbe
jmp 0x3959
setae %cl
testb %cl, %cl
je 0x3965
movslq 0x28(%r13), %rdi
movq 0x10(%r13), %rax
movq (%rax), %rdx
leaq 0x650d(%rip), %rsi      # 0x9e66
xorl %eax, %eax
callq 0x4020
movl $0x6f, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq