// File: /workspace/github_c_makefile_star2_O3/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 0x6dca
movq %rbx, %rdi
callq 0x6798
movq (%rbx), %rax
movb 0x20(%rax), %r15b
movzbl %r15b, %ecx
cmpl $0x61, %ecx
jg 0x6e07
cmpl $0x3e, %ecx
jle 0x6e2f
cmpl $0x3f, %ecx
je 0x6e87
cmpl $0x5c, %ecx
je 0x6e77
cmpl $0x61, %ecx
jne 0x6e97
movq %rbx, %rdi
callq 0x6798
movb $0x7, %r14b
jmp 0x6ffc
leal -0x6e(%rcx), %edx
cmpl $0x8, %edx
ja 0x6e49
leaq 0x6a8e(%rip), %rcx      # 0xd8a4
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq %rbx, %rdi
callq 0x6798
movb $0xa, %r14b
jmp 0x6ffc
cmpl $0x22, %ecx
je 0x6e67
cmpl $0x27, %ecx
jne 0x6e97
movq %rbx, %rdi
callq 0x6798
movb $0x27, %r14b
jmp 0x6ffc
cmpl $0x62, %ecx
je 0x6f19
cmpl $0x66, %ecx
jne 0x6e97
movq %rbx, %rdi
callq 0x6798
movb $0xc, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0x22, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0x5c, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0x3f, %r14b
jmp 0x6ffc
cmpl $0x0, 0x2c(%rax)
jne 0x6eac
movq %rbx, %rdi
callq 0x6798
movq (%rbx), %rax
movb 0x20(%rax), %r15b
cmpb $0x78, %r15b
jne 0x6f29
movq %rbx, %rdi
callq 0x6798
movl %eax, %ebp
callq 0x3230
movq %rax, %r15
movq (%rax), %rax
movsbq %bpl, %r12
movzwl (%rax,%r12,2), %eax
btl $0xc, %eax
jb 0x6f9e
leaq 0x6e5d(%rip), %rsi      # 0xdd3e
xorl %r14d, %r14d
jmp 0x6ff2
movq %rbx, %rdi
callq 0x6798
movb $0xb, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0xd, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0x9, %r14b
jmp 0x6ffc
movq %rbx, %rdi
callq 0x6798
movb $0x8, %r14b
jmp 0x6ffc
callq 0x3230
movq %rax, %r12
leal -0x3a(%r15), %eax
xorl %r14d, %r14d
cmpb $-0x3, %al
ja 0x6ffc
movq (%r12), %rax
movsbq %r15b, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
je 0x6ffc
xorl %r14d, %r14d
movsbl %r15b, %eax
leal (%rax,%r14,8), %r14d
addl $-0x30, %r14d
movq %rbx, %rdi
callq 0x6798
movl %eax, %r15d
leal -0x3a(%r15), %eax
cmpb $-0x3, %al
ja 0x6f8c
movq (%r12), %rax
movsbq %r15b, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
jne 0x6f5a
cmpl $0x100, %r14d           # imm = 0x100
jb 0x6ffc
leaq 0x6df8(%rip), %rsi      # 0xdd94
jmp 0x6ff2
xorl %r14d, %r14d
btl $0xb, %eax
jb 0x6fb8
callq 0x3220
movq (%rax), %rax
movl (%rax,%r12,4), %eax
addl $-0x57, %eax
jmp 0x6fbf
movsbl %bpl, %eax
addl $-0x30, %eax
shll $0x4, %r14d
addl %eax, %r14d
movq %rbx, %rdi
callq 0x6798
movl %eax, %ebp
movq (%r15), %rax
movsbq %bpl, %r12
movzwl (%rax,%r12,2), %eax
btl $0xc, %eax
jb 0x6fa1
cmpl $0xff, %r14d
jbe 0x6ffc
leaq 0x6d7c(%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