// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rdx, %r15
movq %rdi, -0x78(%rbp)
movl $0x180, %edi            # imm = 0x180
callq 0x31f0
movq %rax, %r14
movq %rax, -0x48(%rbp)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x829e(%rip), %rax      # 0xed08
movq %rax, (%r14)
leaq 0x10(%r14), %r12
leaq 0x158(%r14), %rbx
movl $0x158, %edx            # imm = 0x158
movq %r12, %rdi
xorl %esi, %esi
callq 0x3100
movq %rbx, 0x168(%r14)
movq %rbx, 0x170(%r14)
movq %r14, -0x80(%rbp)
movq $0x0, 0x178(%r14)
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
movq %r12, %rsi
callq 0x3240
cmpw $0x200, (%r12)          # imm = 0x200
jne 0x6e50
leaq -0x70(%rbp), %rdi
movq %r15, %rdx
callq 0x682e
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rdx
movq %rax, 0x130(%rdx)
movq 0x138(%rdx), %rdi
movq %rcx, 0x138(%rdx)
testq %rdi, %rdi
je 0x6af8
callq 0x3ddc
leaq -0x70(%rbp), %rdi
movq %r15, %rdx
callq 0x682e
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rdx
movq %rax, 0x140(%rdx)
movq 0x148(%rdx), %rdi
movq %rcx, 0x148(%rdx)
testq %rdi, %rdi
je 0x6b2f
callq 0x3ddc
addq $0x150, -0x80(%rbp)     # imm = 0x150
movq 0x8492(%rip), %rbx      # 0xefd0
movq %r12, -0x90(%rbp)
movl $0x8, %edx
movq %r15, %rdi
leaq -0x88(%rbp), %rsi
callq 0x3240
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6eae
movq %r15, %rdi
movq $-0x8, %rsi
movl $0x1, %edx
callq 0x3260
movzwl -0x88(%rbp), %eax
cmpl $0x201, %eax            # imm = 0x201
je 0x6bad
cmpl $0x200, %eax            # imm = 0x200
je 0x6eae
movl -0x84(%rbp), %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3260
jmp 0x6b45
movl $0xb8, %edi
callq 0x31f0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x8189(%rip), %rax      # 0xed58
movq %rax, (%r14)
movq %r14, %r12
addq $0x10, %r12
movl $0xa8, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3100
movq %r14, -0x30(%rbp)
movq %r12, -0x38(%rbp)
movl $0x38, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3240
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %esi
addl $-0x38, %esi
movq %r15, %rdi
movl $0x1, %edx
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
leaq -0x70(%rbp), %rdi
movq %r15, %rdx
callq 0x7074
movq -0x38(%rbp), %r14
movaps -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x70(%rbp)
movq 0x40(%r14), %rdi
movups %xmm0, 0x38(%r14)
testq %rdi, %rdi
je 0x6c5f
callq 0x3ddc
movaps -0x60(%rbp), %xmm0
leaq -0x60(%rbp), %rax
xorps %xmm1, %xmm1
movups %xmm1, (%rax)
movq 0x50(%r14), %rdi
movups %xmm0, 0x48(%r14)
testq %rdi, %rdi
je 0x6c98
callq 0x3ddc
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, 0x58(%r14)
testq %rdi, %rdi
je 0x6ca0
callq 0x3ddc
jmp 0x6ca0
movq -0x50(%rbp), %rax
movq %rax, 0x58(%r14)
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x6cae
callq 0x3ddc
movq -0x38(%rbp), %rax
movzbl 0x8(%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x533a
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x7646
movq -0x38(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x6e36
xorl %r12d, %r12d
movq 0x38(%rax), %rcx
movq 0x40(%rax), %r14
testq %r14, %r14
je 0x6d00
cmpb $0x0, (%rbx)
je 0x6cfb
incl 0x8(%r14)
jmp 0x6d00
lock
incl 0x8(%r14)
movq 0x48(%rax), %r13
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0x6d1b
cmpb $0x0, (%rbx)
je 0x6d17
incl 0x8(%rdi)
jmp 0x6d1b
lock
incl 0x8(%rdi)
movl 0x5c(%rax), %eax
cmpq %rax, %r12
jae 0x6d36
movl (%rcx,%r12,4), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x6d36
addq %rax, %r13
jmp 0x6d39
xorl %r13d, %r13d
testq %rdi, %rdi
je 0x6d43
callq 0x3ddc
testq %r14, %r14
je 0x6d50
movq %r14, %rdi
callq 0x3ddc
movq %r13, -0x70(%rbp)
testq %r13, %r13
je 0x6d7d
movzwl (%r13), %eax
addq %r13, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq 0x68(%rdi), %rsi
cmpq 0x70(%rdi), %rsi
je 0x6da1
movq %r13, (%rsi)
addq $0x8, 0x68(%rdi)
jmp 0x6dae
movq -0x38(%rbp), %rdi
movq $0x0, -0x40(%rbp)
movq 0x68(%rdi), %rsi
cmpq 0x70(%rdi), %rsi
je 0x6dda
movq $0x0, (%rsi)
addq $0x8, 0x68(%rdi)
jmp 0x6de7
addq $0x60, %rdi
leaq -0x70(%rbp), %rdx
callq 0x8974
movq -0x38(%rbp), %rdi
movq 0x80(%rdi), %rsi
cmpq 0x88(%rdi), %rsi
je 0x6dcb
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
jmp 0x6e0a
addq $0x78, %rdi
leaq -0x40(%rbp), %rdx
callq 0x8a4a
jmp 0x6e12
addq $0x60, %rdi
leaq -0x40(%rbp), %rdx
callq 0x8700
movq -0x38(%rbp), %rdi
movq $0x0, -0x40(%rbp)
movq 0x80(%rdi), %rsi
cmpq 0x88(%rdi), %rsi
je 0x6e27
movq $0x0, (%rsi)
addq $0x8, 0x80(%rdi)
incq %r12
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
cmpq %rcx, %r12
jb 0x6ce3
jmp 0x6e36
addq $0x78, %rdi
leaq -0x40(%rbp), %rdx
callq 0x883a
jmp 0x6e12
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6e44
callq 0x3ddc
movq -0x90(%rbp), %r12
jmp 0x6b45
movq 0x8181(%rip), %rbx      # 0xefd8
leaq 0x447a(%rip), %rsi      # 0xb2d8
movl $0x3e, %edx
movq %rbx, %rdi
callq 0x3220
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31e0
movsbl %al, %esi
movq 0x814f(%rip), %rdi      # 0xefd8
callq 0x3040
movq %rax, %rdi
callq 0x3120
xorps %xmm0, %xmm0
movq -0x78(%rbp), %rbx
movups %xmm0, (%rbx)
movq -0x48(%rbp), %rdi
callq 0x3ddc
movq %rbx, %rax
jmp 0x6ec0
movq -0x78(%rbp), %rcx
movq %r12, (%rcx)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rcx)
movq %rcx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ee3
jmp 0x6ee3
jmp 0x6ee3
jmp 0x6ee8
jmp 0x6ee3
jmp 0x6ee8
jmp 0x6ee8
jmp 0x6ee8
jmp 0x6ee8
jmp 0x6ee8
movq %rax, %rbx
jmp 0x6ef9
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6ef9
callq 0x3ddc
movq -0x48(%rbp), %rdi
callq 0x3ddc
movq %rbx, %rdi
callq 0x3330