// File: smallmuou[P]tinyhtml/tinyxml.cpp
// Function: TiXmlBase::EncodeString(TiXmlString const&, TiXmlString*)
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
{
	int i=0;

	while( i<(int)str.length() )
	{
		unsigned char c = (unsigned char) str[i];

		if (    c == '&' 
		     && i < ( (int)str.length() - 2 )
			 && str[i+1] == '#'
			 && str[i+2] == 'x' )
		{
			// Hexadecimal character reference.
			// Pass through unchanged.
			// &#xA9;	-- copyright symbol, for example.
			//
			// The -1 is a bug fix from Rob Laveaux. It keeps
			// an overflow from happening if there is no ';'.
			// There are actually 2 ways to exit this loop -
			// while fails (error case) and break (semicolon found).
			// However, there is no mechanism (currently) for
			// this function to return an error.
			while ( i<(int)str.length()-1 )
			{
				outString->append( str.c_str() + i, 1 );
				++i;
				if ( str[i] == ';' )
					break;
			}
		}
		else if ( c == '&' )
		{
			outString->append( entity[0].str, entity[0].strLength );
			++i;
		}
		else if ( c == '<' )
		{
			outString->append( entity[1].str, entity[1].strLength );
			++i;
		}
		else if ( c == '>' )
		{
			outString->append( entity[2].str, entity[2].strLength );
			++i;
		}
		else if ( c == '\"' )
		{
			outString->append( entity[3].str, entity[3].strLength );
			++i;
		}
		else if ( c == '\'' )
		{
			outString->append( entity[4].str, entity[4].strLength );
			++i;
		}
		else if ( c < 32 )
		{
			// Easy pass at non-alpha/numeric/symbol
			// Below 32 is symbolic.
			char buf[ 32 ];
			
			#if defined(TIXML_SNPRINTF)		
				TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
			#else
				sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
			#endif		

			//*ME:	warning C4267: convert 'size_t' to 'int'
			//*ME:	Int-Cast to make compiler happy ...
			outString->append( buf, (int)strlen( buf ) );
			++i;
		}
		else
		{
			//char realc = (char) c;
			//outString->append( &realc, 1 );
			*outString += (char) c;	// somewhat more efficient function call.
			++i;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7780
movq %rax, %rcx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jge 0x366f
movq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x77a0
movb (%rax), %al
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
cmpl $0x26, %eax
jne 0x34d9
movl -0x14(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7780
movq %rax, %rcx
movl -0x48(%rbp), %eax
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0x34d9
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x77a0
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x34d9
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x77a0
movsbl (%rax), %eax
cmpl $0x78, %eax
jne 0x34d9
jmp 0x346d
movl -0x14(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7780
movq %rax, %rcx
movl -0x4c(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x34d4
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7810
movq -0x58(%rbp), %rdi
movq %rax, %rsi
movslq -0x14(%rbp), %rax
addq %rax, %rsi
movl $0x1, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x77a0
movsbl (%rax), %eax
cmpl $0x3b, %eax
jne 0x34d2
jmp 0x34d4
jmp 0x346d
jmp 0x366a
movzbl -0x15(%rbp), %eax
cmpl $0x26, %eax
jne 0x350f
movq -0x10(%rbp), %rdi
leaq 0x10c83(%rip), %rax     # 0x14170
movq (%rax), %rsi
leaq 0x10c79(%rip), %rax     # 0x14170
movl 0x8(%rax), %eax
movl %eax, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3668
movzbl -0x15(%rbp), %eax
cmpl $0x3c, %eax
jne 0x3546
movq -0x10(%rbp), %rdi
leaq 0x10c4d(%rip), %rax     # 0x14170
movq 0x10(%rax), %rsi
leaq 0x10c42(%rip), %rax     # 0x14170
movl 0x18(%rax), %eax
movl %eax, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3666
movzbl -0x15(%rbp), %eax
cmpl $0x3e, %eax
jne 0x357d
movq -0x10(%rbp), %rdi
leaq 0x10c16(%rip), %rax     # 0x14170
movq 0x20(%rax), %rsi
leaq 0x10c0b(%rip), %rax     # 0x14170
movl 0x28(%rax), %eax
movl %eax, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3664
movzbl -0x15(%rbp), %eax
cmpl $0x22, %eax
jne 0x35b4
movq -0x10(%rbp), %rdi
leaq 0x10bdf(%rip), %rax     # 0x14170
movq 0x30(%rax), %rsi
leaq 0x10bd4(%rip), %rax     # 0x14170
movl 0x38(%rax), %eax
movl %eax, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3662
movzbl -0x15(%rbp), %eax
cmpl $0x27, %eax
jne 0x35e8
movq -0x10(%rbp), %rdi
leaq 0x10ba8(%rip), %rax     # 0x14170
movq 0x40(%rax), %rsi
leaq 0x10b9d(%rip), %rax     # 0x14170
movl 0x48(%rax), %eax
movl %eax, %edx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3660
movzbl -0x15(%rbp), %eax
cmpl $0x20, %eax
jge 0x3646
leaq -0x40(%rbp), %rdi
movzbl -0x15(%rbp), %ecx
andl $0xff, %ecx
movl $0x20, %esi
leaq 0xa9f9(%rip), %rdx      # 0xe004
movb $0x0, %al
callq 0x3230
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x30a0
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movslq %eax, %rdx
callq 0xbe10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x365e
movb -0x15(%rbp), %al
movq -0x10(%rbp), %rdi
movsbl %al, %esi
callq 0x7830
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3660
jmp 0x3662
jmp 0x3664
jmp 0x3666
jmp 0x3668
jmp 0x366a
jmp 0x33d7
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)