// File: /workspace/github_cpp_makefile_star2_O3/JameyWoo[P]csmile/scan.cpp
// Function: getToken()
Token getToken() {        // 获取token, 主函数里循环调用
    string currentToken;  // 当前token
    string token_value;
    int line;
    StateType state = START;
    bool save;  // save 表示是否保存该字符
    while (state != DONE) {
        char c = getNextChar(line);
        save   = true;                                               // 默认不返回
        if ((c == ' ') || (c == '\t') || (c == '\n')) save = false;  // ! 修复<, >后面接空格的bug
        switch (state) {
            case START:
                if (isdigit(c))
                    state = INNUM;
                else if (isalpha(c) || c == '_')
                    state = INID;
                else if ((c == ' ') || (c == '\t') || (c == '\n'))  // 这条还是不能少
                    save = false;
                else if (c == '<') {
                    state = COMPARE1;
                } else if (c == '>') {
                    state = COMPARE2;
                } else if (c == '/') {
                    state = INCOMMENT;
                } else if (c == '-') {
                    state = INNEGATIVE;
                } else if (c == '=') {
                    state = INASSIGN;
                } else if (c == '!') {  // 不等于判断
                    state = INNE;
                } else if (c == EOF) {
                    save         = false;
                    state        = DONE;
                    currentToken = "EndFile";
                } else {
                    state = DONE;  // 下面的都是单个字符出现的, 统一状态DONE
                    switch (c) {
                        case '(':
                            currentToken = "LeftBracket";
                            break;
                        case ')':
                            currentToken = "RightBracket";
                            break;
                        case '{':
                            currentToken = "LeftBigBkt";
                            break;
                        case '}':
                            currentToken = "RightBigBkt";
                            break;
                        case ';':
                            currentToken = "Semicolon";
                            break;
                        case '+':
                            currentToken = "PMOP";
                            break;
                        // - 有些特殊, 他可能是负数的开始
                        case '*':
                            currentToken = "MDOP";
                            break;
                        case ',':
                            currentToken = "Comma";
                            break;
                        default:
                            currentToken = "ErrorToken";
                    }
                }
                break;  // ! 由于没有写break引发的惨案...
            case INNUM:
                if (not isdigit(c)) {
                    rollback();
                    state        = DONE;
                    currentToken = "Num";
                    save         = false;  // rollback了不保存
                }
                break;
            case INID:
                if (not(isalpha(c) or isdigit(c) or c == '_')) {  // 如果不是字母和数字
                    rollback();
                    save         = false;
                    state        = DONE;
                    currentToken = "Id";
                }
                break;
            case INASSIGN:
                if (c == '=') {
                    state        = DONE;
                    currentToken = "CompareOp";
                } else {
                    rollback();
                    save         = false;
                    state        = DONE;
                    currentToken = "Assign";
                }
                break;
            case INCOMMENT:
                if (c == '*') {
                    state = INCOMMENT2;
                } else {
                    save = false;
                    rollback();
                    state        = DONE;
                    currentToken = "MDOP";
                }
                break;
            case INCOMMENT2:
                if (c != '*') {
                    state = INCOMMENT2;
                    save  = true;  // 让注释的空格保存下来
                    if (c == EOF) {
                        state        = DONE;
                        currentToken = "ErrorToken";
                    }
                } else
                    state = INCOMMENT3;
                break;
            case INCOMMENT3:
                if (c == '/') {
                    state        = DONE;
                    currentToken = "Comment";
                } else {
                    state = INCOMMENT2;
                }
                break;
            case COMPARE1:                        // 检测到<之后到这个状态来
                if (not(c == '=' || c == '>')) {  // <= 或者 <> 不等于
                    rollback();
                    save = false;
                }
                state        = DONE;
                currentToken = "CompareOp";
                break;
            case COMPARE2:
                if (c != '=') {
                    rollback();

                    save = false;
                }
                state        = DONE;
                currentToken = "CompareOp";
                break;
            case INNEGATIVE:
                if (isdigit(c)) {
                    state = INNUM;
                } else {
                    rollback();
                    save         = false;
                    state        = DONE;
                    currentToken = "PMOP";
                }
                break;
            case INNE:
                if (c == '=') {  // 不等于
                    state        = DONE;
                    currentToken = "CompareOp";
                } else {
                    currentToken = "ErrorToken";
                    state        = DONE;
                }
                break;
            case DONE:
            default:
                currentToken = "ErrorToken";
        }
        if (save) token_value += c;
    }
    if (count(reversedWords.begin(), reversedWords.end(), token_value) != 0)  // 判断Id是否为保留字
        currentToken = token_value;
    Token token;
    token.setToken(currentToken, token_value, line + 1);  // 行号从1开始
    tokens.push_back(token);                              // 保存token
    if (token.type == "Comment") return getToken();       // 忽略注释
    return token;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, 0x90(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r14d, %r14d
movq %r14, -0x8(%rax)
movb %r14b, (%rax)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r14, -0x8(%rax)
movb %r14b, (%rax)
leaq 0x24(%rsp), %r12
leaq 0x11c7b(%rip), %rbx     # 0x15048
movq %r12, %rdi
callq 0x32e3
movl %eax, %r15d
movsbl %al, %r13d
cmpb $0x21, %r13b
setae %al
movl $0xfffff9ff, %ebp       # imm = 0xFFFFF9FF
movl %r15d, %ecx
shrq %cl, %rbp
orb %al, %bpl
cmpl $0xb, %r14d
ja 0x360b
movl %r14d, %eax
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
leal -0x30(%r13), %eax
movl $0x2, %r14d
cmpl $0xa, %eax
jb 0x362f
movl %r13d, %edi
callq 0x22d0
movl $0x3, %r14d
cmpb $0x5f, %r15b
je 0x362f
testl %eax, %eax
jne 0x362f
movzbl %r15b, %eax
cmpl $0x7a, %eax
jg 0x3651
xorl %r14d, %r14d
leal -0x20(%rax), %ecx
cmpl $0x1e, %ecx
ja 0x3675
leaq 0x11c1b(%rip), %rdx     # 0x15078
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0xb, %r14d
jmp 0x362f
xorl %r8d, %r8d
cmpb $0x3d, %r15b
leaq 0x11d17(%rip), %rcx     # 0x15196
leaq 0x11c87(%rip), %rax     # 0x1510d
cmoveq %rax, %rcx
setne %r8b
addq $0x9, %r8
jmp 0x3573
movl $0x6, %r14d
cmpb $0x2a, %r15b
je 0x362f
jmp 0x375d
cmpb $0x2a, %r15b
je 0x3629
movzbl %r15b, %eax
movl $0x6, %r14d
cmpl $0xff, %eax
jne 0x3635
movl $0x4, %r14d
movq 0x8(%rsp), %rdx
movl $0xa, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11cae(%rip), %rcx     # 0x15196
callq 0x22b0
jmp 0x3635
movl %r13d, %edi
callq 0x22d0
movl $0x3, %r14d
testl %eax, %eax
jne 0x362f
leal -0x30(%r13), %eax
cmpl $0xa, %eax
setb %al
cmpb $0x5f, %r15b
sete %cl
orb %al, %cl
jne 0x362f
jmp 0x378a
leal -0x30(%r13), %eax
movl $0x2, %r14d
cmpl $0xa, %eax
jb 0x362f
jmp 0x377b
movl $0x9, %r8d
leaq 0x11bc2(%rip), %rcx     # 0x1510d
cmpb $0x3d, %r15b
je 0x3573
jmp 0x374e
movl $0x6, %r14d
movl $0x7, %r8d
leaq 0x11be6(%rip), %rcx     # 0x1514f
cmpb $0x2f, %r15b
jne 0x362f
movl $0x4, %r14d
movq 0x8(%rsp), %rdx
movq %rsp, %rdi
xorl %esi, %esi
callq 0x22b0
jmp 0x362f
addb $-0x3d, %r15b
cmpb $0x2, %r15b
jb 0x35a0
decq 0x17f12(%rip)           # 0x1b4b0
xorl %ebp, %ebp
movl $0x4, %r14d
movq 0x8(%rsp), %rdx
movl $0x9, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11b50(%rip), %rcx     # 0x1510d
callq 0x22b0
jmp 0x362f
leal -0x30(%r13), %eax
movl $0x2, %r14d
cmpl $0xa, %eax
jb 0x362f
jmp 0x376c
cmpb $0x3d, %r15b
je 0x35e7
decq 0x17ecb(%rip)           # 0x1b4b0
xorl %ebp, %ebp
movl $0x4, %r14d
movq 0x8(%rsp), %rdx
movl $0x9, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11b09(%rip), %rcx     # 0x1510d
callq 0x22b0
jmp 0x362f
movq 0x8(%rsp), %rdx
movl $0xa, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11b74(%rip), %rcx     # 0x15196
callq 0x22b0
jmp 0x362f
movl $0x7, %r14d
testb $0x1, %bpl
je 0x3642
leaq 0x70(%rsp), %rdi
movl %r13d, %esi
callq 0x2170
cmpl $0x4, %r14d
jne 0x33cd
jmp 0x37ac
cmpl $0x7b, %eax
je 0x371f
cmpl $0x7d, %eax
jne 0x3731
movl $0xb, %r8d
leaq 0x11af2(%rip), %rcx     # 0x15162
jmp 0x3573
addl $-0x9, %eax
cmpl $0x2, %eax
jb 0x3642
jmp 0x373c
movl $0x8, %r14d
jmp 0x362f
movl $0x5, %r14d
jmp 0x362f
movl $0xc, %r8d
leaq 0x11a99(%rip), %rcx     # 0x15138
jmp 0x3573
movl $0x9, %r8d
leaq 0x11a94(%rip), %rcx     # 0x15145
jmp 0x3573
movl $0xb, %r8d
leaq 0x11a69(%rip), %rcx     # 0x1512c
jmp 0x3573
movl $0xa, %r14d
jmp 0x362f
movl $0x1, %r14d
jmp 0x362f
movl $0x4, %r8d
leaq 0x11a37(%rip), %rcx     # 0x15122
jmp 0x3573
movl $0x5, %r8d
leaq 0x11a71(%rip), %rcx     # 0x1516e
jmp 0x3573
movl $0x4, %r8d
leaq 0x11a18(%rip), %rcx     # 0x15127
jmp 0x3573
movl $0x9, %r14d
jmp 0x362f
movl $0xa, %r8d
leaq 0x11a2b(%rip), %rcx     # 0x15157
jmp 0x3573
cmpl $0xff, %eax
je 0x3a17
movl $0xa, %r8d
leaq 0x11a4d(%rip), %rcx     # 0x15196
jmp 0x3573
movl $0x6, %r8d
leaq 0x11b4f(%rip), %rcx     # 0x152aa
jmp 0x3797
movl $0x4, %r8d
leaq 0x119bd(%rip), %rcx     # 0x15127
jmp 0x3797
movl $0x4, %r8d
leaq 0x119a9(%rip), %rcx     # 0x15122
jmp 0x3797
movl $0x3, %r8d
leaq 0x11981(%rip), %rcx     # 0x15109
jmp 0x3797
movl $0x2, %r8d
leaq 0x11a89(%rip), %rcx     # 0x15220
decq 0x17d12(%rip)           # 0x1b4b0
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
xorl %esi, %esi
callq 0x22b0
movq 0x17cad(%rip), %r15     # 0x1b460
movq 0x17cae(%rip), %rbx     # 0x1b468
leaq 0x70(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq %rbx, %r15
je 0x37fd
xorl %r12d, %r12d
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4250
movzbl %al, %eax
addq %rax, %r12
addq $0x20, %r15
cmpq %rbx, %r15
jne 0x37d1
testq %r12, %r12
je 0x37fd
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
callq 0x2100
leaq 0x38(%rsp), %rbx
movq %rbx, -0x10(%rbx)
xorl %eax, %eax
movq %rax, -0x8(%rbx)
movb %al, (%rbx)
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rax, -0x8(%r14)
movb %al, (%r14)
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x3c10
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x3c10
movl 0x24(%rsp), %ebp
leaq 0x28(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x2100
leaq 0x48(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2100
incl %ebp
movl %ebp, 0x68(%rsp)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x38b5
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
movq 0x90(%rsp), %r15
je 0x38da
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x17b4f(%rip), %rdi     # 0x1b430
leaq 0x28(%rsp), %rsi
callq 0x3bdc
leaq 0x1185d(%rip), %rsi     # 0x1514f
leaq 0x28(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x391f
leaq 0x10(%r15), %rax
movq %rax, (%r15)
movq 0x28(%rsp), %rcx
cmpq %rbx, %rcx
je 0x3940
movq %rcx, (%r15)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%r15)
jmp 0x3946
movq %r15, %rdi
callq 0x3382
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x39ae
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x39ae
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%r15)
movq %rbx, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
leaq 0x30(%r15), %rax
movq %rax, 0x20(%r15)
movq 0x48(%rsp), %rcx
cmpq %r14, %rcx
je 0x3983
movq %rcx, 0x20(%r15)
movq 0x58(%rsp), %rax
movq %rax, 0x30(%r15)
jmp 0x398a
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq 0x50(%rsp), %rax
movq %rax, 0x28(%r15)
movq %r14, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x40(%r15)
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x39c5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x39e7
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3a02
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r15, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x7, %r8d
leaq 0x116dd(%rip), %rcx     # 0x15101
jmp 0x379e
jmp 0x3a80
jmp 0x3a80
movq %rax, %rbx
jmp 0x3a52
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x3a52
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3a74
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3a74
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x30b8
jmp 0x3a83
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x3aa5
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3ac0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2310