// File: /workspace/github_c_makefile_star2_O0/MikeGray-APH[P]LibLouisAPH/source/utf-convert.c
// Function: utf16_convert_escapes
int utf16_convert_escapes(unichar *uchars, const int uchars_len)
{
	int crs, off, hex, i;

	if(uchars_len < 2)
		return uchars_len;

	crs =
	off = 0;
	while(off < uchars_len)
	{
		if(!uchars[off])
			break;
		else if(uchars[off] == u'\\')
		{
			off++;
			if(!uchars[off])
				return 0;
			else if(off >= uchars_len)
				return 0;
			switch(uchars[off])
			{
			default:    uchars[crs++] = uchars[off++];  break;
			case u'n':  uchars[crs++] = u'\n';  off++;  break;
			case u'r':  uchars[crs++] = u'\r';  off++;  break;
			case u't':  uchars[crs++] = u'\t';  off++;  break;
			case u's':  uchars[crs++] = u' ';   off++;  break;

			case u'x':  case u'X':  case u'u':  case u'U':

				if(off + 5 > uchars_len)
					return 0;
				hex = 0;
				off++;
				for(i = 0; i < 4; i++)
				{
					if(!uchars[off])
						return 0;
					else if(uchars[off] >= u'0' && uchars[off] <= u'9')
						hex += ((uchars[off++] - u'0')) << ((3 - i) * 4);
					else if(uchars[off] >= u'A' && uchars[off] <= u'F')
						hex += ((uchars[off++] - u'A') + 10) << ((3 - i) * 4);
					else if(uchars[off] >= u'a' && uchars[off] <= u'f')
						hex += ((uchars[off++] - u'a') + 10) << ((3 - i) * 4);
				}
				uchars[crs++] = hex;
				break;
			}
		}
		else
			uchars[crs++] = uchars[off++];
	}

	if(crs <= uchars_len)
		uchars[crs] = 0;
#ifdef DEBUG
	else
		ASSERT(0)
#endif
	return crs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x1360
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x16a8
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1685
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cmpw $0x0, (%rax,%rcx,2)
jne 0x138e
jmp 0x1685
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x5c, %eax
jne 0x1652
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cmpw $0x0, (%rax,%rcx,2)
jne 0x13c7
movl $0x0, -0x4(%rbp)
jmp 0x16a8
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x13db
movl $0x0, -0x4(%rbp)
jmp 0x16a8
jmp 0x13dd
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
addl $-0x55, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x23, %eax
ja 0x140b
movq -0x30(%rbp), %rax
leaq 0x1cc0e(%rip), %rcx     # 0x1e010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movw (%rax,%rcx,2), %dx
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x1650
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movw $0xa, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1650
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movw $0xd, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1650
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movw $0x9, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1650
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movw $0x20, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1650
movl -0x1c(%rbp), %eax
addl $0x5, %eax
cmpl -0x14(%rbp), %eax
jle 0x14eb
movl $0x0, -0x4(%rbp)
jmp 0x16a8
movl $0x0, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0x1634
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cmpw $0x0, (%rax,%rcx,2)
jne 0x1527
movl $0x0, -0x4(%rbp)
jmp 0x16a8
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x30, %eax
jl 0x157a
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x39, %eax
jg 0x157a
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
subl $0x30, %eax
movl $0x3, %ecx
subl -0x24(%rbp), %ecx
shll $0x2, %ecx
shll %cl, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x1622
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x41, %eax
jl 0x15cd
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x46, %eax
jg 0x15cd
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
subl $0x41, %eax
addl $0xa, %eax
movl $0x3, %ecx
subl -0x24(%rbp), %ecx
shll $0x2, %ecx
shll %cl, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x1620
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x61, %eax
jl 0x161e
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
cmpl $0x66, %eax
jg 0x161e
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
subl $0x61, %eax
addl $0xa, %eax
movl $0x3, %ecx
subl -0x24(%rbp), %ecx
shll $0x2, %ecx
shll %cl, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x1620
jmp 0x1622
jmp 0x1624
jmp 0x1626
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1502
movl -0x20(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x167e
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movw (%rax,%rcx,2), %dx
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x1680
jmp 0x136e
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x169d
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movw $0x0, (%rax,%rcx,2)
jmp 0x16a2
callq 0x1050
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)