// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x9108(%rip), %rax      # 0xf258
movq %rax, 0x10(%rsp)
andl $0x0, (%rdx)
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x23, 0x1(%rdi)
jne 0x617b
movl %ecx, %ebp
movzbl 0x2(%rbx), %eax
cmpl $0x78, %eax
je 0x6200
testl %eax, %eax
jne 0x6280
movq %r15, %r12
movq %r14, (%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%rsp)
xorl %ecx, %ecx
leaq 0x8fec(%rip), %r15      # 0xf180
leaq 0x10(%rcx), %r14
cmpq $0x60, %r14
je 0x61f0
movq (%rcx,%r15), %rbp
movl 0x8(%rcx,%r15), %r13d
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x30b0
movq %r14, %rcx
testl %eax, %eax
jne 0x6194
movq %rbp, %rdi
callq 0x30a0
cmpq %r13, %rax
jne 0x630b
movb -0x4(%r14,%r15), %al
movb %al, (%r12)
movq (%rsp), %rax
movl $0x1, (%rax)
movl -0x8(%r14,%r15), %eax
addq %rax, %rbx
movq %rbx, %r12
jmp 0x62ef
movb (%rbx), %al
movb %al, (%r12)
movq 0x8(%rsp), %r12
jmp 0x62ef
cmpb $0x0, 0x3(%rbx)
je 0x62c7
leaq 0x3(%rbx), %rdi
pushq $0x3b
popq %rsi
callq 0x3080
testq %rax, %rax
je 0x62c7
cmpb $0x0, (%rax)
je 0x62c7
movq %rax, %r13
subq %rbx, %r13
decq %rax
pushq $0x1
popq %rcx
xorl %r12d, %r12d
xorl %edi, %edi
movzbl (%rax), %edx
cmpl $0x78, %edx
je 0x62cc
leal -0x30(%rdx), %esi
cmpb $0x9, %sil
ja 0x6254
movzbl %sil, %edx
jmp 0x6272
leal -0x61(%rdx), %esi
cmpb $0x5, %sil
ja 0x6262
addl $-0x57, %edx
jmp 0x6272
leal -0x41(%rdx), %esi
cmpb $0x5, %sil
ja 0x62ef
addl $-0x37, %edx
imull %ecx, %edx
addq %rdx, %rdi
shll $0x4, %ecx
decq %rax
jmp 0x6239
leaq 0x2(%rbx), %rdi
pushq $0x3b
popq %rsi
callq 0x3080
testq %rax, %rax
je 0x62c7
cmpb $0x0, (%rax)
je 0x62c7
movq %rax, %r13
subq %rbx, %r13
decq %rax
pushq $0x1
popq %rcx
xorl %r12d, %r12d
xorl %edi, %edi
movb (%rax), %dl
cmpb $0x23, %dl
je 0x62cc
addb $-0x30, %dl
cmpb $0x9, %dl
ja 0x62ef
movzbl %dl, %edx
imull %ecx, %edx
addq %rdx, %rdi
imull $0xa, %ecx, %ecx
decq %rax
jmp 0x62a7
xorl %r12d, %r12d
jmp 0x62ef
cmpl $0x1, %ebp
jne 0x62de
movq %r15, %rsi
movq %r14, %rdx
callq 0x5d68
jmp 0x62e8
movb %dil, (%r15)
movl $0x1, (%r14)
leaq (%rbx,%r13), %r12
incq %r12
leaq 0x10(%rsp), %rdi
callq 0x5cd8
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x33cd(%rip), %rdi      # 0x96df
leaq 0x3305(%rip), %rsi      # 0x961e
leaq 0x33ee(%rip), %rcx      # 0x970e
movl $0x207, %edx            # imm = 0x207
callq 0x30e0