// File: /workspace/github_c_makefile_star2_O0/gaultier[P]lox-c/lex.c
// Function: lex_scan_token
void lex_scan_token(Lex* lex, Token* token) {
    skip_whitespace(lex);
    const Lex start_lex = *lex;

    if (is_at_end(lex)) {
        init_token(lex, token, TOKEN_EOF, &start_lex);
        return;
    }

    const char c = advance(lex);

    if (isdigit(c)) {
        number(lex, token, &start_lex);
        return;
    }
    if (isalnum(c)) {
        identifier(lex, token, &start_lex);
        return;
    }

    switch (c) {
        case '{':
            init_token(lex, token, TOKEN_LEFT_BRACE, &start_lex);
            return;
        case '}':
            init_token(lex, token, TOKEN_RIGHT_BRACE, &start_lex);
            return;
        case '(':
            init_token(lex, token, TOKEN_LEFT_PAREN, &start_lex);
            return;
        case ')':
            init_token(lex, token, TOKEN_RIGHT_PAREN, &start_lex);
            return;
        case ';':
            init_token(lex, token, TOKEN_SEMICOLON, &start_lex);
            return;
        case ',':
            init_token(lex, token, TOKEN_COMMA, &start_lex);
            return;
        case '.':
            init_token(lex, token, TOKEN_DOT, &start_lex);
            return;
        case '-':
            init_token(lex, token, TOKEN_MINUS, &start_lex);
            return;
        case '+':
            init_token(lex, token, TOKEN_PLUS, &start_lex);
            return;
        case '*':
            init_token(lex, token, TOKEN_STAR, &start_lex);
            return;
        case '/':
            init_token(lex, token, TOKEN_SLASH, &start_lex);
            return;
        case '!':
            init_token(lex, token,
                       match(lex, '=') ? TOKEN_BANG_EQUAL : TOKEN_BANG,
                       &start_lex);
            return;
        case '=':
            init_token(lex, token,
                       match(lex, '=') ? TOKEN_EQUAL_EQUAL : TOKEN_EQUAL,
                       &start_lex);
            return;
        case '<':
            init_token(lex, token,
                       match(lex, '=') ? TOKEN_LESS_EQUAL : TOKEN_LESS,
                       &start_lex);
            return;
        case '>':
            init_token(lex, token,
                       match(lex, '=') ? TOKEN_GREATER_EQUAL : TOKEN_GREATER,
                       &start_lex);
            return;
        case '"':
            string(lex, token);
            return;
        default: {
            static char err[256] = "";
            memset(&err, 0, sizeof(err));

            snprintf(err, sizeof(err) - 1, "Unknown token `%c`", c);
            init_token_err(lex, token, err);
        }
    }
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq 0x80(%rsp), %rdi
callq 0x20a0
movq 0x80(%rsp), %rsi
leaq 0x50(%rsp), %rdi
movl $0x28, %edx
callq 0x1160
movq 0x80(%rsp), %rdi
callq 0x2170
testb $0x1, %al
jne 0x1cab
jmp 0x1ccc
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x28, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
callq 0x2210
movb %al, 0x4f(%rsp)
callq 0x11f0
movq (%rax), %rax
movsbl 0x4f(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1d17
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x2250
jmp 0x2091
callq 0x11f0
movq (%rax), %rax
movsbl 0x4f(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1d4f
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x23b0
jmp 0x2091
movsbl 0x4f(%rsp), %eax
addl $-0x21, %eax
movl %eax, %ecx
movq %rcx, 0x40(%rsp)
subl $0x5c, %eax
ja 0x2046
movq 0x40(%rsp), %rax
leaq 0x929d(%rip), %rcx      # 0xb010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x3, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x4, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x1, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x2, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x9, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x5, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x6, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x7, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0x8, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0xb, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl $0xa, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3d, %esi
callq 0x2490
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movb %al, %cl
movl $0xc, %edx
movl $0xd, %eax
testb $0x1, %cl
cmovnel %eax, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3d, %esi
callq 0x2490
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movb %al, %cl
movl $0xe, %edx
movl $0xf, %eax
testb $0x1, %cl
cmovnel %eax, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3d, %esi
callq 0x2490
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movb %al, %cl
movl $0x12, %edx
movl $0x13, %eax
testb $0x1, %cl
cmovnel %eax, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x80(%rsp), %rdi
movl $0x3d, %esi
callq 0x2490
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movb %al, %cl
movl $0x10, %edx
movl $0x11, %eax
testb $0x1, %cl
cmovnel %eax, %edx
leaq 0x50(%rsp), %rcx
callq 0x2190
jmp 0x2091
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x2500
jmp 0x2091
leaq 0xe0d3(%rip), %rdi      # 0x10120
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x10f0
movsbl 0x4f(%rsp), %ecx
leaq 0xe0bb(%rip), %rdi      # 0x10120
movl $0xff, %esi
leaq 0x9557(%rip), %rdx      # 0xb5c8
movb $0x0, %al
callq 0x10c0
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0xe094(%rip), %rdx      # 0x10120
callq 0x25e0
addq $0x88, %rsp
retq
nopl (%rax)