// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x1, %edi
callq 0xaf93
movl %eax, %ebx
testb %al, %al
je 0x7531
leaq 0x20bc35f(%rip), %r12   # 0x20c34a0
cmpw $0x7b, (%r12)
je 0x7157
leaq 0x15450(%rip), %rdi     # 0x1c5a0
xorl %eax, %eax
callq 0xa164
movl 0x20182e7(%rip), %eax   # 0x201f444
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x7178
leaq 0x1544e(%rip), %rdi     # 0x1c5b9
xorl %eax, %eax
callq 0xa164
movl 0x20182cc(%rip), %eax   # 0x201f444
cltq
leaq (%rax,%rax,4), %rcx
leaq 0x20182cb(%rip), %rdx   # 0x201f450
leaq (%rdx,%rcx,8), %r14
incl %eax
movl %eax, 0x20182b3(%rip)   # 0x201f444
leaq (%rdx,%rcx,8), %r13
addq $0x20, %r13
leaq 0x1543b(%rip), %r15     # 0x1c5db
movl $0x1, %edi
callq 0xaf93
testb %al, %al
jne 0x71b8
movq %r15, %rdi
xorl %eax, %eax
callq 0xa164
cmpw $0x7d, (%r12)
je 0x71d2
callq 0x7093
movq (%r13), %rcx
movq %rcx, (%rax)
movq %rax, (%r13)
jmp 0x71a0
leaq 0x16ad0(%rip), %r15     # 0x1dca9
leaq 0x15422(%rip), %r12     # 0x1c602
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7200
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x71e3
movq 0x10(%rbp), %r15
leaq 0x15405(%rip), %rsi     # 0x1c60c
movq %r15, %rdi
callq 0x4440
testl %eax, %eax
jne 0x7229
leaq 0x1540a(%rip), %rdi     # 0x1c624
xorl %eax, %eax
callq 0x9e76
movq %r14, %rdi
callq 0x1513c
leaq 0x16a79(%rip), %r15     # 0x1dca9
leaq 0x153cb(%rip), %r12     # 0x1c602
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7257
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x723a
movq 0x10(%rbp), %r15
leaq 0x15468(%rip), %rsi     # 0x1c6c6
movl $0x5, %edx
movq %r15, %rdi
callq 0x41a0
testl %eax, %eax
jne 0x72fe
leaq 0x16a2f(%rip), %r12     # 0x1dca9
leaq 0x153e8(%rip), %r15     # 0x1c669
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x72a1
movq 0x8(%rbp), %rdi
movq %r15, %rsi
callq 0x4440
testl %eax, %eax
jne 0x7284
movq 0x10(%rbp), %r12
cmpb $0x0, (%r12)
je 0x72fe
leaq 0x169fa(%rip), %r15     # 0x1dca9
leaq 0x1534c(%rip), %r12     # 0x1c602
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x72d6
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x72b9
movq 0x10(%rbp), %r15
leaq 0x15391(%rip), %rsi     # 0x1c66e
movq %r14, %rdi
movq %r15, %rdx
callq 0x757d
leaq 0x15313(%rip), %rsi     # 0x1c602
leaq 0x15382(%rip), %rdx     # 0x1c678
movq %r14, %rdi
callq 0x757d
leaq 0x169a4(%rip), %r15     # 0x1dca9
leaq 0x1537a(%rip), %r12     # 0x1c686
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x732c
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x730f
movq 0x10(%rbp), %r15
leaq 0x1535f(%rip), %rsi     # 0x1c692
movq %r15, %rdi
callq 0x4440
testl %eax, %eax
je 0x7384
leaq 0x16963(%rip), %r15     # 0x1dca9
leaq 0x15339(%rip), %r12     # 0x1c686
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x736d
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x7350
movq 0x10(%rbp), %r15
leaq 0x1532b(%rip), %rsi     # 0x1c69f
movq %r15, %rdi
callq 0x4440
testl %eax, %eax
jne 0x7415
leaq 0x1691e(%rip), %r15     # 0x1dca9
leaq 0x15270(%rip), %r12     # 0x1c602
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x73b4
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x7395
movq 0x10(%rbp), %rdx
jmp 0x73b7
movq %r15, %rdx
leaq 0x152b0(%rip), %rsi     # 0x1c66e
movq %r14, %rdi
callq 0x757d
leaq 0x152b9(%rip), %r12     # 0x1c686
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x73ed
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x73d0
movq 0x10(%rbp), %r15
leaq 0x1520e(%rip), %rsi     # 0x1c602
movq %r14, %rdi
movq %r15, %rdx
callq 0x757d
leaq 0x15280(%rip), %rsi     # 0x1c686
leaq 0x1689c(%rip), %rdx     # 0x1dca9
movq %r14, %rdi
callq 0x757d
leaq 0x1688d(%rip), %r15     # 0x1dca9
leaq 0x151df(%rip), %r12     # 0x1c602
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7443
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x7426
movq 0x10(%rbp), %r15
leaq 0x15262(%rip), %rsi     # 0x1c6ac
movq %r15, %rdi
callq 0x4440
testl %eax, %eax
jne 0x7497
leaq 0x1684c(%rip), %r15     # 0x1dca9
leaq 0x15222(%rip), %r12     # 0x1c686
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7484
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
jne 0x7467
movq 0x10(%rbp), %r15
leaq 0x15233(%rip), %rsi     # 0x1c6be
movq %r15, %rdi
callq 0x4440
testl %eax, %eax
je 0x74fc
movq (%r13), %r13
testq %r13, %r13
je 0x74ba
movq 0x8(%r13), %rdi
leaq 0x15157(%rip), %rsi     # 0x1c602
callq 0x4440
testl %eax, %eax
jne 0x7497
movq 0x10(%r13), %rdi
jmp 0x74c1
leaq 0x167e8(%rip), %rdi     # 0x1dca9
leaq 0x151e4(%rip), %rsi     # 0x1c6ac
callq 0x4440
testl %eax, %eax
jne 0x7531
leaq 0x151f4(%rip), %rsi     # 0x1c6cc
movq %r14, %rdi
callq 0x7678
testl %eax, %eax
je 0x7531
leaq 0x15117(%rip), %rsi     # 0x1c602
leaq 0x151cc(%rip), %rdx     # 0x1c6be
movq %r14, %rdi
callq 0x757d
jmp 0x7531
movq (%r13), %rax
testq %rax, %rax
je 0x7517
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x7623
movq 0x20(%r14), %rax
jmp 0x7500
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
decl 0x2017f13(%rip)         # 0x201f444
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq