// File: /workspace/github_c_makefile_star2_O1/mahrr[P]raven/src/lexer.c
// Function: lexer_next
Token lexer_next(Lexer *lexer) {
#define New_Token(type) (new_token(lexer, type))

    skip_whitespace(lexer);

    lexer->start = lexer->current;

    if (at_end(lexer)) return New_Token(TOKEN_EOF);

    char c = advance(lexer);
    switch (c) {
    // One-Character Tokens
    case '+': return New_Token(TOKEN_PLUS);
    case '*': return New_Token(TOKEN_STAR);
    case '/': return New_Token(TOKEN_SLASH);
    case '%': return New_Token(TOKEN_PERCENT);
    case ',': return New_Token(TOKEN_COMMA);
    case '(': return New_Token(TOKEN_LEFT_PAREN);
    case ')': return New_Token(TOKEN_RIGHT_PAREN);
    case '[': return New_Token(TOKEN_LEFT_BRACKET);
    case ']': return New_Token(TOKEN_RIGHT_BRACKET);
    case '{': return New_Token(TOKEN_LEFT_BRACE);
    case ';': return New_Token(TOKEN_SEMICOLON);
    case '\\': return New_Token(TOKEN_BACK_SLASH);

    // Possible Two-Charachter Tokens
    case '-':
        if (match(lexer, '>')) return New_Token(TOKEN_ARROW);
        return New_Token(TOKEN_MINUS);

    case '=':
        if (match(lexer, '=')) return New_Token(TOKEN_EQUAL_EQUAL);
        return New_Token(TOKEN_EQUAL);

    case '<':
        if (match(lexer, '=')) return New_Token(TOKEN_LESS_EQUAL);
        return New_Token(TOKEN_LESS);

    case '>':
        if (match(lexer, '=')) return New_Token(TOKEN_GREATER_EQUAL);
        return New_Token(TOKEN_GREATER);

    case ':':
        if (match(lexer, ':')) return New_Token(TOKEN_COLON_COLON);
        return New_Token(TOKEN_COLON);

    case '.':
        if (match(lexer, '.')) return New_Token(TOKEN_DOT_DOT);
        return New_Token(TOKEN_DOT);

    case '!':
        if (match(lexer, '=')) return New_Token(TOKEN_BANG_EQUAL);
        break;

    // Strings
    case '}':
        if (match(lexer, '}')) return string_interpolated(lexer);
        return New_Token(TOKEN_RIGHT_BRACE);
    case '\'':
        return string(lexer);
    case '"':
        return string_interpolated(lexer);

    default:
        if (isalpha(c) || c == '_') return identifier(lexer);
        if (isdigit(c)) return number(lexer);
    }

    return error_token(lexer, "Unexpected symbol");
#undef New_Token
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %rax
addq $0x18, %rsi
movzbl (%rax), %ecx
cmpl $0xa, %ecx
jne 0x981f
incl (%rsi)
cmpb $0x0, (%rax)
je 0x980e
jmp 0x984f
cmpl $0x1f, %ecx
jg 0x9830
cmpl $0x9, %ecx
je 0x984f
cmpl $0xd, %ecx
je 0x984f
jmp 0x9858
cmpl $0x20, %ecx
je 0x984f
cmpl $0x23, %ecx
jne 0x9858
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x980e
cmpl $0xa, %ecx
je 0x980e
incq %rax
movq %rax, 0x10(%r14)
jmp 0x983a
incq %rax
movq %rax, 0x10(%r14)
jmp 0x980e
movq 0x10(%r14), %rdx
movq %rdx, 0x8(%r14)
cmpb $0x0, (%rdx)
je 0x98b3
leaq 0x1(%rdx), %rax
movq %rax, 0x10(%r14)
movzbl (%rdx), %r15d
cmpl $0x5a, %r15d
jg 0x98ce
leal -0x21(%r15), %eax
cmpl $0x1d, %eax
ja 0x9a90
leaq 0x24b1(%rip), %rcx      # 0xbd3c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %rax
cmpb $0x3d, (%rax)
jne 0x9b46
incq %rax
movq %rax, 0x10(%r14)
movl $0x21, (%rbx)
jmp 0x9b1c
movl $0x36, (%rbx)
movl (%rsi), %eax
movl %eax, 0x14(%rbx)
movq %rdx, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
jmp 0x9b30
cmpl $0x5c, %r15d
jle 0x9916
cmpl $0x5d, %r15d
je 0x9a7a
cmpl $0x7b, %r15d
je 0x9a6f
cmpl $0x7d, %r15d
jne 0x9a90
movq 0x10(%r14), %rax
cmpb $0x7d, (%rax)
jne 0x9b16
incq %rax
movq %rax, 0x10(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9b67
jmp 0x9b30
cmpl $0x5b, %r15d
je 0x9a85
cmpl $0x5c, %r15d
jne 0x9a90
movl $0x2e, (%rbx)
jmp 0x9b1c
movl $0x10, (%rbx)
jmp 0x9b1c
movl $0x26, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rax
cmpb $0x3d, (%rax)
jne 0x9ae6
incq %rax
movq %rax, 0x10(%r14)
movl $0x20, (%rbx)
jmp 0x9b1c
movl $0x25, (%rbx)
jmp 0x9b1c
movl $0x28, (%rbx)
jmp 0x9b1c
movl $0x29, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rax
cmpb $0x3d, (%rax)
jne 0x9aee
incq %rax
movq %rax, 0x10(%r14)
movl $0x1c, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rax
cmpb $0x3e, (%rax)
jne 0x9af6
incq %rax
movq %rax, 0x10(%r14)
movl $0x24, (%rbx)
jmp 0x9b1c
movl $0x14, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rcx
movl %ecx, %eax
subl %edx, %eax
incl %eax
incq %rcx
movzbl -0x1(%rcx), %edi
cmpl $0x27, %edi
je 0x9acf
testl %edi, %edi
je 0x9b5a
movq %rcx, 0x10(%r14)
jmp 0x99dc
movq 0x10(%r14), %rax
cmpb $0x3d, (%rax)
jne 0x9afe
incq %rax
movq %rax, 0x10(%r14)
movl $0x1e, (%rbx)
jmp 0x9b1c
movl $0x12, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rax
cmpb $0x3a, (%rax)
jne 0x9b06
incq %rax
movq %rax, 0x10(%r14)
movl $0x1a, (%rbx)
jmp 0x9b1c
movl $0x13, (%rbx)
jmp 0x9b1c
movq 0x10(%r14), %rax
cmpb $0x2e, (%rax)
jne 0x9b0e
incq %rax
movq %rax, 0x10(%r14)
movl $0x19, (%rbx)
jmp 0x9b1c
movl $0x2a, (%rbx)
jmp 0x9b1c
movl $0x2d, (%rbx)
jmp 0x9b1c
movl $0x2c, (%rbx)
jmp 0x9b1c
callq 0x2220
cmpb $0x5f, %r15b
je 0x9b39
movsbq %r15b, %rcx
movq (%rax), %rax
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
andl $0x400, %ecx            # imm = 0x400
jne 0x9b39
btl $0xb, %eax
jae 0x9b46
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9fe2
jmp 0x9b30
movq %rcx, 0x10(%r14)
movl $0x31, (%rbx)
movl 0x18(%r14), %ecx
movl %ecx, 0x14(%rbx)
movq %rdx, 0x8(%rbx)
jmp 0x9b2d
movl $0x1f, (%rbx)
jmp 0x9b1c
movl $0x1b, (%rbx)
jmp 0x9b1c
movl $0x11, (%rbx)
jmp 0x9b1c
movl $0x1d, (%rbx)
jmp 0x9b1c
movl $0x27, (%rbx)
jmp 0x9b1c
movl $0x15, (%rbx)
jmp 0x9b1c
movl $0x2b, (%rbx)
movl 0x18(%r14), %eax
movl %eax, 0x14(%rbx)
movq %rdx, 0x8(%rbx)
movl 0x10(%r14), %eax
subl %edx, %eax
movl %eax, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9c18
jmp 0x9b30
leaq 0x22c3(%rip), %rdx      # 0xbe10
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2529
jmp 0x9b30
movq %r14, %rdi
movq %rbx, %rcx
callq 0x257b
jmp 0x9b30