// File: 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
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x90(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0xbc80
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x65a0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
movl $0x1c, %edx
callq 0x32f0
jmp 0xa049
leaq -0x28(%rbp), %rdi
callq 0x65a0
movzwl (%rax), %eax
cmpl $0x1, %eax
je 0xa0c1
movq 0x1cf67(%rip), %rdi     # 0x26fc8
leaq 0x101ca(%rip), %rsi     # 0x1a232
callq 0x3260
movq %rax, -0x98(%rbp)
jmp 0xa076
movq -0x98(%rbp), %rdi
movq 0x1cf24(%rip), %rsi     # 0x26fa8
callq 0x3290
jmp 0xa08b
movq -0x90(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbcf0
movl $0x1, -0x38(%rbp)
jmp 0xa342
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x43a0
jmp 0xa35b
leaq -0x28(%rbp), %rdi
callq 0x65a0
movl 0x8(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x3030
movq %rax, -0xa0(%rbp)
jmp 0xa0e1
movq -0xa0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xbd10
jmp 0xa0f3
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x65a0
movq %rax, %rdi
addq $0x20, %rdi
leaq -0x48(%rbp), %rsi
movq %rsi, -0xb8(%rbp)
callq 0xbd40
movq -0xb8(%rbp), %rdi
callq 0xbd70
movq -0xb0(%rbp), %rdi
callq 0x65a0
movq -0xb0(%rbp), %rdi
movl 0x8(%rax), %eax
shll $0x2, %eax
movl %eax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
callq 0x65a0
movq %rax, %rdi
addq $0x20, %rdi
callq 0xbd90
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
movl -0x50(%rbp), %eax
movl %eax, %edx
callq 0x32f0
jmp 0xa174
leaq -0x28(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x65a0
movq -0xc8(%rbp), %rdi
movl 0x14(%rax), %eax
movl %eax, -0xbc(%rbp)
callq 0x65a0
movq %rax, %rcx
movl -0xbc(%rbp), %eax
movzwl 0x2(%rcx), %ecx
subl %ecx, %eax
movl -0x50(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x3350
jmp 0xa1c5
leaq -0x28(%rbp), %rdi
callq 0x65a0
cmpl $0x0, 0xc(%rax)
jbe 0xa203
leaq -0x28(%rbp), %rdi
callq 0x65a0
movl 0x18(%rax), %eax
movl %eax, -0xd0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x65a0
movq %rax, %rcx
movl -0xd0(%rbp), %eax
subl 0x14(%rcx), %eax
movl %eax, -0xcc(%rbp)
jmp 0xa230
leaq -0x28(%rbp), %rdi
callq 0x65a0
movl 0x4(%rax), %eax
movl %eax, -0xd4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x65a0
movq %rax, %rcx
movl -0xd4(%rbp), %eax
subl 0x14(%rcx), %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %edi
callq 0x3030
movq %rax, -0xe0(%rbp)
jmp 0xa24c
movq -0xe0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xbdb0
jmp 0xa25e
leaq -0x28(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x65a0
movq %rax, %rdi
addq $0x30, %rdi
leaq -0x68(%rbp), %rsi
movq %rsi, -0xf8(%rbp)
callq 0xbde0
movq -0xf8(%rbp), %rdi
callq 0xbe10
movq -0xf0(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
callq 0x65a0
movq %rax, %rdi
addq $0x30, %rdi
callq 0xbe30
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
movl -0x58(%rbp), %eax
movl %eax, %edx
callq 0x32f0
jmp 0xa2ca
leaq -0x28(%rbp), %rdi
callq 0x65a0
cmpl $0x0, 0xc(%rax)
jbe 0xa32b
leaq -0x28(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x65a0
movq -0x108(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0xfc(%rbp)
callq 0x65a0
movq %rax, %rcx
movl -0xfc(%rbp), %eax
movl 0x14(%rcx), %ecx
subl %ecx, %eax
movl -0x58(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x3350
jmp 0xa329
jmp 0xa32b
movq -0x90(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xbe50
movl $0x1, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x43a0
movq -0x88(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3450
nopw %cs:(%rax,%rax)