// File: /workspace/github_cpp_makefile_star2_O1/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 0xb0b8
movl %eax, %ebx
testb %al, %al
je 0x7588
leaq 0x20bc312(%rip), %r12   # 0x20c34b0
cmpw $0x7b, (%r12)
je 0x71b4
leaq 0x153fb(%rip), %rdi     # 0x1c5a8
xorl %eax, %eax
callq 0xa2a0
cmpl $0x4000, 0x2018296(%rip) # imm = 0x4000
jne 0x71ce
leaq 0x153fa(%rip), %rdi     # 0x1c5c1
xorl %eax, %eax
callq 0xa2a0
movslq 0x201827f(%rip), %rax   # 0x201f454
leaq (%rax,%rax,4), %rcx
leaq 0x2018280(%rip), %rdx   # 0x201f460
leaq (%rdx,%rcx,8), %r14
incl %eax
movl %eax, 0x2018268(%rip)   # 0x201f454
leaq 0x153f0(%rip), %r15     # 0x1c5e3
movl $0x1, %edi
callq 0xb0b8
testb %al, %al
jne 0x720b
movq %r15, %rdi
xorl %eax, %eax
callq 0xa2a0
cmpw $0x7d, (%r12)
je 0x7225
callq 0x70f0
movq 0x20(%r14), %rcx
movq %rcx, (%rax)
movq %rax, 0x20(%r14)
jmp 0x71f3
leaq 0x20(%r14), %r13
leaq 0x16a89(%rip), %r15     # 0x1dcb9
leaq 0x153d3(%rip), %r12     # 0x1c60a
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7257
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x723a
movq 0x10(%rbp), %r15
leaq 0x153b6(%rip), %rsi     # 0x1c614
movq %r15, %rdi
callq 0x4450
testl %eax, %eax
jne 0x7280
leaq 0x153bb(%rip), %rdi     # 0x1c62c
xorl %eax, %eax
callq 0x9fb2
movq %r14, %rdi
callq 0x156a8
leaq 0x16a32(%rip), %r15     # 0x1dcb9
leaq 0x1537c(%rip), %r12     # 0x1c60a
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x72ae
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x7291
movq 0x10(%rbp), %r15
leaq 0x15419(%rip), %rsi     # 0x1c6ce
movl $0x5, %edx
movq %r15, %rdi
callq 0x41a0
testl %eax, %eax
jne 0x7355
leaq 0x169e8(%rip), %r12     # 0x1dcb9
leaq 0x15399(%rip), %r15     # 0x1c671
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x72f8
movq 0x8(%rbp), %rdi
movq %r15, %rsi
callq 0x4450
testl %eax, %eax
jne 0x72db
movq 0x10(%rbp), %r12
cmpb $0x0, (%r12)
je 0x7355
leaq 0x169b3(%rip), %r15     # 0x1dcb9
leaq 0x152fd(%rip), %r12     # 0x1c60a
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x732d
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x7310
movq 0x10(%rbp), %r15
leaq 0x15342(%rip), %rsi     # 0x1c676
movq %r14, %rdi
movq %r15, %rdx
callq 0x75d4
leaq 0x152c4(%rip), %rsi     # 0x1c60a
leaq 0x15333(%rip), %rdx     # 0x1c680
movq %r14, %rdi
callq 0x75d4
leaq 0x1695d(%rip), %r15     # 0x1dcb9
leaq 0x1532b(%rip), %r12     # 0x1c68e
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7383
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x7366
movq 0x10(%rbp), %r15
leaq 0x15310(%rip), %rsi     # 0x1c69a
movq %r15, %rdi
callq 0x4450
testl %eax, %eax
je 0x73db
leaq 0x1691c(%rip), %r15     # 0x1dcb9
leaq 0x152ea(%rip), %r12     # 0x1c68e
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x73c4
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x73a7
movq 0x10(%rbp), %r15
leaq 0x152dc(%rip), %rsi     # 0x1c6a7
movq %r15, %rdi
callq 0x4450
testl %eax, %eax
jne 0x746c
leaq 0x168d7(%rip), %r15     # 0x1dcb9
leaq 0x15221(%rip), %r12     # 0x1c60a
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x740b
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x73ec
movq 0x10(%rbp), %rdx
jmp 0x740e
movq %r15, %rdx
leaq 0x15261(%rip), %rsi     # 0x1c676
movq %r14, %rdi
callq 0x75d4
leaq 0x1526a(%rip), %r12     # 0x1c68e
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x7444
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x7427
movq 0x10(%rbp), %r15
leaq 0x151bf(%rip), %rsi     # 0x1c60a
movq %r14, %rdi
movq %r15, %rdx
callq 0x75d4
leaq 0x15231(%rip), %rsi     # 0x1c68e
leaq 0x16855(%rip), %rdx     # 0x1dcb9
movq %r14, %rdi
callq 0x75d4
leaq 0x16846(%rip), %r15     # 0x1dcb9
leaq 0x15190(%rip), %r12     # 0x1c60a
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x749a
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x747d
movq 0x10(%rbp), %r15
leaq 0x15213(%rip), %rsi     # 0x1c6b4
movq %r15, %rdi
callq 0x4450
testl %eax, %eax
jne 0x74ee
leaq 0x16805(%rip), %r15     # 0x1dcb9
leaq 0x151d3(%rip), %r12     # 0x1c68e
movq %r13, %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x74db
movq 0x8(%rbp), %rdi
movq %r12, %rsi
callq 0x4450
testl %eax, %eax
jne 0x74be
movq 0x10(%rbp), %r15
leaq 0x151e4(%rip), %rsi     # 0x1c6c6
movq %r15, %rdi
callq 0x4450
testl %eax, %eax
je 0x7553
movq (%r13), %r13
testq %r13, %r13
je 0x7511
movq 0x8(%r13), %rdi
leaq 0x15108(%rip), %rsi     # 0x1c60a
callq 0x4450
testl %eax, %eax
jne 0x74ee
movq 0x10(%r13), %rdi
jmp 0x7518
leaq 0x167a1(%rip), %rdi     # 0x1dcb9
leaq 0x15195(%rip), %rsi     # 0x1c6b4
callq 0x4450
testl %eax, %eax
jne 0x7588
leaq 0x151a5(%rip), %rsi     # 0x1c6d4
movq %r14, %rdi
callq 0x76cf
testl %eax, %eax
je 0x7588
leaq 0x150c8(%rip), %rsi     # 0x1c60a
leaq 0x1517d(%rip), %rdx     # 0x1c6c6
movq %r14, %rdi
callq 0x75d4
jmp 0x7588
movq (%r13), %rax
testq %rax, %rax
je 0x756e
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x767a
movq 0x20(%r14), %rax
jmp 0x7557
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
decl 0x2017ecc(%rip)         # 0x201f454
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq