// File: /workspace/github_cpp_makefile_star2_O3/bluesky466[P]ResourcesParser/ResourcesParser.cpp
// Function: ResourcesParser::parserResStringPool(std::basic_ifstream<char, std::char_traits<char>>&)
ResourcesParser::ResStringPoolPtr ResourcesParser::parserResStringPool(
		ifstream& resources) {
	ResStringPoolPtr pPool = make_shared<ResStringPool>();
	resources.read((char*)&pPool->header, sizeof(ResStringPool_header));
	if(pPool->header.header.type != RES_STRING_POOL_TYPE) {
		cout<<"parserResStringPool 需要定位到 RES_STRING_POOL_TYPE !"<<endl;
		return nullptr;
	}

	pPool->pOffsets = shared_ptr<uint32_t>(
			new uint32_t[pPool->header.stringCount],
			default_delete<uint32_t[]>()
	);

	const uint32_t offsetSize = sizeof(uint32_t) * pPool->header.stringCount;
	resources.read((char*)pPool->pOffsets.get(), offsetSize);

	// 跳到字符串数组开头位置
	uint32_t seek = pPool->header.stringsStart
		- pPool->header.header.headerSize
		- offsetSize;
	resources.seekg(seek, ios::cur);

	// 载入所有字符串
	const uint32_t strBuffSize = pPool->header.styleCount > 0
		? pPool->header.stylesStart - pPool->header.stringsStart
		: pPool->header.header.size - pPool->header.stringsStart;
	pPool->pStrings = shared_ptr<byte>(
			new byte[strBuffSize],
			default_delete<byte[]>()
	);
	resources.read((char*)pPool->pStrings.get(), strBuffSize);

	// 跳出全局字符串池
	if(pPool->header.styleCount > 0) {
		seek = pPool->header.header.size
			- pPool->header.stringsStart
			- strBuffSize;
		resources.seekg(seek, ios::cur);
	}

	return pPool;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rdi, %r14
movl $0x50, %edi
callq 0x31f0
movq %rax, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%rbx)
leaq 0x8389(%rip), %rax      # 0xebf0
movq %rax, (%rbx)
leaq 0x10(%rbx), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x40(%rbx)
movl $0x1c, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3240
cmpw $0x1, (%r12)
jne 0x69a7
movl 0x18(%rbx), %edi
shlq $0x2, %rdi
callq 0x3030
leaq -0x38(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x817a
movaps -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x38(%rbx), %rdi
movups %xmm0, 0x30(%rbx)
testq %rdi, %rdi
je 0x68e4
callq 0x3ddc
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x68e4
callq 0x3ddc
movl 0x18(%rbx), %r13d
shll $0x2, %r13d
movq 0x30(%rbx), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0x3240
movl 0x24(%rbx), %esi
movzwl 0x12(%rbx), %eax
addl %eax, %r13d
subl %r13d, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3260
leaq 0x28(%rbx), %rax
movq %rbx, %rcx
addq $0x14, %rcx
cmpl $0x0, 0x1c(%rbx)
cmovneq %rax, %rcx
movl (%rcx), %r13d
subl 0x24(%rbx), %r13d
movq %r13, %rdi
callq 0x3030
leaq -0x38(%rbp), %rdi
movq %rax, -0x8(%rdi)
movq %rax, %rsi
callq 0x8258
movaps -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x48(%rbx), %rdi
movups %xmm0, 0x40(%rbx)
testq %rdi, %rdi
je 0x6972
callq 0x3ddc
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x6972
callq 0x3ddc
movq 0x40(%rbx), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0x3240
cmpl $0x0, 0x1c(%rbx)
je 0x699e
movl 0x14(%rbx), %esi
addl 0x24(%rbx), %r13d
subl %r13d, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3260
movq %r12, (%r14)
movq %rbx, 0x8(%r14)
jmp 0x69fc
movq 0x862a(%rip), %r15      # 0xefd8
leaq 0x48e4(%rip), %rsi      # 0xb299
movl $0x3a, %edx
movq %r15, %rdi
callq 0x3220
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x31e0
movsbl %al, %esi
movq 0x85f8(%rip), %rdi      # 0xefd8
callq 0x3040
movq %rax, %rdi
callq 0x3120
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq %rbx, %rdi
callq 0x3ddc
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6a18
jmp 0x6a18
jmp 0x6a18
jmp 0x6a18
jmp 0x6a18
movq %rax, %r14
movq %rbx, %rdi
callq 0x3ddc
movq %r14, %rdi
callq 0x3330
nop