// File: /workspace/github_c_makefile_star2_O1/Yamsman[P]scc/src/lex.c
// Function: lex_eschar
char lex_eschar(lexer *lx) {
	//Simple escape characters
	s_pos loc = lx->tgt->loc;
	switch (lex_cur(lx)) {
		case '\'': lex_advc(lx); return '\'';
		case '\"': lex_advc(lx); return '\"';
		case '\?': lex_advc(lx); return '\?';
		case '\\': lex_advc(lx); return '\\';
		case 'a':  lex_advc(lx); return '\a';
		case 'b':  lex_advc(lx); return '\b';
		case 'f':  lex_advc(lx); return '\f';
		case 'n':  lex_advc(lx); return '\n';
		case 'r':  lex_advc(lx); return '\r';
		case 't':  lex_advc(lx); return '\t';
		case 'v':  lex_advc(lx); return '\v';
	}

	//Number escape character
	char cur = lex_cur(lx);
	unsigned int val = 0;
	if (cur == 'x') {
		//Hexadecimal
		cur = lex_advc(lx);
		if (!isxdigit(cur)) {
			c_warn(&loc, "\\x escape character without hexadecimal digits\n");
			return 0;
		}

		//Read number and check range
		while (isxdigit(cur)) {
			int dval = (!isdigit(cur)) ? 10 + (tolower(cur) - 'a') : (cur - '0');
			val = (val * 16) + dval;
			cur = lex_advc(lx);
		}
		if (val > 0xFF)
			c_warn(&loc, "hexadecimal escape char out of range\n");
	} else if (isdigit(cur) && cur != '8' && cur != '9') {
		//Octal
		//Read number
		while (isdigit(cur) && cur != '8' && cur != '9') {
			val = (val * 8) + (cur - '0');
			cur = lex_advc(lx);
		}

		//Check range
		if (val > 0377)
			c_warn(&loc, "octal escape char out of range\n");
	}

	return val;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x38(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups 0x28(%rax), %xmm0
movaps %xmm0, (%rsp)
cmpl $0x0, 0x2c(%rax)
jne 0x6dfd
movq %rbx, %rdi
callq 0x6776
movq (%rbx), %rax
movzbl 0x20(%rax), %ecx
cmpl $0x61, %ecx
jg 0x6e39
cmpl $0x3e, %ecx
jle 0x6e61
cmpl $0x3f, %ecx
je 0x6eb9
cmpl $0x5c, %ecx
je 0x6ea9
cmpl $0x61, %ecx
jne 0x6ec9
movq %rbx, %rdi
callq 0x6776
movb $0x7, %r14b
jmp 0x7052
leal -0x6e(%rcx), %edx
cmpl $0x8, %edx
ja 0x6e7b
leaq 0x6a5c(%rip), %rcx      # 0xd8a4
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq %rbx, %rdi
callq 0x6776
movb $0xa, %r14b
jmp 0x7052
cmpl $0x22, %ecx
je 0x6e99
cmpl $0x27, %ecx
jne 0x6ec9
movq %rbx, %rdi
callq 0x6776
movb $0x27, %r14b
jmp 0x7052
cmpl $0x62, %ecx
je 0x6f49
cmpl $0x66, %ecx
jne 0x6ec9
movq %rbx, %rdi
callq 0x6776
movb $0xc, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0x22, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0x5c, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0x3f, %r14b
jmp 0x7052
cmpl $0x0, 0x2c(%rax)
jne 0x6ed7
movq %rbx, %rdi
callq 0x6776
movq (%rbx), %rax
movsbq 0x20(%rax), %r15
cmpq $0x78, %r15
jne 0x6f59
movq %rbx, %rdi
callq 0x6776
movl %eax, %ebp
callq 0x3230
movq %rax, %r15
movq (%rax), %rax
movsbq %bpl, %r12
testb $0x10, 0x1(%rax,%r12,2)
jne 0x6fe3
leaq 0x6e2d(%rip), %rsi      # 0xdd3e
xorl %r14d, %r14d
jmp 0x7048
movq %rbx, %rdi
callq 0x6776
movb $0xb, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0xd, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0x9, %r14b
jmp 0x7052
movq %rbx, %rdi
callq 0x6776
movb $0x8, %r14b
jmp 0x7052
callq 0x3230
movq %rax, %r12
leal -0x3a(%r15), %eax
xorl %r14d, %r14d
cmpb $-0x3, %al
ja 0x7052
movq (%r12), %rcx
movzwl (%rcx,%r15,2), %ecx
andl $0x800, %ecx            # imm = 0x800
je 0x7052
xorl %r14d, %r14d
cmpb $-0x3, %al
ja 0x6fd1
movq (%r12), %rax
movzwl (%rax,%r15,2), %eax
andl $0x800, %eax            # imm = 0x800
je 0x6fd1
xorl %r14d, %r14d
movsbl %r15b, %eax
leal (%rax,%r14,8), %r14d
addl $-0x30, %r14d
movq %rbx, %rdi
callq 0x6776
movl %eax, %r15d
leal -0x3a(%r15), %eax
cmpb $-0x3, %al
ja 0x6fd1
movq (%r12), %rax
movsbq %r15b, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
jne 0x6f9f
cmpl $0x100, %r14d           # imm = 0x100
jb 0x7052
leaq 0x6db3(%rip), %rsi      # 0xdd94
jmp 0x7048
movq (%r15), %rax
movzwl (%rax,%r12,2), %eax
xorl %r14d, %r14d
btl $0xc, %eax
jae 0x7038
xorl %r14d, %r14d
btl $0xb, %eax
jb 0x700e
callq 0x3220
movq (%rax), %rax
movl (%rax,%r12,4), %eax
addl $-0x57, %eax
jmp 0x7015
movsbl %bpl, %eax
addl $-0x30, %eax
shll $0x4, %r14d
addl %eax, %r14d
movq %rbx, %rdi
callq 0x6776
movl %eax, %ebp
movq (%r15), %rax
movsbq %bpl, %r12
movzwl (%rax,%r12,2), %eax
btl $0xc, %eax
jb 0x6ff7
cmpl $0xff, %r14d
jbe 0x7052
leaq 0x6d26(%rip), %rsi      # 0xdd6e
movq %rsp, %rdi
xorl %eax, %eax
callq 0x3338
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq