// File: /workspace/github_cpp_makefile_star2_O2/bluesky466[P]ResourcesParser/ResourcesParser.cpp
// Function: ResourcesParser::parserPackageResource(std::basic_ifstream<char, std::char_traits<char>>&)
ResourcesParser::PackageResourcePtr ResourcesParser::parserPackageResource(
		ifstream& resources) {
	PackageResourcePtr pPool = make_shared<PackageResource>();
	resources.read((char*)&pPool->header, sizeof(ResTable_package));

	if(pPool->header.header.type != RES_TABLE_PACKAGE_TYPE) {
		cout<<"parserPackageResource 需要定位到 RES_TABLE_PACKAGE_TYPE !"<<endl;
		return nullptr;
	}

	// 接着是资源类型字符串池
	pPool->pTypes = parserResStringPool(resources);

	// 接着是资源名称字符串池
	pPool->pKeys = parserResStringPool(resources);

	ResChunk_header chunkHeader;
	while(resources.read((char*)&chunkHeader, sizeof(ResChunk_header))) {
		resources.seekg(-sizeof(ResChunk_header), ios::cur);

		if(chunkHeader.type == RES_TABLE_PACKAGE_TYPE) {
			return pPool;
		} else if(chunkHeader.type == RES_TABLE_TYPE_TYPE) {
			ResTableTypePtr pResTableType = make_shared<ResTableType>();
			resources.read((char*)&pResTableType->header, sizeof(ResTable_type));
			uint32_t seek = pResTableType->header.header.headerSize - sizeof(ResTable_type);
			resources.seekg(seek, ios::cur);
			pResTableType->entryPool = parserEntryPool(
					resources,
					pResTableType->header.entryCount,
					pResTableType->header.entriesStart - pResTableType->header.header.headerSize,
					pResTableType->header.header.size - pResTableType->header.entriesStart);
			pPool->resTablePtrs[pResTableType->header.id].push_back(pResTableType);
			for(int i = 0 ; i < pResTableType->header.entryCount ; i++) {
				ResTable_entry* pEntry = getEntryFromEntryPool(pResTableType->entryPool, i);
				if(nullptr == pEntry) {
					pResTableType->entries.push_back(nullptr);
					pResTableType->values.push_back(nullptr);
					continue;
				}
				Res_value* pValue = getValueFromEntry(pEntry);
				pResTableType->entries.push_back(pEntry);
				pResTableType->values.push_back(pValue);
			}
		} else {
			resources.seekg(chunkHeader.size, ios::cur);
		}
	}

	return pPool;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r15
movq %rdi, %r14
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x6387
movq (%rbx), %rsi
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
callq 0x3230
movq -0x48(%rbp), %rax
cmpw $0x200, (%rax)          # imm = 0x200
jne 0x5cf5
leaq -0x90(%rbp), %rdi
movq %r15, %rdx
callq 0x58e8
movl $0x120, %edi            # imm = 0x120
addq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x690e
leaq -0x88(%rbp), %rdi
callq 0x3ac4
leaq -0x90(%rbp), %rdi
movq %r15, -0x50(%rbp)
movq %r15, %rdx
callq 0x58e8
movl $0x130, %edi            # imm = 0x130
addq -0x48(%rbp), %rdi
leaq -0x90(%rbp), %r12
movq %r12, %rsi
callq 0x690e
leaq -0x88(%rbp), %rdi
callq 0x3ac4
leaq -0xb8(%rbp), %r13
leaq -0x58(%rbp), %r15
movq %r14, -0x68(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
pushq $0x8
popq %rdx
callq 0x3230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5d19
movq -0x50(%rbp), %rdi
pushq $-0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x3260
movzwl -0x60(%rbp), %eax
cmpl $0x201, %eax            # imm = 0x201
je 0x5b8b
cmpl $0x200, %eax            # imm = 0x200
je 0x5d19
movl -0x5c(%rbp), %esi
movq -0x50(%rbp), %rdi
pushq $0x1
popq %rdx
callq 0x3260
jmp 0x5b33
leaq -0x38(%rbp), %rdi
callq 0x63a3
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
pushq $0x38
popq %rdx
callq 0x3230
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %esi
addl $-0x38, %esi
movq %rbx, %rdi
pushq $0x1
popq %rdx
callq 0x3260
movq -0x38(%rbp), %rax
movl 0x4(%rax), %r9d
movl 0xc(%rax), %ecx
movl 0x10(%rax), %r8d
movzwl 0x2(%rax), %eax
subl %r8d, %r9d
subl %eax, %r8d
movq %r12, %rdi
movq %rbx, %rdx
callq 0x5e6a
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movq %r12, %rsi
callq 0x63c0
movq %r12, %rdi
callq 0x63f0
movq -0x48(%rbp), %rdi
movl $0x140, %eax            # imm = 0x140
addq %rax, %rdi
movq -0x38(%rbp), %rax
movzbl 0x8(%rax), %eax
movl %eax, -0x90(%rbp)
movq %r12, %rsi
callq 0x4882
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x6414
xorl %r14d, %r14d
movq -0x38(%rbp), %rsi
movl 0xc(%rsi), %eax
cmpq %rax, %r14
jae 0x5ce3
addq $0x38, %rsi
movq %r13, %rdi
callq 0x6450
movl -0x94(%rbp), %eax
cmpq %rax, %r14
jae 0x5c6f
movq -0xb8(%rbp), %rax
movl (%rax,%r14,4), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x5c6f
addq -0xa8(%rbp), %rbx
jmp 0x5c71
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x63f0
movq %rbx, -0x90(%rbp)
testq %rbx, %rbx
je 0x5cb1
movzwl (%rbx), %eax
addq %rbx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
movq %r12, %rsi
callq 0x647c
movq -0x38(%rbp), %rdi
addq $0x78, %rdi
movq %r15, %rsi
callq 0x64a0
jmp 0x5cdb
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
andq $0x0, -0x58(%rbp)
movq %r15, %rsi
callq 0x7cae
movq -0x38(%rbp), %rdi
addq $0x78, %rdi
andq $0x0, -0x58(%rbp)
movq %r15, %rsi
callq 0x7e24
incq %r14
jmp 0x5c2a
leaq -0x30(%rbp), %rdi
callq 0x3ac4
movq -0x68(%rbp), %r14
jmp 0x5b33
movq 0x92dc(%rip), %rdi      # 0xefd8
leaq 0x45ad(%rip), %rsi      # 0xa2b0
callq 0x31e0
movq %rax, %rdi
callq 0x30d0
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
jmp 0x5d32
movq -0x48(%rbp), %rax
movq %rax, (%r14)
movq -0x40(%rbp), %rax
andq $0x0, -0x40(%rbp)
movq %rax, 0x8(%r14)
andq $0x0, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3ac4
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5d60
jmp 0x5d60
jmp 0x5d60
jmp 0x5d69
jmp 0x5d69
jmp 0x5d69
jmp 0x5d60
jmp 0x5d69
movq %rax, %rbx
jmp 0x5d75
jmp 0x5d69
jmp 0x5d69
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3ac4
leaq -0x40(%rbp), %rdi
callq 0x3ac4
movq %rbx, %rdi
callq 0x3340