// File: /workspace/github_cpp_makefile_star2_O2/philpoore[P]Math/./src/Lexer.cpp
// Function: Lexer::tokenize()
vector<Token> Lexer::tokenize() {
    vector<Token> tokens;

    while (i < size) {
        char a = peek();
        if (a == 'i' && peek(1) == 'f') {  // if
            Token t = createToken(TOKEN_IF);
            t.source = "if";
            tokens.push_back(t);
            advance(2);
            continue;
        } else if (peekStr(0, 4) == "else") {  // else
            Token t = createToken(TOKEN_ELSE);
            t.source = "else";
            tokens.push_back(t);
            advance(4);
            continue;
        } else if (isalpha(a)) {
            // idents
            string ident = "";
            Token t = createToken(TOKEN_IDENT);
            while (isalpha(a) || isdigit(a)) {
                ident += a;
                advance();
                a = peek();
            }
            t.source = ident;
            tokens.push_back(t);
            continue;
        } else if (isdigit(a)) {
            Token t = createToken(TOKEN_NUMBER_LITERAL);
            // number literal
            string number = "";
            while (isdigit(a)) {
                number += a;
                advance();
                a = peek();
            }

            // decimal point
            if (a == '.') {
                number += a;
                advance();
                a = peek();
                while (isdigit(a)) {
                    number += a;
                    advance();
                    a = peek();
                }
            }

            t.source = number;
            tokens.push_back(t);
            continue;
        } else if (isspace(a)) {
            string whitespace;

            Token t = createToken(TOKEN_WHITESPACE);
            while (isspace(a)) {
                whitespace += a;
                if (a == '\n') {
                    advanceRow();
                }
                advance();
                a = peek();
            }
            t.source = whitespace;
            tokens.push_back(t);
            continue;
        } else if (a == '*' && peek(1) == '*') {
            Token t = createToken(TOKEN_EXP);
            t.source = "**";
            tokens.push_back(t);
            advance(2);
            continue;
        } else {
            TokenType tt =
                tokenTypeMap.count(a) ? tokenTypeMap.at(a) : (TokenType)a;
            Token t = createToken(tt);
            t.source = a;
            tokens.push_back(t);
            advance();
        }
    }

    Token t = createToken(TOKEN_EOF);
    tokens.push_back(t);

    return tokens;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r12
movq %rdi, %rbx
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
leaq -0x60(%rbp), %r15
movq %rdi, -0x68(%rbp)
movslq 0x20(%r12), %rax
cmpl 0x24(%r12), %eax
jge 0x5a3c
movq (%r12), %rcx
movb (%rcx,%rax), %dl
movb %dl, -0x29(%rbp)
cmpb $0x69, %dl
jne 0x5670
cmpb $0x66, 0x1(%rcx,%rax)
jne 0x5670
movl $0x10e, -0x60(%rbp)     # imm = 0x10E
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x4d28(%rip), %rsi      # 0xa37a
callq 0x33a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
addl $0x2, 0x2c(%r12)
addl $0x2, 0x20(%r12)
jmp 0x56ed
movq %rbx, %r14
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
pushq $0x4
popq %rcx
callq 0x7be6
movq %r15, %rdi
leaq 0x4cf0(%rip), %rsi      # 0xa37d
callq 0x7bd5
movl %eax, %r13d
movq %r15, %rdi
callq 0x3110
testb %r13b, %r13b
je 0x56fb
movl $0x10f, -0x60(%rbp)     # imm = 0x10F
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x4caf(%rip), %rsi      # 0xa37d
movq %r14, %rbx
callq 0x33a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
addl $0x4, 0x2c(%r12)
addl $0x4, 0x20(%r12)
leaq -0x58(%rbp), %rdi
callq 0x3110
jmp 0x5600
movb -0x29(%rbp), %bl
movsbl %bl, %r13d
movl %r13d, %edi
callq 0x3300
testl %eax, %eax
je 0x57cd
leaq -0x90(%rbp), %r14
movq %r14, %rdi
leaq 0x4dc0(%rip), %rsi      # 0xa4e3
movq %r15, %rdx
callq 0x7692
movl $0x101, -0x60(%rbp)     # imm = 0x101
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
movb -0x29(%rbp), %al
movq -0x68(%rbp), %rbx
movsbl %al, %r13d
movl %r13d, %edi
callq 0x3300
testl %eax, %eax
setne %al
leal -0x30(%r13), %ecx
cmpl $0xa, %ecx
setb %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x57a0
movq %r14, %rdi
movl %r13d, %esi
callq 0x31c0
incl 0x2c(%r12)
movslq 0x20(%r12), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x20(%r12)
movq (%r12), %rcx
movb 0x1(%rcx,%rax), %al
movb %al, -0x29(%rbp)
jmp 0x5753
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x3150
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
leaq -0x58(%rbp), %rdi
callq 0x3110
movq %r14, %rdi
callq 0x3110
jmp 0x5600
leal -0x30(%r13), %eax
cmpl $0x9, %eax
leaq -0x90(%rbp), %r14
ja 0x584f
movl $0x102, -0x60(%rbp)     # imm = 0x102
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
movq %r14, %rdi
leaq 0x4cdb(%rip), %rsi      # 0xa4e3
leaq -0x69(%rbp), %rdx
callq 0x7692
movb -0x29(%rbp), %al
movq -0x68(%rbp), %rbx
movsbl %al, %esi
leal -0x30(%rsi), %ecx
cmpl $0x9, %ecx
ja 0x58f6
movq %r14, %rdi
callq 0x31c0
incl 0x2c(%r12)
movslq 0x20(%r12), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x20(%r12)
movq (%r12), %rcx
movb 0x1(%rcx,%rax), %al
movb %al, -0x29(%rbp)
jmp 0x5818
movl %r13d, %edi
callq 0x3060
testl %eax, %eax
je 0x597f
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
andq $0x0, -0x88(%rbp)
movl $0x111, -0x60(%rbp)     # imm = 0x111
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
xorl %eax, %eax
movb %al, -0x80(%rbp)
movb %al, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
movsbl %bl, %r13d
movl %r13d, %edi
callq 0x3060
testl %eax, %eax
je 0x595f
movq %r14, %rdi
movl %r13d, %esi
callq 0x31c0
cmpb $0xa, -0x29(%rbp)
jne 0x58cf
movl $0x1, 0x2c(%r12)
incl 0x28(%r12)
pushq $0x2
popq %rax
jmp 0x58d6
movl 0x2c(%r12), %eax
incl %eax
movl %eax, 0x2c(%r12)
movslq 0x20(%r12), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x20(%r12)
movq (%r12), %rcx
movb 0x1(%rcx,%rax), %bl
movb %bl, -0x29(%rbp)
jmp 0x5897
cmpb $0x2e, %al
jne 0x593b
movq %r14, %rdi
pushq $0x2e
popq %rsi
callq 0x31c0
incl 0x2c(%r12)
movslq 0x20(%r12), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x20(%r12)
movq (%r12), %rcx
movsbl 0x1(%rcx,%rax), %eax
movb %al, -0x29(%rbp)
movl %eax, %ecx
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x593b
movsbl %al, %esi
movq %r14, %rdi
callq 0x31c0
jmp 0x5905
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x3150
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
movq %r14, %rdi
callq 0x3110
jmp 0x56ed
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
movq -0x68(%rbp), %rbx
callq 0x3150
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
jmp 0x57b7
cmpb $0x2a, %bl
jne 0x59d9
movslq 0x20(%r12), %rax
movq (%r12), %rcx
cmpb $0x2a, 0x1(%rcx,%rax)
jne 0x59d9
movl $0x109, -0x60(%rbp)     # imm = 0x109
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x28(%r12), %rax
movq %rax, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x48da(%rip), %rsi      # 0xa29a
movq -0x68(%rbp), %rbx
callq 0x33a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
jmp 0x5662
leaq 0x9858(%rip), %rdi      # 0xf238
leaq -0x29(%rbp), %rsi
callq 0x7c1e
testq %rax, %rax
je 0x5a02
leaq 0x9843(%rip), %rdi      # 0xf238
leaq -0x29(%rbp), %rsi
callq 0x7c42
movl (%rax), %edx
jmp 0x5a06
movsbl -0x29(%rbp), %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x7b50
movsbl -0x29(%rbp), %esi
leaq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rbx
callq 0x3350
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b9a
incl 0x2c(%r12)
incl 0x20(%r12)
jmp 0x56ed
leaq -0x58(%rbp), %r15
movl $0x112, -0x8(%r15)      # imm = 0x112
leaq -0x48(%rbp), %rax
movq %rax, (%r15)
andq $0x0, 0x8(%r15)
movb $0x0, 0x10(%r15)
movq 0x28(%r12), %rax
movq %rax, 0x20(%r15)
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x7b9a
movq %r15, %rdi
callq 0x3110
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5aa8
jmp 0x5a9f
movq %rax, %r12
movq %r15, %rdi
jmp 0x5b01
jmp 0x5aa8
movq %rax, %r12
jmp 0x5adf
jmp 0x5abb
jmp 0x5ad0
movq %rax, %r12
jmp 0x5ae8
jmp 0x5aee
jmp 0x5aa8
movq %rax, %r12
leaq -0x58(%rbp), %rdi
jmp 0x5b01
movq %rax, %r12
movq %r14, %rbx
jmp 0x5b06
jmp 0x5ad0
movq %rax, %r12
leaq -0x58(%rbp), %rdi
callq 0x3110
leaq -0x90(%rbp), %rdi
jmp 0x5ae3
movq %rax, %r12
leaq -0x90(%rbp), %rdi
callq 0x3110
leaq -0x58(%rbp), %rdi
callq 0x3110
movq -0x68(%rbp), %rbx
jmp 0x5b06
movq %rax, %r12
leaq -0x58(%rbp), %rdi
callq 0x3110
leaq -0x90(%rbp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x7c7a
movq %r12, %rdi
callq 0x3370