// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/ripent/ripent.cpp
// Function: ParseEntityData(char const*, int, char const*, int, char const*, int)
void ParseEntityData(const char *cTab, int iTabLength, const char *cNewLine, int iNewLineLength, const char *cTerminator, int iTerminatorLength)
{
	CEntityList EntityList;		// Parsed entities.

	int iIndex = 0;				// Current char in g_dentdata.
	int iLine = 0;				// Current line in g_dentdata.

	char cError[256] = "";

	try
	{
		//
		// Parse entity data.
		//

		Log("\nParsing entity data.\n");

		while(true)
		{
			// Parse the start of an entity.
			if(!ScanForToken('{', iIndex, iLine, false, false))
			{
				if(iIndex == g_entdatasize)
				{
					// We read all the entities.
					break;
				}
				else
				{
					sprintf_s(cError, "expected token %s on line %d.", "{", iLine);
					throw cError;
				}
			}

			CEntityPairList *EntityPairList = new CEntityPairList();

			// Parse the rest of the entity.
			while(true)
			{
				// Parse the key and value.
				for(int j = 0; j < 2; j++)
				{
					int iStart;
					// Parse the start of a string.
					if(!ScanForToken('\"', iIndex, iLine, false, false, &iStart))
					{
						sprintf_s(cError, "expected token %s on line %d.", "\"", iLine);
						throw cError;
					}

					int iEnd;
					// Parse the end of a string.
					if(!ScanForToken('\"', iIndex, iLine, true, true, &iEnd))
					{
						sprintf_s(cError, "expected token %s on line %d.", "\"", iLine);
						throw cError;
					}

					// Extract the string.
					int iLength = iEnd - iStart - 1;
					char *cString = new char[iLength + 1];
					memcpy(cString, &g_dentdata[iStart + 1], iLength);
					cString[iLength] = '\0';

					// Save it.
					EntityPairList->push_back(cString);
				}

				// Parse the end of an entity.
				if(!ScanForToken('}', iIndex, iLine, false, false))
				{
					if(g_dentdata[iIndex] == '\"')
					{
						// We arn't done the entity yet.
						continue;
					}
					else
					{
						sprintf_s(cError, "expected token %s on line %d.", "}", iLine);
						throw cError;
					}
				}

				// We read the entity.
				EntityList.push_back(EntityPairList);
				break;
			}
		}

#ifdef ZHLT_64BIT_FIX
		Log("%d entities parsed.\n", (int)EntityList.size());
#else
		Log("%d entities parsed.\n", EntityList.size());
#endif

		//
		// Calculate new data length.
		//

		int iNewLength = 0;

		for(CEntityList::iterator i = EntityList.begin(); i != EntityList.end(); ++i)
		{
			// Opening brace.
			iNewLength += 1;

			// New line.
			iNewLength += iNewLineLength;

			CEntityPairList *EntityPairList = *i;

			for(CEntityPairList::iterator j = EntityPairList->begin(); j != EntityPairList->end(); ++j)
			{
				// Tab.
				iNewLength += iTabLength;

				// String.
				iNewLength += 1;
				iNewLength += (int)strlen(*j);
				iNewLength += 1;

				// String seperator.
				iNewLength += 1;

				++j;

				// String.
				iNewLength += 1;
				iNewLength += (int)strlen(*j);
				iNewLength += 1;

				// New line.
				iNewLength += iNewLineLength;
			}

			// Closing brace.
			iNewLength += 1;

			// New line.
			iNewLength += iNewLineLength;
		}

		// Terminator.
		iNewLength += iTerminatorLength;

		//
		// Check our parsed data.
		//

		assume(iNewLength != 0, "No entity data.");
		assume(iNewLength < sizeof(g_dentdata), "Entity data size exceedes dentdata limit.");

		//
		// Clear current data.
		//

		g_entdatasize = 0;

		//
		// Fill new data.
		//

		Log("Formating entity data.\n\n");

		for(CEntityList::iterator i = EntityList.begin(); i != EntityList.end(); ++i)
		{
			// Opening brace.
			g_dentdata[g_entdatasize] = '{';
			g_entdatasize += 1;

			// New line.
			memcpy(&g_dentdata[g_entdatasize], cNewLine, iNewLineLength);
			g_entdatasize += iNewLineLength;

			CEntityPairList *EntityPairList = *i;

			for(CEntityPairList::iterator j = EntityPairList->begin(); j != EntityPairList->end(); ++j)
			{
				// Tab.
				memcpy(&g_dentdata[g_entdatasize], cTab, iTabLength);
				g_entdatasize += iTabLength;

				// String.
				g_dentdata[g_entdatasize] = '\"';
				g_entdatasize += 1;
				memcpy(&g_dentdata[g_entdatasize], *j, strlen(*j));
				g_entdatasize += (int)strlen(*j);
				g_dentdata[g_entdatasize] = '\"';
				g_entdatasize += 1;

				// String seperator.
				g_dentdata[g_entdatasize] = ' ';
				g_entdatasize += 1;

				++j;

				// String.
				g_dentdata[g_entdatasize] = '\"';
				g_entdatasize += 1;
				memcpy(&g_dentdata[g_entdatasize], *j, strlen(*j));
				g_entdatasize += (int)strlen(*j);
				g_dentdata[g_entdatasize] = '\"';
				g_entdatasize += 1;

				// New line.
				memcpy(&g_dentdata[g_entdatasize], cNewLine, iNewLineLength);
				g_entdatasize += iNewLineLength;
			}

			// Closing brace.
			g_dentdata[g_entdatasize] = '}';
			g_entdatasize += 1;

			// New line.
			memcpy(&g_dentdata[g_entdatasize], cNewLine, iNewLineLength);
			g_entdatasize += iNewLineLength;
		}

		// Terminator.
		memcpy(&g_dentdata[g_entdatasize], cTerminator, iTerminatorLength);
		g_entdatasize += iTerminatorLength;

		//
		// Delete entity data.
		//

		for(CEntityList::iterator i = EntityList.begin(); i != EntityList.end(); ++i)
		{
			CEntityPairList *EntityPairList = *i;

			for(CEntityPairList::iterator j = EntityPairList->begin(); j != EntityPairList->end(); ++j)
			{
				delete []*j;
			}

			delete EntityPairList;
		}

		//return true;
	}
	catch(...)
	{
		//
		// Delete entity data.
		//

		for(CEntityList::iterator i = EntityList.begin(); i != EntityList.end(); ++i)
		{
			CEntityPairList *EntityPairList = *i;

			for(CEntityPairList::iterator j = EntityPairList->begin(); j != EntityPairList->end(); ++j)
			{
				delete []*j;
			}

			delete EntityPairList;
		}

		// If we threw the error cError wont be null, this is
		// a message, print it.
		if(*cError != '\0')
		{
			Error(cError);
		}
		Error("unknowen exception.");

		//return false;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movl %r9d, 0x14(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r12
leaq 0x18(%rsp), %r15
movq %r15, 0x8(%r15)
movq %r15, (%r15)
movq $0x0, 0x10(%r15)
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movl %eax, (%rsp)
leaq 0x80(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x3160
leaq 0x59a9(%rip), %rdi      # 0x12490
xorl %eax, %eax
callq 0x8aee
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
movl $0x7b, %edi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc9d4
testb %al, %al
movq %rbx, 0x40(%rsp)
movq %r14, 0x30(%rsp)
movq %r12, 0x70(%rsp)
je 0xccc0
leaq 0x81380a(%rip), %r13    # 0x820330
movl $0x18, %edi
callq 0x3280
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0x8(%rax)
movq %rax, (%rax)
xorl %r14d, %r14d
movl $0x22, %edi
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x4c(%rsp), %r9
callq 0xc9d4
testb %al, %al
je 0xd097
movl 0x4(%rsp), %edi
leaq 0x8137aa(%rip), %rax    # 0x820324
movl (%rax), %eax
cmpl %eax, %edi
jge 0xcbd5
movslq %eax, %rsi
movl (%rsp), %edx
movslq 0x4(%rsp), %rcx
movslq %edi, %rdi
movzbl (%r13,%rdi), %edi
cmpl $0xa, %edi
je 0xcb9f
testl %edi, %edi
jne 0xcba1
jmp 0xcbce
incl %edx
cmpb $0x22, (%r13,%rcx)
je 0xcbbc
incq %rcx
movl %ecx, %edi
cmpq %rsi, %rcx
jl 0xcb8b
movl %edx, (%rsp)
movl %edi, 0x4(%rsp)
jmp 0xcbd5
movl %edx, (%rsp)
leal 0x1(%rcx), %eax
movl %eax, 0x4(%rsp)
movb $0x1, %al
movl %ecx, 0x8(%rsp)
jmp 0xcbd7
movl %edx, (%rsp)
movl %eax, 0x4(%rsp)
xorl %eax, %eax
testb %al, %al
je 0xd051
movslq 0x4c(%rsp), %rbp
movslq 0x8(%rsp), %rbx
subq %rbp, %rbx
movslq %ebx, %rdi
callq 0x3040
movq %rax, %r15
leaq -0x1(%rbx), %rdx
leaq 0x1(,%r13), %rsi
addq %rbp, %rsi
movq %rax, %rdi
callq 0x31f0
movb $0x0, -0x1(%r15,%rbx)
movl $0x18, %edi
callq 0x3280
movq %r15, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x3070
incq 0x10(%r12)
leal 0x1(%r14), %eax
testl %r14d, %r14d
movl %eax, %r14d
leaq 0x18(%rsp), %r15
je 0xcb4b
movl $0x7d, %edi
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc9d4
testb %al, %al
jne 0xcc7e
movslq 0x4(%rsp), %rax
xorl %r14d, %r14d
cmpb $0x22, (%r13,%rax)
je 0xcb4b
jmp 0xd0dd
movl $0x18, %edi
callq 0x3280
movq %r12, 0x10(%rax)
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0x3070
incq 0x28(%rsp)
movl $0x7b, %edi
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xc9d4
testb %al, %al
jne 0xcb26
movl 0x4(%rsp), %eax
leaq 0x813659(%rip), %rcx    # 0x820324
cmpl (%rcx), %eax
jne 0xd120
movl 0x28(%rsp), %esi
leaq 0x57ed(%rip), %rdi      # 0x124cb
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x8aee
movq 0x18(%rsp), %rcx
cmpq %r15, %rcx
je 0xcd5b
movq 0x38(%rsp), %rax
leal 0x1(%rax), %r12d
movq 0x30(%rsp), %rax
leal 0x4(%rax), %ebp
xorl %r14d, %r14d
movq %rcx, 0x8(%rsp)
movq 0x10(%rcx), %r13
movq (%r13), %r15
addl %r12d, %r14d
cmpq %r13, %r15
je 0xcd46
addl %ebp, %r14d
movq 0x10(%r15), %rdi
callq 0x3120
movq %rax, %rbx
movq (%r15), %r15
movq 0x10(%r15), %rdi
callq 0x3120
addl %r14d, %ebx
movq (%r15), %r15
addl %r12d, %ebx
addl %eax, %ebx
movl %ebx, %r14d
jmp 0xcd16
addl %r12d, %r14d
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq 0x18(%rsp), %r15
cmpq %r15, %rcx
jne 0xcd06
addl 0x14(%rsp), %r14d
leaq 0x8135bd(%rip), %r12    # 0x820324
jne 0xcd91
leaq 0x5770(%rip), %rdi      # 0x124e0
leaq 0x578d(%rip), %rsi      # 0x12504
leaq 0x5796(%rip), %rdx      # 0x12514
leaq 0x57a1(%rip), %r8       # 0x12526
movl $0x116, %ecx            # imm = 0x116
xorl %eax, %eax
callq 0x8ddc
cmpl $0x200000, %r14d        # imm = 0x200000
jb 0xcdc2
leaq 0x573f(%rip), %rdi      # 0x124e0
leaq 0x578e(%rip), %rsi      # 0x12536
leaq 0x5765(%rip), %rdx      # 0x12514
leaq 0x57a0(%rip), %r8       # 0x12556
movl $0x117, %ecx            # imm = 0x117
xorl %eax, %eax
callq 0x8ddc
movl $0x0, (%r12)
leaq 0x57af(%rip), %rdi      # 0x12580
xorl %eax, %eax
callq 0x8aee
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq %r15, %rax
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rsi
je 0xcfce
movl (%r12), %eax
movslq %r14d, %rcx
movq %rcx, 0x8(%rsp)
movslq 0x30(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movq 0x50(%rsp), %rbp
movslq %eax, %rbx
leaq 0x813516(%rip), %rax    # 0x820330
leaq (%rax,%rbx), %rdi
incq %rdi
movb $0x7b, -0x1(%rdi)
leal 0x1(%rbx), %eax
movl %eax, (%r12)
movq 0x8(%rsp), %rdx
callq 0x31f0
leal (%rbx,%r14), %eax
incl %eax
movl %eax, (%r12)
movq %rbp, 0x60(%rsp)
movq 0x10(%rbp), %rcx
movq (%rcx), %rbp
movq %rcx, 0x78(%rsp)
cmpq %rcx, %rbp
movq %r14, %r15
movb $0x22, %r12b
je 0xcf6f
movslq %eax, %rbx
leaq 0x8134c6(%rip), %r15    # 0x820330
leaq (%r15,%rbx), %rdi
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rdx
callq 0x31f0
movq 0x30(%rsp), %rcx
leal (%rbx,%rcx), %eax
movslq %eax, %r14
addq %r14, %r15
incq %r15
movb %r12b, -0x1(%r15)
leal 0x1(%rbx,%rcx), %eax
leaq 0x813487(%rip), %r13    # 0x820324
movl %eax, (%r13)
movq 0x10(%rbp), %r12
movq %r12, %rdi
callq 0x3120
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x31f0
movq 0x10(%rbp), %rdi
callq 0x3120
leal (%rax,%r14), %ecx
incl %ecx
movslq %ecx, %rbx
leaq 0x81345c(%rip), %rcx    # 0x820330
leaq 0x3(%rcx,%rbx), %r15
movw $0x2022, -0x3(%r15)     # imm = 0x2022
leaq 0x2(%rbx), %rcx
movl %ecx, (%r13)
movq (%rbp), %rbp
movb $0x22, %cl
movb %cl, -0x1(%r15)
leal 0x4(%rax,%r14), %eax
movl %eax, (%r13)
movq 0x10(%rbp), %r12
movq %r12, %rdi
callq 0x3120
movq %r15, %rdi
movq 0x38(%rsp), %r15
movq %r12, %rsi
movb $0x22, %r12b
movq %rax, %rdx
callq 0x31f0
movq 0x10(%rbp), %rdi
callq 0x3120
leal (%rax,%rbx), %ecx
addl $0x3, %ecx
movslq %ecx, %r14
leaq 0x8133fa(%rip), %rcx    # 0x820330
leaq 0x1(%rcx,%r14), %rdi
movb %r12b, -0x1(%rdi)
leal 0x4(%rax,%rbx), %eax
movl %eax, (%r13)
movq 0x40(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x31f0
leal (%r15,%r14), %eax
incl %eax
movl %eax, (%r13)
movq (%rbp), %rbp
cmpq 0x78(%rsp), %rbp
jne 0xce60
movslq %eax, %rbx
leaq 0x8133b7(%rip), %rax    # 0x820330
leaq (%rax,%rbx), %rdi
incq %rdi
movb $0x7d, -0x1(%rdi)
leal 0x1(%rbx), %eax
leaq 0x813396(%rip), %r13    # 0x820324
movl %eax, (%r13)
movq 0x40(%rsp), %r12
movq %r12, %rsi
movq 0x8(%rsp), %rdx
callq 0x31f0
leal (%rbx,%r15), %eax
incl %eax
movl %eax, (%r13)
movq 0x60(%rsp), %rbp
movq (%rbp), %rbp
movq %r15, %r14
leaq 0x18(%rsp), %r15
cmpq %r15, %rbp
movq %r12, %rsi
movq %r13, %r12
jne 0xce10
movslq (%r12), %rbx
movq %rbx, %rdi
addq 0x9fd4(%rip), %rdi      # 0x16fb0
movl 0x14(%rsp), %ebp
movslq %ebp, %rdx
movq 0x58(%rsp), %rsi
callq 0x31f0
addl %ebx, %ebp
movl %ebp, (%r12)
movq 0x50(%rsp), %r12
cmpq %r15, %r12
je 0xd206
movq 0x10(%r12), %rbx
movq (%rbx), %r14
cmpq %rbx, %r14
je 0xd021
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0xd01c
callq 0x3350
movq (%r14), %r14
jmp 0xd009
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0xd03e
movq (%rdi), %r14
movl $0x18, %esi
callq 0x3290
movq %r14, %rdi
cmpq %rbx, %r14
jne 0xd029
movl $0x18, %esi
movq %rbx, %rdi
callq 0x3290
movq (%r12), %r12
jmp 0xcff8
movl (%rsp), %ecx
leaq 0x544c(%rip), %rsi      # 0x124a7
leaq 0x5465(%rip), %rdx      # 0x124c7
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30a0
movl $0x8, %edi
callq 0x3150
movq %rbx, (%rax)
movq 0x9f60(%rip), %rsi      # 0x16fe8
movq %rax, %rdi
xorl %edx, %edx
callq 0x3460
jmp 0xd161
movl (%rsp), %ecx
leaq 0x5406(%rip), %rsi      # 0x124a7
leaq 0x541f(%rip), %rdx      # 0x124c7
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30a0
movl $0x8, %edi
callq 0x3150
movq %rbx, (%rax)
movq 0x9f1a(%rip), %rsi      # 0x16fe8
movq %rax, %rdi
xorl %edx, %edx
callq 0x3460
jmp 0xd161
movl (%rsp), %ecx
leaq 0x53c0(%rip), %rsi      # 0x124a7
leaq 0x53db(%rip), %rdx      # 0x124c9
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30a0
movl $0x8, %edi
callq 0x3150
movq %rbx, (%rax)
movq 0x9ed4(%rip), %rsi      # 0x16fe8
movq %rax, %rdi
xorl %edx, %edx
callq 0x3460
jmp 0xd161
movl (%rsp), %ecx
leaq 0x537d(%rip), %rsi      # 0x124a7
leaq 0x5394(%rip), %rdx      # 0x124c5
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30a0
movl $0x8, %edi
callq 0x3150
movq %rbx, (%rax)
movq 0x9e91(%rip), %rsi      # 0x16fe8
movq %rax, %rdi
xorl %edx, %edx
callq 0x3460
jmp 0xd16b
jmp 0xd16b
jmp 0xd16b
jmp 0xd16b
jmp 0xd16b
movq %rax, %rdi
jmp 0xd178
movq %rax, %rdi
leaq 0x18(%rsp), %r15
callq 0x3110
movq 0x18(%rsp), %r14
cmpq %r15, %r14
je 0xd1da
movq 0x10(%r14), %rbx
movq (%rbx), %r15
cmpq %rbx, %r15
je 0xd1a6
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0xd1a1
callq 0x3350
movq (%r15), %r15
jmp 0xd18e
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0xd1c3
movq (%rdi), %r15
movl $0x18, %esi
callq 0x3290
movq %r15, %rdi
cmpq %rbx, %r15
jne 0xd1ae
movl $0x18, %esi
movq %rbx, %rdi
callq 0x3290
movq (%r14), %r14
leaq 0x18(%rsp), %r15
jmp 0xd182
cmpb $0x0, 0x80(%rsp)
je 0xd1f3
leaq 0x80(%rsp), %rdi
xorl %eax, %eax
callq 0x8ddc
leaq 0x539f(%rip), %rdi      # 0x12599
xorl %eax, %eax
callq 0x8ddc
callq 0x3450
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0xd225
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x3290
movq %rbx, %rdi
cmpq %r15, %rbx
jne 0xd210
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xd244
movq %rax, %rbx
callq 0x3450
movq 0x18(%rsp), %rdi
leaq 0x18(%rsp), %r15
cmpq %r15, %rdi
je 0xd268
movq (%rdi), %r14
movl $0x18, %esi
callq 0x3290
movq %r14, %rdi
cmpq %r15, %r14
jne 0xd253
movq %rbx, %rdi
callq 0x3470
movq %rax, %rdi
callq 0xe5bb