// File: baziotis[P]minijava-cpp/lex.cpp
// Function: lexer_init(char const*, char const*)
void lexer_init(const char *input, const char *file) {
    int c;
    // Initialize charmap
    for (c = 0; c < 256; ++c) {
        if ('0' <= c && c <= '7') {
            charmap[c] |= OCT;
        }
        if (('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')) {
            charmap[c] |= HEX;
        }
        if ('0' <= c && c <= '9') {
            charmap[c] |= DEC;
            charmap[c] |= HEX;
        }
        
        switch(c) {
            case 0x9 ... 0xc:
            case 0x20:
                charmap[c] |= BLANK;
                break;
            case 0x21 ... 0x2f:
            case 0x3a ... 0x40:
            case 0x5b ... 0x5e:
            case 0x7b ... 0x7e:
                charmap[c] |= OTHER;
                break;
            case 'A' ... 'Z':
            case 'a' ... 'z':
            case '_':
                charmap[c] |= MIDCHAR;
                break;
        }
    }

    // Initialize digit_from_char
    for (c = '0'; c <= '9'; ++c) {
        digit_from_char[c] = c - '0';
    }
    for (c = 'a'; c <= 'f'; ++c) {
        digit_from_char[c] = c - 'a' + 10;
    }

    // Initialize location info
    loc.ln = 1;

    // Initialize the input
    init_input(input);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x100, -0x14(%rbp)     # imm = 0x100
jge 0x542b
movl $0x30, %eax
cmpl -0x14(%rbp), %eax
jg 0x5302
cmpl $0x37, -0x14(%rbp)
jg 0x5302
movslq -0x14(%rbp), %rcx
leaq 0x1f3d1(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x10, %eax
movb %al, %dl
leaq 0x1f3c1(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
movl $0x61, %eax
cmpl -0x14(%rbp), %eax
jg 0x5312
cmpl $0x66, -0x14(%rbp)
jle 0x5322
movl $0x41, %eax
cmpl -0x14(%rbp), %eax
jg 0x5340
cmpl $0x46, -0x14(%rbp)
jg 0x5340
movslq -0x14(%rbp), %rcx
leaq 0x1f393(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x8, %eax
movb %al, %dl
leaq 0x1f383(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
movl $0x30, %eax
cmpl -0x14(%rbp), %eax
jg 0x538c
cmpl $0x39, -0x14(%rbp)
jg 0x538c
movslq -0x14(%rbp), %rcx
leaq 0x1f365(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x4, %eax
movb %al, %dl
leaq 0x1f355(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
movslq -0x14(%rbp), %rcx
leaq 0x1f347(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x8, %eax
movb %al, %dl
leaq 0x1f337(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
movl -0x14(%rbp), %eax
addl $-0x9, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x75, %eax
ja 0x541b
movq -0x20(%rbp), %rax
leaq 0x14610(%rip), %rcx     # 0x199b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x53b3
movslq -0x14(%rbp), %rcx
leaq 0x1f302(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x1, %eax
movb %al, %dl
leaq 0x1f2f2(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
jmp 0x541b
jmp 0x53d5
jmp 0x53d7
jmp 0x53d9
movslq -0x14(%rbp), %rcx
leaq 0x1f2dc(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x20, %eax
movb %al, %dl
leaq 0x1f2cc(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
jmp 0x541b
jmp 0x53fb
jmp 0x53fd
movslq -0x14(%rbp), %rcx
leaq 0x1f2b8(%rip), %rax     # 0x246c0
movzbl (%rax,%rcx), %eax
orl $0x2, %eax
movb %al, %dl
leaq 0x1f2a8(%rip), %rax     # 0x246c0
movb %dl, (%rax,%rcx)
jmp 0x541d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x52c7
movl $0x30, -0x14(%rbp)
cmpl $0x39, -0x14(%rbp)
jg 0x545b
movl -0x14(%rbp), %eax
subl $0x30, %eax
movw %ax, %dx
movslq -0x14(%rbp), %rcx
leaq 0x1f374(%rip), %rax     # 0x247c0
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5432
movl $0x61, -0x14(%rbp)
cmpl $0x66, -0x14(%rbp)
jg 0x548e
movl -0x14(%rbp), %eax
subl $0x61, %eax
addl $0xa, %eax
movw %ax, %dx
movslq -0x14(%rbp), %rcx
leaq 0x1f341(%rip), %rax     # 0x247c0
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5462
movl $0x1, 0x1f208(%rip)     # 0x246a0
movq -0x8(%rbp), %rdi
callq 0x5280
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)