// File: /workspace/github_cpp_makefile_star2_O3/baziotis[P]minijava-cpp/lex.cpp
// Function: next_token()
void next_token() {
    tok_start = input;
lex_again:
    if (!input[0]) {
        token.kind = TOK::EOI;
        return;
    }
    // skip whitespace
    while (*input && charmap[*input] & BLANK) {
        if (*input == '\n') {
            encountered_newline();
        }
        input++;
    }
    if (!input[0]) goto lex_again;
    tok_start = input;

    switch (*input) {
    case '.':
    {
        token.kind = TOK::DOT;
        if (charmap[input[1]]&DEC) {
            warning("Floating numbers are not supported.");
        }
        ++input;
    } break;

    case '0' ... '9':
    {
        while (charmap[*input]&DEC) {
            ++input;
        }
        const char *save = input;
        if (*input == '.' || *input == 'e') {
            warning("Floating numbers are not supported.");
            ++save;
        }
        input = tok_start;  // reset input
        scan_int();
        input = save;
    } break;

    // TODO: Maybe an automata-like lexer is not that good these days..
    // Think of making a modified version of memcmp (one that can
    // intelligently be inlined) optimized for small lengths.

    // Explicitly handle letters that start keywords.
    // If we don't match a keyword, we fall-through to the
    // identifier case.
    case 'b':
    {
        if (input[1] == 'o'
        &&  input[2] == 'o'
        &&  input[3] == 'l'
        &&  input[4] == 'e'
        &&  input[5] == 'a'
        &&  input[6] == 'n'
        && !(charmap[input[7]]&(DEC|MIDCHAR))) {
            input += 7;
            token.kind = TOK::BOOLEAN;
            return;
        }
        goto Lid;
    } break;
    case 'c':
    {
        if (input[1] == 'l'
        &&  input[2] == 'a'
        &&  input[3] == 's'
        &&  input[4] == 's'
        && !(charmap[input[5]]&(DEC|MIDCHAR))) {
            input += 5;
            token.kind = TOK::CLASS;
            return;
        }
        goto Lid;
    } break;
    case 'e':
    {
        if (input[1] == 'l'
        &&  input[2] == 's'
        &&  input[3] == 'e'
        && !(charmap[input[4]]&(DEC|MIDCHAR))) {
            input += 4;
            token.kind = TOK::ELSE;
            return;
        }
        if (input[1] == 'x'
        &&  input[2] == 't'
        &&  input[3] == 'e'
        &&  input[4] == 'n'
        &&  input[5] == 'd'
        &&  input[6] == 's'
        && !(charmap[input[7]]&(DEC|MIDCHAR))) {
            input += 7;
            token.kind = TOK::EXTENDS;
            return;
        }
        goto Lid;
    }
    case 'f':
    {
        if (input[1] == 'a'
        &&  input[2] == 'l'
        &&  input[3] == 's'
        &&  input[4] == 'e'
        && !(charmap[input[5]]&(DEC|MIDCHAR))) {
            input += 5;
            token.kind = TOK::FALSE;
            return;
        }
        goto Lid;
    }
	case 'i':
    {
		if (input[1] == 'f'
		&& !(charmap[input[2]]&(DEC|MIDCHAR)))
        {
            input += 2;
            token.kind = TOK::IF;
			return;
		}
		if (input[1] == 'n'
		&&  input[2] == 't'
		&& !(charmap[input[3]]&(DEC|MIDCHAR)))
        {
            input += 3;
            token.kind = TOK::INT;
            return;
		}
		goto Lid;
    }
    case 'n':
    {
		if (input[1] == 'e'
		&&  input[2] == 'w'
		&& !(charmap[input[3]]&(DEC|MIDCHAR))) {
            input += 3;
            token.kind = TOK::NEW;
            return;
        }
        goto Lid;
    } break;
    case 'p':
    {
		if (input[1] == 'u'
		&&  input[2] == 'b'
		&&  input[3] == 'l'
		&&  input[4] == 'i'
		&&  input[5] == 'c'
		&& !(charmap[input[6]]&(DEC|MIDCHAR))) {
            input += 6;
            token.kind = TOK::PUBLIC;
            return;
        }
        goto Lid;
    } break;
    case 'r':
    {
        if (input[1] == 'e'
        &&  input[2] == 't'
        &&  input[3] == 'u'
        &&  input[4] == 'r'
        &&  input[5] == 'n'
        && !(charmap[input[6]]&(DEC|MIDCHAR))) {
            input += 6;
            token.kind = TOK::RETURN;
            return;
        }
        goto Lid;
    }
    case 's':
    {
        if (input[1] == 't'
        &&  input[2] == 'a'
        &&  input[3] == 't'
        &&  input[4] == 'i'
        &&  input[5] == 'c'
        && !(charmap[input[6]]&(DEC|MIDCHAR))) {
            input += 6;
            token.kind = TOK::STATIC;
            return;
        }
        goto Lid;
    }
    case 't':
    {
        if (input[1] == 'r'
        &&  input[2] == 'u'
        &&  input[3] == 'e'
        && !(charmap[input[4]]&(DEC|MIDCHAR))) {
            input += 4;
            token.kind = TOK::TRUE;
            return;
        }
        if (input[1] == 'h'
        &&  input[2] == 'i'
        &&  input[3] == 's'
        && !(charmap[input[4]]&(DEC|MIDCHAR))) {
            input += 4;
            token.kind = TOK::THIS;
            return;
        }
        goto Lid;
    }
    case 'w':
    {
        if (input[1] == 'h'
        &&  input[2] == 'i'
        &&  input[3] == 'l'
        &&  input[4] == 'e'
        && !(charmap[input[5]]&(DEC|MIDCHAR))) {
            input += 5;
            token.kind = TOK::WHILE;
            return;
        }
        goto Lid;
    }
    case 'v':
    {
        if (input[1] == 'o'
        &&  input[2] == 'i'
        &&  input[3] == 'd'
        && !(charmap[input[4]]&(DEC|MIDCHAR))) {
            input += 4;
            token.kind = TOK::VOID;
            return;
        }
        goto Lid;
    }

    case 'S':
    {
        if (input[1] == 't'
        &&  input[2] == 'r'
        &&  input[3] == 'i'
        &&  input[4] == 'n'
        &&  input[5] == 'g'
        && !(charmap[input[6]]&(DEC|MIDCHAR))) {
            input += 6;
            token.kind = TOK::STRING;
            return;
        }
        if (!memcmp(input, print_stmt_key, print_stmt_key_len)) {
            input += print_stmt_key_len;
            token.kind = TOK::PRINT;
            return;
        }
        goto Lid;
    } break;

    // The rest of letters and _ (which correspond to an identifier)
    case 'a': case 'd': case 'g': case 'h': case 'j':
    case 'k': case 'l': case 'm': case 'o':
    case 'q': case 'u':
    case 'x': case 'y': case 'z':
    case 'A' ... 'R': case 'T' ... 'Z':
    case '_':
    {
Lid:
        while (charmap[*input]&(MIDCHAR|DEC)) {
            ++input;
        }
        token.id = str_intern_range(tok_start, input);
        token.kind = TOK::ID;
    } break;

    case '&':
    {
        if (input[1] == '&') {
            token.kind = TOK::AND_AND;
            input += 2;
        } else {
            warning("There's no `&` token. Maybe you meant to write `&&`.");
            ++input;
        }
    } break;

    case '<': case '\0': case '(': case ')': case '{': case '}':
    case '[': case ']': case ',': case ';': case '!': case '=':
    case '-': case '+': case '*':
    {
        switch (*input)
        {
        case '<': token.kind = TOK::LT; break;
        case '\0': token.kind = TOK::EOI; break;
        case '(': token.kind = TOK::LPAR; break;
        case ')': token.kind = TOK::RPAR; break;
        case '{': token.kind = TOK::LBRACE; break;
        case '}': token.kind = TOK::RBRACE; break;
        case '[': token.kind = TOK::LBRACKET; break;
        case ']': token.kind = TOK::RBRACKET; break;
        case ',': token.kind = TOK::COMMA; break;
        case ';': token.kind = TOK::SEMI; break;
        case '!': token.kind = TOK::NOT; break;
        case '=': token.kind = TOK::ASGN; break;
        case '-': token.kind = TOK::MINUS; break;
        case '+': token.kind = TOK::PLUS; break;
        case '*': token.kind = TOK::STAR; break;
        default: printf("%c\n", *input); assert(0);
        }
        ++input;
    } break;

    case '/':
    {
        ++input;
        if (*input != '/') {
            syntax_error("Expected `/` after `/` so that comment starts;"
                         " skipping the rest of the line");

        }
        while (*input != 0 && *input != '\n') {
            ++input;
        }
        goto lex_again;
    } break;

    default:
        fatal_error("Unrecognized character: ", *input, " - ln: ", loc.ln);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x16c3a(%rip), %rdi     # 0x1a6a8
movq %rdi, 0x16f3b(%rip)     # 0x1a9b0
movb (%rdi), %dl
testb %dl, %dl
je 0x3b30
movl 0x16c0b(%rip), %esi     # 0x1a690
leaq 0x16c24(%rip), %r14     # 0x1a6b0
leaq 0xdb2d(%rip), %r15      # 0x115c0
leaq 0xdfc5(%rip), %rbx      # 0x11a5f
movsbq %dl, %rax
movb (%rax,%r14), %cl
testb $0x1, %cl
jne 0x3b0a
movq %rdi, 0x16f02(%rip)     # 0x1a9b0
movzbl %dl, %eax
leal -0x21(%rax), %r8d
cmpl $0x5c, %r8d
ja 0x421f
movslq (%r15,%r8,4), %r8
addq %r15, %r8
jmpq *%r8
leaq 0x1(%rdi), %rax
movq %rax, 0x16bd4(%rip)     # 0x1a6a8
cmpb $0x2f, 0x1(%rdi)
je 0x3aef
movq %rbx, %rdi
callq 0x391a
movl 0x16ba8(%rip), %esi     # 0x1a690
movq 0x16bb9(%rip), %rax     # 0x1a6a8
movq %rax, %rdi
movzbl (%rdi), %edx
testl %edx, %edx
je 0x3b30
cmpl $0xa, %edx
je 0x3a9a
incq %rdi
movq %rdi, 0x16ba0(%rip)     # 0x1a6a8
jmp 0x3af2
cmpb $0xa, %dl
jne 0x3b17
incl %esi
movl %esi, 0x16b79(%rip)     # 0x1a690
leaq 0x1(%rdi), %rax
movq %rax, 0x16b86(%rip)     # 0x1a6a8
movb 0x1(%rdi), %dl
movq %rax, %rdi
testb %dl, %dl
jne 0x3a9a
movl $0x1, 0x16b5e(%rip)     # 0x1a698
jmp 0x41eb
cmpl $0x5a, %eax
jg 0x3bca
leal -0x28(%rax), %ecx
cmpl $0x15, %ecx
ja 0x3c07
leaq 0xdbd9(%rip), %rdx      # 0x11734
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x3, %eax
jmp 0x4102
movq %rdi, %rbx
testb $0x4, %cl
je 0x3b8f
movq %rdi, %rbx
movsbq 0x1(%rbx), %rdx
incq %rbx
testb $0x4, (%rdx,%r14)
jne 0x3b79
movq %rbx, 0x16b19(%rip)     # 0x1a6a8
cmpb $0x65, %dl
je 0x3b9c
movzbl %dl, %eax
cmpl $0x2e, %eax
jne 0x3bb2
leaq 0xde45(%rip), %rdi      # 0x119e8
callq 0x39d5
incq %rbx
movq 0x16dfe(%rip), %rdi     # 0x1a9b0
movq %rdi, 0x16aef(%rip)     # 0x1a6a8
callq 0x3694
movq %rbx, 0x16ae3(%rip)     # 0x1a6a8
jmp 0x41eb
cmpl $0x7a, %eax
jg 0x3beb
cmpl $0x5b, %eax
je 0x40f6
cmpl $0x5d, %eax
jne 0x4227
movl $0x1b, %eax
jmp 0x4102
cmpl $0x7b, %eax
je 0x40fd
cmpl $0x7d, %eax
jne 0x4227
movl $0x1a, %eax
jmp 0x4102
cmpl $0x21, %eax
jne 0x4227
movl $0x4, %eax
jmp 0x4102
cmpb $0x6f, 0x1(%rdi)
jne 0x41b4
cmpb $0x6f, 0x2(%rdi)
jne 0x41b4
cmpb $0x6c, 0x3(%rdi)
jne 0x41b4
cmpb $0x65, 0x4(%rdi)
jne 0x41b4
cmpb $0x61, 0x5(%rdi)
jne 0x41b4
cmpb $0x6e, 0x6(%rdi)
jne 0x41b4
movsbq 0x7(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x7, %rdi
movq %rdi, 0x16a37(%rip)     # 0x1a6a8
movl $0x5, 0x16a1d(%rip)     # 0x1a698
jmp 0x41eb
cmpb $0x74, 0x1(%rdi)
jne 0x41b4
cmpb $0x61, 0x2(%rdi)
jne 0x41b4
cmpb $0x74, 0x3(%rdi)
jne 0x41b4
cmpb $0x69, 0x4(%rdi)
jne 0x41b4
cmpb $0x63, 0x5(%rdi)
jne 0x41b4
movsbq 0x6(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x6, %rdi
movq %rdi, 0x169db(%rip)     # 0x1a6a8
movl $0xf, 0x169c1(%rip)     # 0x1a698
jmp 0x41eb
movzbl 0x1(%rdi), %eax
cmpl $0x6e, %eax
je 0x412f
cmpl $0x66, %eax
jne 0x41b4
movsbq 0x2(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x2, %rdi
movq %rdi, 0x1699b(%rip)     # 0x1a6a8
movl $0x9, 0x16981(%rip)     # 0x1a698
jmp 0x41eb
movzbl 0x1(%rdi), %eax
cmpl $0x78, %eax
je 0x415b
cmpl $0x6c, %eax
jne 0x41b4
cmpb $0x73, 0x2(%rdi)
jne 0x41b4
cmpb $0x65, 0x3(%rdi)
jne 0x41b4
movsbq 0x4(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x4, %rdi
movq %rdi, 0x16947(%rip)     # 0x1a6a8
movl $0xd, 0x1692d(%rip)     # 0x1a698
jmp 0x41eb
cmpb $0x61, 0x1(%rdi)
jne 0x41b4
cmpb $0x6c, 0x2(%rdi)
jne 0x41b4
cmpb $0x73, 0x3(%rdi)
jne 0x41b4
cmpb $0x65, 0x4(%rdi)
jne 0x41b4
movsbq 0x5(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x5, %rdi
movq %rdi, 0x168f5(%rip)     # 0x1a6a8
movl $0x13, 0x168db(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x6c, 0x1(%rdi)
jne 0x41b4
cmpb $0x61, 0x2(%rdi)
jne 0x41b4
cmpb $0x73, 0x3(%rdi)
jne 0x41b4
cmpb $0x73, 0x4(%rdi)
jne 0x41b4
movsbq 0x5(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x5, %rdi
movq %rdi, 0x168a3(%rip)     # 0x1a6a8
movl $0x16, 0x16889(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x65, 0x1(%rdi)
jne 0x41b4
cmpb $0x77, 0x2(%rdi)
jne 0x41b4
movsbq 0x3(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x3, %rdi
movq %rdi, 0x16865(%rip)     # 0x1a6a8
movl $0x15, 0x1684b(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x75, 0x1(%rdi)
jne 0x41b4
cmpb $0x62, 0x2(%rdi)
jne 0x41b4
cmpb $0x6c, 0x3(%rdi)
jne 0x41b4
cmpb $0x69, 0x4(%rdi)
jne 0x41b4
cmpb $0x63, 0x5(%rdi)
jne 0x41b4
movsbq 0x6(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x6, %rdi
movq %rdi, 0x16809(%rip)     # 0x1a6a8
movl $0xc, 0x167ef(%rip)     # 0x1a698
jmp 0x41eb
cmpb $0x26, 0x1(%rdi)
jne 0x4117
movl $0x1f, 0x167d6(%rip)    # 0x1a698
addq $0x2, %rdi
jmp 0x410b
movzbl 0x1(%rdi), %eax
cmpl $0x68, %eax
je 0x419c
cmpl $0x72, %eax
jne 0x41b4
cmpb $0x75, 0x2(%rdi)
jne 0x41b4
cmpb $0x65, 0x3(%rdi)
jne 0x41b4
movsbq 0x4(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x4, %rdi
movq %rdi, 0x16798(%rip)     # 0x1a6a8
movl $0x12, 0x1677e(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x65, 0x1(%rdi)
jne 0x41b4
cmpb $0x74, 0x2(%rdi)
jne 0x41b4
cmpb $0x75, 0x3(%rdi)
jne 0x41b4
cmpb $0x72, 0x4(%rdi)
jne 0x41b4
cmpb $0x6e, 0x5(%rdi)
jne 0x41b4
movsbq 0x6(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x6, %rdi
movq %rdi, 0x1673c(%rip)     # 0x1a6a8
movl $0xe, 0x16722(%rip)     # 0x1a698
jmp 0x41eb
movl $0x1d, 0x16713(%rip)    # 0x1a698
movsbq 0x1(%rdi), %rax
testb $0x4, (%rax,%r14)
je 0x4108
leaq 0xda4c(%rip), %rdi      # 0x119e8
callq 0x39d5
movq 0x16700(%rip), %rdi     # 0x1a6a8
jmp 0x4108
cmpb $0x74, 0x1(%rdi)
jne 0x3fdb
cmpb $0x72, 0x2(%rdi)
jne 0x3fdb
cmpb $0x69, 0x3(%rdi)
jne 0x3fdb
cmpb $0x6e, 0x4(%rdi)
jne 0x3fdb
cmpb $0x67, 0x5(%rdi)
jne 0x3fdb
movsbq 0x6(%rdi), %rax
testb $0x6, (%rax,%r14)
je 0x4208
movdqu (%rdi), %xmm0
movzwl 0x10(%rdi), %eax
movd %eax, %xmm1
pcmpeqb 0xd5b1(%rip), %xmm0     # 0x115a0
pcmpeqb 0xd5b9(%rip), %xmm1     # 0x115b0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x41b4
addq $0x12, %rdi
movq %rdi, 0x16693(%rip)     # 0x1a6a8
movl $0xb, 0x16679(%rip)     # 0x1a698
jmp 0x41eb
cmpb $0x6f, 0x1(%rdi)
jne 0x41b4
cmpb $0x69, 0x2(%rdi)
jne 0x41b4
cmpb $0x64, 0x3(%rdi)
jne 0x41b4
movsbq 0x4(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x4, %rdi
movq %rdi, 0x1664b(%rip)     # 0x1a6a8
movl $0x10, 0x16631(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x68, 0x1(%rdi)
jne 0x41b4
cmpb $0x69, 0x2(%rdi)
jne 0x41b4
cmpb $0x6c, 0x3(%rdi)
jne 0x41b4
cmpb $0x65, 0x4(%rdi)
jne 0x41b4
movsbq 0x5(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x5, %rdi
movq %rdi, 0x165f9(%rip)     # 0x1a6a8
movl $0xa, 0x165df(%rip)     # 0x1a698
jmp 0x41eb
movl $0x1e, %eax
jmp 0x4102
movl $0x1c, %eax
jmp 0x4102
movl $0x20, %eax
jmp 0x4102
movl $0x21, %eax
jmp 0x4102
movl $0x23, %eax
jmp 0x4102
movl $0x19, %eax
jmp 0x4102
movl $0x18, %eax
jmp 0x4102
movl $0x22, %eax
jmp 0x4102
movl $0x24, %eax
jmp 0x4102
movl $0x7, %eax
movl %eax, 0x16590(%rip)     # 0x1a698
incq %rdi
movq %rdi, 0x16596(%rip)     # 0x1a6a8
jmp 0x41eb
leaq 0xd8ee(%rip), %rdi      # 0x11a0c
callq 0x39d5
incq 0x1657e(%rip)           # 0x1a6a8
jmp 0x41eb
cmpb $0x74, 0x2(%rdi)
jne 0x41b4
movsbq 0x3(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x3, %rdi
movq %rdi, 0x1655c(%rip)     # 0x1a6a8
movl $0x6, 0x16542(%rip)     # 0x1a698
jmp 0x41eb
cmpb $0x74, 0x2(%rdi)
jne 0x41b4
cmpb $0x65, 0x3(%rdi)
jne 0x41b4
cmpb $0x6e, 0x4(%rdi)
jne 0x41b4
cmpb $0x64, 0x5(%rdi)
jne 0x41b4
cmpb $0x73, 0x6(%rdi)
jne 0x41b4
movsbq 0x7(%rdi), %rax
testb $0x6, (%rax,%r14)
jne 0x41b4
addq $0x7, %rdi
movq %rdi, 0x16518(%rip)     # 0x1a6a8
movl $0x17, 0x164fe(%rip)    # 0x1a698
jmp 0x41eb
cmpb $0x69, 0x2(%rdi)
jne 0x41b4
cmpb $0x73, 0x3(%rdi)
jne 0x41b4
movsbq 0x4(%rdi), %rax
testb $0x6, (%rax,%r14)
je 0x41f1
movq %rdi, %rsi
testb $0x6, %cl
je 0x41d5
movq %rdi, %rsi
movsbq 0x1(%rsi), %rax
incq %rsi
testb $0x6, (%rax,%r14)
jne 0x41bf
movq %rsi, 0x164d3(%rip)     # 0x1a6a8
callq 0x8145
movq %rax, 0x164bf(%rip)     # 0x1a6a0
movl $0x8, 0x164ad(%rip)     # 0x1a698
popq %rbx
popq %r14
popq %r15
retq
addq $0x4, %rdi
movq %rdi, 0x164ac(%rip)     # 0x1a6a8
movl $0x14, 0x16492(%rip)    # 0x1a698
jmp 0x41eb
addq $0x6, %rdi
movq %rdi, 0x16495(%rip)     # 0x1a6a8
movl $0x11, 0x1647b(%rip)    # 0x1a698
jmp 0x41eb
movsbl %dl, %edi
callq 0x4256
leaq 0xd813(%rip), %rdi      # 0x11a41
movl %eax, %esi
xorl %eax, %eax
callq 0x2030
leaq 0xf3e4(%rip), %rdi      # 0x13622
leaq 0xd800(%rip), %rsi      # 0x11a45
leaq 0xd801(%rip), %rcx      # 0x11a4d
movl $0x18b, %edx            # imm = 0x18B
callq 0x20b0