// File: /workspace/github_cpp_makefile_star2_O1/smallmuou[P]tinyhtml/tinyxmlparser.cpp
// Function: TiXmlBase::GetEntity(char const*, char*, int*, TiXmlEncoding)
const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding )
{
	// Presume an entity, and pull it out.
    TIXML_STRING ent;
	int i;
	*length = 0;

	if ( *(p+1) && *(p+1) == '#' && *(p+2) )
	{
		unsigned long ucs = 0;
		ptrdiff_t delta = 0;
		unsigned mult = 1;

		if ( *(p+2) == 'x' )
		{
			// Hexadecimal.
			if ( !*(p+3) ) return 0;

			const char* q = p+3;
			q = strchr( q, ';' );

			if ( !q || !*q ) return 0;

			delta = q-p;
			--q;

			while ( *q != 'x' )
			{
				if ( *q >= '0' && *q <= '9' )
					ucs += mult * (*q - '0');
				else if ( *q >= 'a' && *q <= 'f' )
					ucs += mult * (*q - 'a' + 10);
				else if ( *q >= 'A' && *q <= 'F' )
					ucs += mult * (*q - 'A' + 10 );
				else 
					return 0;
				mult *= 16;
				--q;
			}
		}
		else
		{
			// Decimal.
			if ( !*(p+2) ) return 0;

			const char* q = p+2;
			q = strchr( q, ';' );

			if ( !q || !*q ) return 0;

			delta = q-p;
			--q;

			while ( *q != '#' )
			{
				if ( *q >= '0' && *q <= '9' )
					ucs += mult * (*q - '0');
				else 
					return 0;
				mult *= 10;
				--q;
			}
		}
		if ( encoding == TIXML_ENCODING_UTF8 )
		{
			// convert the UCS to UTF-8
			ConvertUTF32ToUTF8( ucs, value, length );
		}
		else
		{
			*value = (char)ucs;
			*length = 1;
		}
		return p + delta + 1;
	}

	// Now try to match it.
	for( i=0; i<NUM_ENTITY; ++i )
	{
		if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
		{
			assert( strlen( entity[i].str ) == entity[i].strLength );
			*value = entity[i].chr;
			*length = 1;
			return ( p + entity[i].strLength );
		}
	}

	// So it wasn't an entity, its unrecognized, or something like that.
	*value = *p;	// Don't put back the last one, since we return it!
	//*length = 1;	// Leave unrecognized entities - this doesn't really work.
					// Just writes strange XML.
	return p+1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl $0x0, (%rdx)
cmpb $0x23, 0x1(%rdi)
jne 0x7072
movl %ecx, %ebp
movzbl 0x2(%rbx), %eax
cmpl $0x78, %eax
je 0x70f8
testl %eax, %eax
jne 0x718e
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x1(%rbx), %r12
movl $0xc, %r15d
leaq 0x90f3(%rip), %r14      # 0x10180
movq -0xc(%r15,%r14), %rbp
movl -0x4(%r15,%r14), %r13d
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x30b0
testl %eax, %eax
je 0x70c1
addq $0x10, %r15
cmpq $0x5c, %r15
jne 0x708d
movb (%rbx), %al
movq 0x8(%rsp), %rcx
movb %al, (%rcx)
jmp 0x71ee
movq %rbp, %rdi
callq 0x30a0
cmpq %r13, %rax
jne 0x7235
movb (%r15,%r14), %al
movq 0x8(%rsp), %rcx
movb %al, (%rcx)
movq 0x10(%rsp), %rax
movl $0x1, (%rax)
movl -0x4(%r15,%r14), %eax
addq %rax, %rbx
movq %rbx, %r12
jmp 0x71ee
cmpb $0x0, 0x3(%rbx)
je 0x71d9
leaq 0x3(%rbx), %rdi
movl $0x3b, %esi
callq 0x3080
testq %rax, %rax
je 0x71bc
cmpb $0x0, (%rax)
je 0x71bc
movq %rax, %r12
subq %rbx, %r12
movb -0x1(%rax), %sil
movb $0x1, %cl
cmpb $0x78, %sil
je 0x71b8
addq $-0x2, %rax
movl $0x1, %edx
xorl %edi, %edi
leal -0x30(%rsi), %r8d
cmpb $0x9, %r8b
ja 0x7153
movzbl %r8b, %esi
jmp 0x7177
leal -0x61(%rsi), %r8d
cmpb $0x5, %r8b
ja 0x7166
movzbl %sil, %esi
addl $-0x57, %esi
jmp 0x7177
leal -0x41(%rsi), %r8d
cmpb $0x5, %r8b
ja 0x71c1
movzbl %sil, %esi
addl $-0x37, %esi
imull %edx, %esi
addq %rsi, %rdi
shll $0x4, %edx
movb (%rax), %sil
decq %rax
cmpb $0x78, %sil
jne 0x7143
jmp 0x71c3
leaq 0x2(%rbx), %rdi
movl $0x3b, %esi
callq 0x3080
testq %rax, %rax
je 0x71bc
cmpb $0x0, (%rax)
je 0x71bc
movq %rax, %r12
subq %rbx, %r12
movb -0x1(%rax), %sil
cmpb $0x23, %sil
jne 0x7200
movb $0x1, %cl
xorl %edi, %edi
jmp 0x71c3
xorl %edi, %edi
xorl %r12d, %r12d
xorl %ecx, %ecx
testb %cl, %cl
je 0x71d9
cmpl $0x1, %ebp
jne 0x71de
movq %r15, %rsi
movq %r14, %rdx
callq 0x6bd0
jmp 0x71e8
xorl %r12d, %r12d
jmp 0x71ee
movb %dil, (%r15)
movl $0x1, (%r14)
addq %rbx, %r12
incq %r12
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $-0x2, %rax
movl $0x1, %edx
xorl %edi, %edi
addb $-0x30, %sil
cmpb $0xa, %sil
setb %cl
jae 0x71c3
movzbl %sil, %esi
imull %edx, %esi
addq %rsi, %rdi
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
movb (%rax), %sil
decq %rax
cmpb $0x23, %sil
jne 0x720b
jmp 0x71c3
leaq 0x38f7(%rip), %rdi      # 0xab33
leaq 0x382f(%rip), %rsi      # 0xaa72
leaq 0x3918(%rip), %rcx      # 0xab62
movl $0x207, %edx            # imm = 0x207
callq 0x30e0