// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: ParseEntity()
bool            ParseEntity()
{
    epair_t*        e;
    entity_t*       mapent;

    if (!GetToken(true))
    {
        return false;
    }

    if (strcmp(g_token, "{"))
    {
        Error("ParseEntity: { not found");
    }

    if (g_numentities == MAX_MAP_ENTITIES)
    {
        Error("g_numentities == MAX_MAP_ENTITIES");
    }

    mapent = &g_entities[g_numentities];
    g_numentities++;

    while (1)
    {
        if (!GetToken(true))
        {
            Error("ParseEntity: EOF without closing brace");
        }
        if (!strcmp(g_token, "}"))
        {
            break;
        }
        e = ParseEpair();
        e->next = mapent->epairs;
        mapent->epairs = e;
    }

#ifdef ZHLT_INFO_COMPILE_PARAMETERS // AJM
    if (!strcmp(ValueForKey(mapent, "classname"), "info_compile_parameters"))
    {
        Log("Map entity info_compile_parameters detected, using compile settings\n");
        GetParamsFromEnt(mapent);
    }
#endif
#ifdef ZHLT_ENTITY_LIGHTSURFACE
	// ugly code
	if (!strncmp(ValueForKey (mapent, "classname"), "light", 5) && *ValueForKey (mapent, "_tex"))
	{
		SetKeyValue (mapent, "convertto", ValueForKey (mapent, "classname"));
		SetKeyValue (mapent, "classname", "light_surface");
	}
#endif
#ifdef ZHLT_ENTITY_LIGHTSHADOW
	if (!strcmp (ValueForKey (mapent, "convertfrom"), "light_shadow")
	#ifdef ZHLT_ENTITY_LIGHTBOUNCE
		|| !strcmp (ValueForKey (mapent, "convertfrom"), "light_bounce")
	#endif
		)
	{
		SetKeyValue (mapent, "convertto", ValueForKey (mapent, "classname"));
		SetKeyValue (mapent, "classname", ValueForKey (mapent, "convertfrom"));
		SetKeyValue (mapent, "convertfrom", "");
	}
#endif
#ifdef ZHLT_ENTITY_INFOSUNLIGHT
	if (!strcmp (ValueForKey (mapent, "classname"), "light_environment") &&
		!strcmp (ValueForKey (mapent, "convertfrom"), "info_sunlight"))
	{
		while (mapent->epairs)
		{
			DeleteKey (mapent, mapent->epairs->key);
		}
		memset (mapent, 0, sizeof(entity_t));
		g_numentities--;
		return true;
	}
	if (!strcmp (ValueForKey (mapent, "classname"), "light_environment") &&
		IntForKey (mapent, "_fake"))
	{
		SetKeyValue (mapent, "classname", "info_sunlight");
	}
#endif

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq $0x1
popq %rdi
callq 0x9b47
movl %eax, %ebx
testb %al, %al
je 0x6922
leaq 0x20bad62(%rip), %r12   # 0x20c14b0
cmpw $0x7b, (%r12)
je 0x6764
leaq 0x12dab(%rip), %rdi     # 0x19508
xorl %eax, %eax
callq 0x8d7b
movl 0x2016cea(%rip), %eax   # 0x201d454
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x6785
leaq 0x12da9(%rip), %rdi     # 0x19521
xorl %eax, %eax
callq 0x8d7b
movl 0x2016ccf(%rip), %eax   # 0x201d454
cltq
imulq $0x28, %rax, %rcx
leaq 0x2016cce(%rip), %r14   # 0x201d460
addq %rcx, %r14
incl %eax
movl %eax, 0x2016cb7(%rip)   # 0x201d454
pushq $0x1
popq %rbp
leaq 0x12d9c(%rip), %r15     # 0x19543
movl %ebp, %edi
callq 0x9b47
testb %al, %al
jne 0x67bc
movq %r15, %rdi
xorl %eax, %eax
callq 0x8d7b
cmpw $0x7d, (%r12)
je 0x67d6
callq 0x66a7
movq 0x20(%r14), %rcx
movq %rcx, (%rax)
movq %rax, 0x20(%r14)
jmp 0x67a7
leaq 0x12d8d(%rip), %rsi     # 0x1956a
movq %r14, %rdi
callq 0x69ab
leaq 0x12d88(%rip), %rsi     # 0x19574
movq %rax, %rdi
callq 0x4480
testl %eax, %eax
jne 0x680e
leaq 0x12d8d(%rip), %rdi     # 0x1958c
xorl %eax, %eax
callq 0x89dc
movq %r14, %rdi
callq 0x12cd4
leaq 0x12d55(%rip), %rsi     # 0x1956a
movq %r14, %rdi
callq 0x69ab
movq %rax, %r15
leaq 0x12e07(%rip), %rsi     # 0x1962e
pushq $0x5
popq %rdx
movq %rax, %rdi
callq 0x41c0
testl %eax, %eax
jne 0x6872
leaq 0x12d94(%rip), %rsi     # 0x195d1
movq %r14, %rdi
callq 0x69ab
cmpb $0x0, (%rax)
je 0x6872
leaq 0x12d85(%rip), %rsi     # 0x195d6
movq %r14, %rdi
movq %r15, %rdx
callq 0x69e6
leaq 0x12d07(%rip), %rsi     # 0x1956a
leaq 0x12d76(%rip), %rdx     # 0x195e0
movq %r14, %rdi
callq 0x69e6
leaq 0x12d75(%rip), %rsi     # 0x195ee
movq %r14, %rdi
callq 0x69ab
movq %rax, %r15
leaq 0x12d6f(%rip), %rsi     # 0x195fa
movq %rax, %rdi
callq 0x4480
testl %eax, %eax
je 0x68aa
leaq 0x12d69(%rip), %rsi     # 0x19607
movq %r15, %rdi
callq 0x4480
testl %eax, %eax
jne 0x6900
leaq 0x12cb9(%rip), %r15     # 0x1956a
movq %r14, %rdi
movq %r15, %rsi
callq 0x69ab
leaq 0x12d13(%rip), %rsi     # 0x195d6
movq %r14, %rdi
movq %rax, %rdx
callq 0x69e6
leaq 0x12d19(%rip), %r12     # 0x195ee
movq %r14, %rdi
movq %r12, %rsi
callq 0x69ab
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x69e6
leaq 0x14324(%rip), %rdx     # 0x1ac19
movq %r14, %rdi
movq %r12, %rsi
callq 0x69e6
leaq 0x12c63(%rip), %rsi     # 0x1956a
movq %r14, %rdi
callq 0x69ab
leaq 0x12cfe(%rip), %rsi     # 0x19614
movq %rax, %rdi
callq 0x4480
testl %eax, %eax
je 0x692d
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12cba(%rip), %rsi     # 0x195ee
movq %r14, %rdi
callq 0x69ab
leaq 0x12ce3(%rip), %rsi     # 0x19626
movq %rax, %rdi
callq 0x4480
testl %eax, %eax
je 0x6986
leaq 0x12cde(%rip), %rsi     # 0x19634
movq %r14, %rdi
callq 0x6adf
testl %eax, %eax
je 0x6922
leaq 0x12c01(%rip), %rsi     # 0x1956a
leaq 0x12cb6(%rip), %rdx     # 0x19626
movq %r14, %rdi
callq 0x69e6
jmp 0x6922
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x6a8a
movq 0x20(%r14), %rax
testq %rax, %rax
jne 0x697a
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
andq $0x0, 0x20(%r14)
movups %xmm0, (%r14)
decl 0x2016aae(%rip)         # 0x201d454
jmp 0x6922