// File: /workspace/github_cpp_makefile_star2_O1/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, 0x28(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r15d, %r15d
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x24(%rsp), %rdi
callq 0x32db
movl %eax, %ebp
movb $0x1, %r13b
movzbl %al, %ebx
cmpb $0x20, %al
ja 0x33ef
movabsq $0x100000600, %rax      # imm = 0x100000600
btq %rbx, %rax
jae 0x33ef
xorl %r13d, %r13d
movsbl %bpl, %r12d
cmpl $0xb, %r15d
ja 0x363a
movl %r15d, %eax
leaq 0x11c41(%rip), %rcx     # 0x15048
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leal -0x30(%r12), %eax
cmpl $0xa, %eax
jae 0x365b
movl %r13d, %r14d
movl $0x2, %r15d
jmp 0x369e
xorl %r8d, %r8d
cmpb $0x3d, %bpl
movq 0x8(%rsp), %rdx
leaq 0x11d57(%rip), %rcx     # 0x15196
leaq 0x11cc7(%rip), %rax     # 0x1510d
cmoveq %rax, %rcx
setne %r8b
addq $0x9, %r8
jmp 0x3565
movl $0x4, %r8d
movl $0x6, %r15d
leaq 0x11cbd(%rip), %rcx     # 0x15127
movl %r13d, %r14d
cmpb $0x2a, %bpl
jne 0x35df
jmp 0x369e
cmpb $0x2a, %bpl
je 0x3695
movl $0x6, %r15d
movb $0x1, %r14b
cmpl $0xff, %ebx
jne 0x369e
movl $0x4, %r15d
movq 0x8(%rsp), %rdx
movl $0xa, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11cde(%rip), %rcx     # 0x15196
callq 0x22b0
jmp 0x369e
movl %r12d, %edi
callq 0x22d0
testl %eax, %eax
jne 0x369b
leal -0x30(%r12), %eax
cmpl $0xa, %eax
setb %al
cmpb $0x5f, %bpl
sete %cl
orb %al, %cl
movl $0x2, %r8d
leaq 0x11d2d(%rip), %rcx     # 0x15220
movl %r13d, %r14d
je 0x35df
jmp 0x369e
leal -0x30(%r12), %eax
movl $0x3, %r8d
leaq 0x11bf6(%rip), %rcx     # 0x15109
jmp 0x35d3
movl $0x6, %r8d
leaq 0x11d85(%rip), %rcx     # 0x152aa
cmpb $0x3d, %bpl
jne 0x35df
movl $0x9, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11bcc(%rip), %rcx     # 0x1510d
jmp 0x3565
movl $0x6, %r15d
cmpb $0x2f, %bpl
jne 0x369b
movl $0x7, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11bea(%rip), %rcx     # 0x1514f
movl $0x4, %r15d
movq %rsp, %rdi
xorl %esi, %esi
callq 0x22b0
movl %r13d, %r14d
jmp 0x369e
addb $-0x3d, %bpl
cmpb $0x2, %bpl
jb 0x3591
decq 0x17f22(%rip)           # 0x1b4b0
xorl %r13d, %r13d
movl $0x4, %r15d
movq 0x8(%rsp), %rdx
movl $0x9, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11b5f(%rip), %rcx     # 0x1510d
callq 0x22b0
movl %r13d, %r14d
jmp 0x369e
leal -0x30(%r12), %eax
movl $0x4, %r8d
movl $0x2, %r15d
leaq 0x11b4f(%rip), %rcx     # 0x15122
movl %r13d, %r14d
cmpl $0xa, %eax
jb 0x369e
decq 0x17eca(%rip)           # 0x1b4b0
xorl %r14d, %r14d
movq 0x8(%rsp), %rdx
movq %rsp, %rdi
xorl %esi, %esi
callq 0x22b0
movl $0x4, %r15d
jmp 0x369e
cmpb $0x3d, %bpl
je 0x3613
decq 0x17ea0(%rip)           # 0x1b4b0
xorl %r13d, %r13d
movl $0x4, %r15d
movq 0x8(%rsp), %rdx
movl $0x9, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11add(%rip), %rcx     # 0x1510d
callq 0x22b0
movl %r13d, %r14d
jmp 0x369e
movq 0x8(%rsp), %rdx
movl $0xa, %r8d
movq %rsp, %rdi
xorl %esi, %esi
leaq 0x11b45(%rip), %rcx     # 0x15196
callq 0x22b0
movl %r13d, %r14d
jmp 0x369e
movl %r12d, %edi
callq 0x22d0
cmpb $0x5f, %bpl
je 0x36bf
testl %eax, %eax
jne 0x36bf
cmpl $0x7a, %ebx
jg 0x36ca
xorl %r14d, %r14d
leal -0x20(%rbx), %eax
cmpl $0x1e, %eax
ja 0x36f7
leaq 0x119f4(%rip), %rcx     # 0x15078
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xb, %r15d
jmp 0x369b
movl $0x7, %r15d
movl %r13d, %r14d
testb %r14b, %r14b
je 0x36b0
leaq 0x78(%rsp), %rdi
movl %r12d, %esi
callq 0x2170
cmpl $0x4, %r15d
jne 0x33c6
jmp 0x3805
movl %r13d, %r14d
movl $0x3, %r15d
jmp 0x369e
cmpl $0x7b, %ebx
je 0x37ee
cmpl $0x7d, %ebx
je 0x37d7
movl $0x7, %r8d
leaq 0x11a18(%rip), %rcx     # 0x15101
cmpl $0xff, %ebx
je 0x35e6
jmp 0x36ff
addl $-0x9, %ebx
cmpl $0x2, %ebx
jb 0x369e
movl $0xa, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11a85(%rip), %rcx     # 0x15196
jmp 0x3565
movl $0x9, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11a1d(%rip), %rcx     # 0x15145
jmp 0x3565
movl $0x5, %r15d
jmp 0x369b
movl $0x8, %r15d
jmp 0x369b
movl $0x1, %r15d
jmp 0x369b
movl $0x4, %r8d
movq 0x8(%rsp), %rdx
leaq 0x119c7(%rip), %rcx     # 0x15127
jmp 0x3565
movl $0x5, %r8d
movq 0x8(%rsp), %rdx
leaq 0x119f7(%rip), %rcx     # 0x1516e
jmp 0x3565
movl $0xb, %r8d
movq 0x8(%rsp), %rdx
leaq 0x1199e(%rip), %rcx     # 0x1512c
jmp 0x3565
movl $0xc, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11993(%rip), %rcx     # 0x15138
jmp 0x3565
movl $0x4, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11966(%rip), %rcx     # 0x15122
jmp 0x3565
movl $0x9, %r15d
jmp 0x369b
movl $0xa, %r15d
jmp 0x369b
movl $0xb, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11979(%rip), %rcx     # 0x15162
jmp 0x3565
movl $0xa, %r8d
movq 0x8(%rsp), %rdx
leaq 0x11957(%rip), %rcx     # 0x15157
jmp 0x3565
movq 0x17c54(%rip), %r14     # 0x1b460
movq 0x17c55(%rip), %rbx     # 0x1b468
leaq 0x78(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq %rbx, %r14
je 0x385d
xorl %r12d, %r12d
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x42c6
movzbl %al, %eax
addq %rax, %r12
addq $0x20, %r14
cmpq %rbx, %r14
jne 0x382a
testq %r12, %r12
movq 0x28(%rsp), %r13
je 0x3862
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x2100
jmp 0x3862
movq 0x28(%rsp), %r13
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
xorl %eax, %eax
movq %rax, -0x8(%rbx)
movb %al, (%rbx)
leaq 0x60(%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 0x3c5c
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x3c5c
movl 0x24(%rsp), %ebp
leaq 0x30(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x2100
leaq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2100
incl %ebp
movl %ebp, 0x70(%rsp)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x391d
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x393a
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x17aef(%rip), %rdi     # 0x1b430
leaq 0x30(%rsp), %rsi
callq 0x3c28
leaq 0x117fd(%rip), %rsi     # 0x1514f
leaq 0x30(%rsp), %rdi
callq 0x2090
testl %eax, %eax
je 0x3981
leaq 0x10(%r13), %rax
movq %rax, (%r13)
movq 0x30(%rsp), %rcx
cmpq %rbx, %rcx
je 0x398b
movq %rcx, (%r13)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%r13)
jmp 0x3991
movq %r13, %rdi
callq 0x338a
jmp 0x39f9
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movq 0x38(%rsp), %rax
movq %rax, 0x8(%r13)
movq %rbx, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
leaq 0x30(%r13), %rax
movq %rax, 0x20(%r13)
movq 0x50(%rsp), %rcx
cmpq %r14, %rcx
je 0x39ce
movq %rcx, 0x20(%r13)
movq 0x60(%rsp), %rax
movq %rax, 0x30(%r13)
jmp 0x39d5
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq 0x58(%rsp), %rax
movq %rax, 0x28(%r13)
movq %r14, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x40(%r13)
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x3a10
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3a27
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3a49
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3a64
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r13, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ace
movq %rax, %rbx
jmp 0x3aa0
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x3aa0
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3ac2
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3ac2
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x30b8
jmp 0x3ad1
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3af3
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3b0e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2310