// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rdx, %r15
movq %rdi, -0x78(%rbp)
movl $0x180, %edi            # imm = 0x180
callq 0x3200
movq %rax, %r12
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r12)
leaq 0x8208(%rip), %rax      # 0xed08
movq %rax, (%r12)
leaq 0x10(%r12), %r13
leaq 0x158(%r12), %rbx
movl $0x170, %edx            # imm = 0x170
movq %r13, %rdi
xorl %esi, %esi
callq 0x3110
movq %rbx, 0x168(%r12)
movq %rbx, 0x170(%r12)
movq %r12, -0x88(%rbp)
movq $0x0, 0x178(%r12)
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
movq %r13, %rsi
callq 0x3250
cmpw $0x200, (%r13)          # imm = 0x200
jne 0x6f09
leaq -0x70(%rbp), %rdi
movq %r15, %rdx
callq 0x68be
movaps -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x70(%rbp)
movq 0x138(%r14), %rdi
movups %xmm0, 0x130(%r14)
testq %rdi, %rdi
je 0x6b90
callq 0x3dfa
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x6b9e
callq 0x3dfa
leaq -0x70(%rbp), %rdi
movq %r15, %rdx
callq 0x68be
movaps -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x70(%rbp)
movq 0x148(%r14), %rdi
movups %xmm0, 0x140(%r14)
testq %rdi, %rdi
je 0x6bce
callq 0x3dfa
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x6bdc
callq 0x3dfa
addq $0x150, -0x88(%rbp) # imm = 0x150
movq 0x83e2(%rip), %rbx      # 0xefd0
movq %r14, -0x80(%rbp)
movq %r13, -0x98(%rbp)
movl $0x8, %edx
movq %r15, %rdi
leaq -0x90(%rbp), %rsi
callq 0x3250
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6f5b
movq %r15, %rdi
movq $-0x8, %rsi
movl $0x1, %edx
callq 0x3270
movzwl -0x90(%rbp), %eax
cmpl $0x201, %eax            # imm = 0x201
je 0x6c61
cmpl $0x200, %eax            # imm = 0x200
je 0x6f5b
movl -0x8c(%rbp), %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3270
jmp 0x6bf9
movq $0x0, -0x38(%rbp)
movl $0xb8, %edi
callq 0x3200
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0x80cd(%rip), %rax      # 0xed58
movq %rax, (%r14)
movq %r14, %r12
addq $0x10, %r12
movl $0xa8, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3110
movq %r14, -0x30(%rbp)
movq %r12, -0x38(%rbp)
movl $0x38, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3250
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %esi
addl $-0x38, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3270
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 0x7142
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 0x6d1b
callq 0x3dfa
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 0x6d3c
callq 0x3dfa
movq -0x50(%rbp), %rax
movq %rax, 0x58(%r14)
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x6d52
callq 0x3dfa
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x6d60
callq 0x3dfa
movq -0x38(%rbp), %rax
movzbl 0x8(%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x88(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x533c
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x776c
movq -0x38(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x6eeb
xorl %r12d, %r12d
movq 0x38(%rax), %rcx
movq 0x40(%rax), %r14
testq %r14, %r14
je 0x6db5
cmpb $0x0, (%rbx)
je 0x6db0
incl 0x8(%r14)
jmp 0x6db5
lock
incl 0x8(%r14)
movq 0x48(%rax), %r13
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0x6dd0
cmpb $0x0, (%rbx)
je 0x6dcc
incl 0x8(%rdi)
jmp 0x6dd0
lock
incl 0x8(%rdi)
movl 0x5c(%rax), %eax
cmpq %rax, %r12
jae 0x6deb
movl (%rcx,%r12,4), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x6deb
addq %rax, %r13
jmp 0x6dee
xorl %r13d, %r13d
testq %rdi, %rdi
je 0x6df8
callq 0x3dfa
testq %r14, %r14
je 0x6e05
movq %r14, %rdi
callq 0x3dfa
movq %r13, -0x70(%rbp)
testq %r13, %r13
je 0x6e32
movzwl (%r13), %eax
addq %r13, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq 0x68(%rdi), %rsi
cmpq 0x70(%rdi), %rsi
je 0x6e56
movq %r13, (%rsi)
addq $0x8, 0x68(%rdi)
jmp 0x6e63
movq -0x38(%rbp), %rdi
movq $0x0, -0x40(%rbp)
movq 0x68(%rdi), %rsi
cmpq 0x70(%rdi), %rsi
je 0x6e8f
movq $0x0, (%rsi)
addq $0x8, 0x68(%rdi)
jmp 0x6e9c
addq $0x60, %rdi
leaq -0x70(%rbp), %rdx
callq 0x8aca
movq -0x38(%rbp), %rdi
movq 0x80(%rdi), %rsi
cmpq 0x88(%rdi), %rsi
je 0x6e80
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
jmp 0x6ebf
addq $0x78, %rdi
leaq -0x40(%rbp), %rdx
callq 0x8ba0
jmp 0x6ec7
addq $0x60, %rdi
leaq -0x40(%rbp), %rdx
callq 0x8856
movq -0x38(%rbp), %rdi
movq $0x0, -0x40(%rbp)
movq 0x80(%rdi), %rsi
cmpq 0x88(%rdi), %rsi
je 0x6edc
movq $0x0, (%rsi)
addq $0x8, 0x80(%rdi)
incq %r12
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
cmpq %rcx, %r12
jb 0x6d98
jmp 0x6eeb
addq $0x78, %rdi
leaq -0x40(%rbp), %rdx
callq 0x8990
jmp 0x6ec7
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6ef9
callq 0x3dfa
movq -0x80(%rbp), %r14
movq -0x98(%rbp), %r13
jmp 0x6bf9
movq 0x80c8(%rip), %rbx      # 0xefd8
leaq 0x43d1(%rip), %rsi      # 0xb2e8
movl $0x3e, %edx
movq %rbx, %rdi
callq 0x3230
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq 0x8096(%rip), %rdi      # 0xefd8
callq 0x3040
movq %rax, %rdi
callq 0x3130
xorps %xmm0, %xmm0
movq -0x78(%rbp), %rax
movups %xmm0, (%rax)
jmp 0x6f69
movq -0x78(%rbp), %rax
movq %r13, (%rax)
movq %r14, 0x8(%rax)
xorl %r14d, %r14d
testq %r14, %r14
je 0x6f76
movq %r14, %rdi
callq 0x3dfa
movq -0x78(%rbp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6fa0
jmp 0x6fa0
jmp 0x6fa0
jmp 0x6fa5
movq %rax, %rbx
jmp 0x6fb6
jmp 0x6fa5
jmp 0x6fa5
jmp 0x6fa5
jmp 0x6fa5
jmp 0x6fa5
movq %rax, %rbx
jmp 0x6fba
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6fb6
callq 0x3dfa
movq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3dfa
movq %rbx, %rdi
callq 0x3340