// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]def2fgd/src/entreader.cpp
// Function: readEntFile(std::istream&)
std::vector<Entity> readEntFile(std::istream& stream)
{
    std::vector<char> input((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
    std::vector<Entity> toReturn;

    xml_document<> doc;
    doc.parse<parse_trim_whitespace>(&input[0]);

    xml_node<>* classes = doc.first_node("classes");
    if (!classes)
        throw std::runtime_error(translate("No 'classes' entry found"));

    for (xml_node<>* entityNode = classes->first_node(); entityNode; entityNode = entityNode->next_sibling())
    {
        Entity entity;

        entity.description = descriptionLines(std::string(entityNode->value(), entityNode->value_size()));

        if (hasName(entityNode, "point"))
            entity.solid = false;
        else if (hasName(entityNode, "group"))
            entity.solid = true;

        xml_attribute<>* nameAttr = entityNode->first_attribute("name");
        if (!nameAttr)
            continue; // no name, nothing to do here

        entity.name = valueString(nameAttr);

        xml_attribute<>* colorAttr = entityNode->first_attribute("color");
        if (colorAttr)
            readColor(colorAttr->value(), colorAttr->value_size(), entity.color);

        xml_attribute<>* boxAttr = entityNode->first_attribute("box");
        if (boxAttr)
            readBox(boxAttr->value(), boxAttr->value_size(), entity.box);

        xml_attribute<>* modelAttr = entityNode->first_attribute("model");
        if (modelAttr) {
            entity.model = valueString(modelAttr);
        }

        for (xml_node<>* keyNode = entityNode->first_node(); keyNode; keyNode = keyNode->next_sibling())
        {
            if (hasName(keyNode, "flag"))
            {
                xml_attribute<>* keyAttr = keyNode->first_attribute("key");
                xml_attribute<>* bitAttr = keyNode->first_attribute("bit");

                if (keyAttr && bitAttr)
                {
                    size_t flagnum = static_cast<size_t>(strtol(bitAttr->value(), NULL, 10));
                    if (flagnum < Entity::SpawnFlagNum)
                    {
                        entity.spawnflags[flagnum] = valueString(keyAttr);
                        entity.flagsdescriptions[flagnum] = withoutQuotes(valueString(keyNode));
                    }
                }
            }
            else
            {
                xml_attribute<>* keyAttr = keyNode->first_attribute("key");
                if (keyAttr)
                {
                    entity.keys.push_back(Key(
                        valueString(keyAttr),
                        withoutQuotes(valueString(keyNode)),
                        entTypeToFgdType(keyNode->name(), keyNode->name_size())
                    ));
                }
            }
        }

        xml_node<>* lastNode = entityNode->last_node();
        if (lastNode && lastNode->name_size() == 0)
        {
            std::string val = valueString(lastNode);
            size_t pos = val.find("modeldisabled=");
            if (pos != std::string::npos && entity.model.empty())
            {
                std::string::iterator it = val.begin() + pos + strlen("modeldisabled=");
                if (*it == '"')
                {
                    it++;
                    std::string::iterator start = it;
                    while(it != val.end() && *it != '"')
                        it++;
                    std::string modelname(start, it);
                    entity.model = modelname;
                }
            }
            if (pos != std::string::npos) {
                val.resize(pos);
            }
            if (val.size()) {
                if (entity.description.size()) {
                    entity.description += "\\n\\n";
                }
                entity.description += descriptionLines(val);
            }
        }

        toReturn.push_back(entity);
    }

    return toReturn;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10a58, %rsp          # imm = 0x10A58
movq %rdi, %r15
movq (%rsi), %rax
movq -0x18(%rax), %rax
movq 0xe8(%rsi,%rax), %rsi
leaq 0x58(%rsp), %rbx
pushq $-0x1
popq %rdx
leaq 0x9d0(%rsp), %r14
movq %rbx, %rdi
xorl %ecx, %ecx
movl %edx, %r8d
movq %r14, %r9
callq 0x7b9c
andq $0x0, 0x10(%r15)
xorps %xmm0, %xmm0
andq $0x0, 0x20(%r14)
movaps %xmm0, (%r14)
andl $0x0, 0x28(%r14)
andq $0x0, 0x30(%r14)
movq %r15, 0x8(%rsp)
movups %xmm0, (%r15)
andq $0x0, 0x40(%r14)
leaq 0x10a48(%rsp), %rax
leaq 0xa48(%rsp), %rcx
movups %xmm0, (%rax)
movq %rcx, -0x18(%rcx)
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movq (%rbx), %rsi
leaq 0x9d0(%rsp), %rdi
callq 0x7bce
leaq 0x35f5(%rip), %rsi      # 0xa8f9
leaq 0x9d0(%rsp), %rdi
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x7c9c
testq %rax, %rax
je 0x79ce
movq 0x30(%rax), %rbp
leaq 0x130(%rsp), %r14
leaq 0xb0(%rsp), %rbx
pushq $0x1
popq %r15
testq %rbp, %rbp
je 0x79a0
movq %r14, %rdi
callq 0x6dc6
movq 0x8(%rbp), %rdx
testq %rdx, %rdx
je 0x735a
movq %rdx, %rsi
movq 0x18(%rbp), %rdx
jmp 0x7361
leaq 0x7f29(%rip), %rsi      # 0xf28a
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
addq %rsi, %rdx
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x515c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x70a8
leaq 0x150(%rsp), %rdi
movq %rbx, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3110
movq %r12, %rdi
callq 0x3110
movq %rbp, %rdi
leaq 0x353c(%rip), %rsi      # 0xa8ec
callq 0x7b3d
testb %al, %al
je 0x73bd
xorl %ecx, %ecx
jmp 0x73d2
movq %rbp, %rdi
leaq 0x3553(%rip), %rsi      # 0xa91a
callq 0x7b3d
movb $0x1, %cl
testb %al, %al
je 0x73d9
movb %cl, 0x9ac(%rsp)
movq %rbp, %rdi
leaq 0x3688(%rip), %rsi      # 0xaa6b
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %rax, %rax
je 0x7981
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7b65
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3110
movq %rbp, %rdi
leaq 0x2cb4(%rip), %rsi      # 0xa0d2
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %rax, %rax
je 0x74c0
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x7443
movq %r14, %r12
movq 0x18(%rax), %r14
jmp 0x744a
leaq 0x7e40(%rip), %r12      # 0xf28a
addq %r12, %r14
xorl %r13d, %r13d
cmpq $0x2, %r13
ja 0x74c0
cmpq %r14, %r12
je 0x74c0
cmpq %r14, %r12
je 0x7473
movsbl (%r12), %edi
callq 0x3070
testl %eax, %eax
je 0x747b
incq %r12
jmp 0x745b
movq %r14, %rdi
movq %r14, %r12
jmp 0x747e
movq %r12, %rdi
cmpq %r14, %r12
je 0x74a0
movsbl (%r12), %eax
cmpl $0x2e, %eax
setne %cl
addl $-0x30, %eax
cmpl $0xa, %eax
setae %al
testb %al, %cl
jne 0x74a3
incq %r12
jmp 0x747e
movq %r14, %r12
xorl %esi, %esi
callq 0x3200
cvtsd2ss %xmm0, %xmm0
callq 0x6cc0
movl %eax, 0x988(%rsp,%r13,4)
incq %r13
jmp 0x7450
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x3451(%rip), %rsi      # 0xa920
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %rax, %rax
je 0x756b
movq 0x8(%rax), %rbp
testq %rbp, %rbp
je 0x74f4
movq %rbp, %r12
movq 0x18(%rax), %rbp
jmp 0x74fb
leaq 0x7d8f(%rip), %r12      # 0xf28a
addq %r12, %rbp
xorl %r13d, %r13d
cmpq $0x5, %r13
ja 0x756b
cmpq %rbp, %r12
je 0x756b
cmpq %rbp, %r12
je 0x7524
movsbl (%r12), %edi
callq 0x3070
testl %eax, %eax
je 0x7527
incq %r12
jmp 0x750c
movq %rbp, %r12
movq %r12, %r14
cmpq %rbp, %r14
je 0x754b
movsbl (%r14), %eax
cmpl $0x2d, %eax
setne %cl
addl $-0x30, %eax
cmpl $0xa, %eax
setae %al
testb %al, %cl
jne 0x754e
incq %r14
jmp 0x752a
movq %rbp, %r14
movq %r12, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3370
movl %eax, 0x994(%rsp,%r13,4)
incq %r13
movq %r14, %r12
jmp 0x7501
movq 0x10(%rsp), %rdi
leaq 0x2ba0(%rip), %rsi      # 0xa117
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %rax, %rax
je 0x75a9
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7b65
leaq 0x9b0(%rsp), %rdi
movq %rbx, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3110
movq 0x10(%rsp), %rax
movq 0x30(%rax), %r14
testq %r14, %r14
je 0x7824
movq %r14, %rdi
leaq 0x335f(%rip), %rsi      # 0xa924
callq 0x7b3d
testb %al, %al
je 0x76a9
movq %r14, %rdi
leaq 0x334d(%rip), %rsi      # 0xa929
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
movq %rax, %r13
movq %r14, %rdi
leaq 0x333a(%rip), %rsi      # 0xa92d
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %r13, %r13
sete %cl
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x780d
movq 0x8(%rax), %rdi
testq %rdi, %rdi
leaq 0x7c6b(%rip), %rax      # 0xf28a
cmoveq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3370
cmpq $0x1f, %rax
ja 0x780d
movq %rax, %r12
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7b65
shlq $0x5, %r12
leaq 0x188(%rsp), %rax
leaq (%rax,%r12), %rdi
movq %rbx, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3110
leaq 0x110(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x7b65
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6cdf
leaq 0x588(%rsp), %rax
addq %rax, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3110
movq %r13, %rdi
jmp 0x7808
movq %r14, %rdi
leaq 0x3276(%rip), %rsi      # 0xa929
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7d34
testq %rax, %rax
je 0x780d
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x7b65
leaq 0x90(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x7b65
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x6cdf
movq (%r14), %r13
testq %r13, %r13
je 0x7704
movq %r13, %r12
movq 0x10(%r14), %r13
jmp 0x770b
leaq 0x7b7f(%rip), %r12      # 0xf28a
movq %r12, %rdi
leaq 0x29e0(%rip), %rsi      # 0xa0f5
movq %r13, %rdx
callq 0x3130
leaq 0x29cb(%rip), %rsi      # 0xa0ef
testl %eax, %eax
je 0x77a3
movq %r12, %rdi
leaq 0x320e(%rip), %rsi      # 0xa940
movq %r13, %rdx
callq 0x3130
leaq 0x3204(%rip), %rsi      # 0xa945
testl %eax, %eax
je 0x77a3
movq %r12, %rdi
leaq 0x31fc(%rip), %rbp      # 0xa94b
movq %rbp, %rsi
movq %r13, %rdx
callq 0x3130
movq %rbp, %rsi
testl %eax, %eax
je 0x77a3
movq %r12, %rdi
leaq 0x31e8(%rip), %rbp      # 0xa953
movq %rbp, %rsi
movq %r13, %rdx
callq 0x3130
movq %rbp, %rsi
testl %eax, %eax
je 0x77a3
movq %r12, %rdi
leaq 0x2990(%rip), %rsi      # 0xa117
movq %r13, %rdx
callq 0x3130
testl %eax, %eax
leaq 0x2a56(%rip), %rsi      # 0xa1ee
leaq 0x31ba(%rip), %rax      # 0xa959
cmoveq %rax, %rsi
leaq 0x70(%rsp), %r12
movq %r12, %rdi
leaq 0x7(%rsp), %rdx
callq 0x4dea
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r12, %rcx
callq 0x6d68
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x51f2
movq %rbx, %rdi
callq 0x4e26
leaq 0x70(%rsp), %rdi
callq 0x3110
leaq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x90(%rsp), %rdi
callq 0x3110
leaq 0x18(%rsp), %rdi
callq 0x3110
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7db4
movq %rax, %r14
jmp 0x75b2
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7e52
leaq 0x130(%rsp), %r14
testq %rax, %rax
je 0x7974
cmpq $0x0, (%rax)
je 0x785a
cmpq $0x0, 0x10(%rax)
jne 0x7974
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7b65
movq %rbx, %rdi
leaq 0x30c2(%rip), %rsi      # 0xa931
xorl %edx, %edx
callq 0x34b0
cmpq $-0x1, %rax
je 0x790a
movq %rax, %r14
cmpq $0x0, 0x9b8(%rsp)
jne 0x78ff
movq 0xb0(%rsp), %rdx
cmpb $0x22, 0xe(%rdx,%r14)
jne 0x78ff
leaq (%rdx,%r14), %rsi
addq $0xf, %rsi
movq 0xb8(%rsp), %rax
addq %rax, %rdx
subq %r14, %rax
addq $-0xf, %rax
movq %rsi, %rcx
testq %rax, %rax
je 0x78d0
cmpb $0x22, (%rcx)
je 0x78cd
incq %rcx
decq %rax
jmp 0x78bb
movq %rcx, %rdx
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x6822
leaq 0x9b0(%rsp), %rdi
movq %r12, %rsi
callq 0x3180
movq %r12, %rdi
callq 0x3110
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3350
cmpq $0x0, 0xb8(%rsp)
leaq 0x130(%rsp), %r14
je 0x796c
cmpq $0x0, 0x158(%rsp)
je 0x793c
leaq 0x150(%rsp), %rdi
leaq 0x2f69(%rip), %rsi      # 0xa8a0
callq 0x3490
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x70a8
leaq 0x150(%rsp), %rdi
movq %r12, %rsi
callq 0x34a0
leaq 0x130(%rsp), %r14
movq %r12, %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3110
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x66d4
movq %r14, %rdi
callq 0x4e46
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r15d, %ecx
callq 0x7db4
movq %rax, %rbp
jmp 0x7337
leaq 0xa30(%rsp), %rdi
callq 0x7f14
leaq 0x58(%rsp), %rdi
callq 0x801a
movq 0x8(%rsp), %rax
addq $0x10a58, %rsp          # imm = 0x10A58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3150
movq %rax, %r14
leaq 0x2f21(%rip), %rsi      # 0xa901
leaq 0x130(%rsp), %rdi
callq 0x95ed
movb $0x1, %bpl
leaq 0x130(%rsp), %rsi
movq %r14, %rdi
callq 0x33f0
xorl %ebp, %ebp
movq 0x75e7(%rip), %rsi      # 0xeff0
movq 0x7598(%rip), %rdx      # 0xefa8
movq %r14, %rdi
callq 0x3440
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x3110
testb %bpl, %bpl
jne 0x7a35
jmp 0x7b14
movq %rax, %rbx
movq %r14, %rdi
callq 0x31f0
jmp 0x7b14
jmp 0x7a4a
jmp 0x7a60
jmp 0x7a8a
jmp 0x7a8a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3110
jmp 0x7a63
jmp 0x7a60
jmp 0x7b04
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x7af3
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
jmp 0x7a8a
jmp 0x7b04
movq %rax, %rbx
jmp 0x7b14
jmp 0x7b04
jmp 0x7aeb
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x7af3
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x4e26
jmp 0x7abe
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x3110
jmp 0x7acd
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3110
jmp 0x7adc
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3110
jmp 0x7aee
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3110
jmp 0x7b07
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
jmp 0x7b04
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x4e46
leaq 0xa30(%rsp), %rdi
callq 0x7f14
movq 0x8(%rsp), %rdi
callq 0x4ece
leaq 0x58(%rsp), %rdi
callq 0x801a
movq %rbx, %rdi
callq 0x3460