// File: /workspace/github_c_makefile_star2_O0/Mithreindeir[P]ewcc/src/frontend/lexer.c
// Function: lex_r
enum token_type lex_r(char **saveptr, int *tlen, char **ls, int *ln)
{
	char *str = *saveptr;
	while (isspace(*str))
		*ln += *str == '\n' ? (*ls = str, 1) : 0, str++;

	enum token_type t = t_none;
	int len = 0;
	size_t ntoken_pairs =
	    (size_t) ((sizeof(token_pairs) / sizeof(struct token_pair)));
	/*Match against static tokens */
	for (unsigned int i = 0; i < ntoken_pairs; i++) {
		if (!strncmp
		    (str, token_pairs[i].match, token_pairs[i].len)) {
			len = token_pairs[i].len;
			t = token_pairs[i].type;
			break;
		}
	}
	/*Check for ident, string, numeric, etc */
	if (t == t_none) {
		if (isdigit(*str)) {
			t = t_numeric;
			while (str[len] && isdigit(str[len]))
				len++;
		} else if (isalpha(*str) || *str == '_') {
			t = t_ident;
			while (str[len]
			       && (isalpha(str[len]) || str[len] == '_'))
				len++;
		}
	}

	*saveptr = str + len;
	*tlen = len;
	return t;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
callq 0x2110
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x9594
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x9574
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x957b
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x957b
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x9533
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x22, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpq -0x38(%rbp), %rax
jae 0x9639
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %ecx
leaq 0x64f6(%rip), %rax      # 0xfac0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movl -0x3c(%rbp), %eax
movl %eax, %ecx
leaq 0x64df(%rip), %rax      # 0xfac0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rdx
callq 0x2040
cmpl $0x0, %eax
jne 0x9629
movl -0x3c(%rbp), %eax
movl %eax, %ecx
leaq 0x64be(%rip), %rax      # 0xfac0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, %ecx
leaq 0x64a5(%rip), %rax      # 0xfac0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x9639
jmp 0x962b
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x95b1
cmpl $0x0, -0x2c(%rbp)
jne 0x976b
callq 0x2110
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x96c2
movl $0x1, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x41(%rbp)
je 0x96a9
callq 0x2110
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x96b2
jmp 0x96bd
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x966a
jmp 0x9769
callq 0x2110
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x96ee
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x9767
movl $0xc, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x42(%rbp)
je 0x9751
callq 0x2110
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x400, %ecx            # imm = 0x400
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x43(%rbp)
jne 0x974b
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5f, %eax
sete %al
movb %al, -0x43(%rbp)
movb -0x43(%rbp), %al
movb %al, -0x42(%rbp)
movb -0x42(%rbp), %al
testb $0x1, %al
jne 0x975a
jmp 0x9765
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x96f5
jmp 0x9767
jmp 0x9769
jmp 0x976b
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop