// File: /workspace/github_cpp_makefile_star2_O2/halsafar[P]libtmx-parser/./src/tmxparser.cpp
// Function: tmxparser::_parseMapNode(tinyxml2::XMLElement*, tmxparser::TmxMap*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
TmxReturn _parseMapNode(tinyxml2::XMLElement* element, TmxMap* outMap, std::string tilesetPath)
{
	if (element == NULL)
	{
		return TmxReturn::kMissingMapNode;
	}

	outMap->version = element->Attribute("version");
	const char* orientation = element->Attribute("orientation");
	if (orientation != NULL)
	{
		if (strcmp(orientation, "orthogonal") == 0)
		{
			outMap->orientation = TmxOrientation::kOrthogonal;
		}
		else if (strcmp(orientation, "isometric") == 0)
		{
			outMap->orientation = TmxOrientation::kIsometric;
		}
		else if (strcmp(orientation, "staggered") == 0)
		{
			outMap->orientation = TmxOrientation::kStaggered;
		}
	}
	else
	{
		LOGW("Missing orientation attribute");
	}

	CHECK_AND_RETRIEVE_REQ_ATTRIBUTE(element->QueryUnsignedAttribute, "width", &outMap->width);
	CHECK_AND_RETRIEVE_REQ_ATTRIBUTE(element->QueryUnsignedAttribute, "height", &outMap->height);
	CHECK_AND_RETRIEVE_REQ_ATTRIBUTE(element->QueryUnsignedAttribute, "tilewidth", &outMap->tileWidth);
	CHECK_AND_RETRIEVE_REQ_ATTRIBUTE(element->QueryUnsignedAttribute, "tileheight", &outMap->tileHeight);

	CHECK_AND_RETRIEVE_OPT_ATTRIBUTE_STRING(element, "backgroundcolor", outMap->backgroundColor);
	CHECK_AND_RETRIEVE_OPT_ATTRIBUTE_STRING(element, "renderorder", outMap->renderOrder);


	TmxReturn error = _parsePropertyNode(element->FirstChildElement("properties"), &outMap->propertyMap);
	if (error)
	{
		LOGE("Error processing map properties...");
		return error;
	}

	for (tinyxml2::XMLElement* child = element->FirstChildElement("tileset"); child != NULL; child = child->NextSiblingElement("tileset"))
	{
		TmxTileset set;
		error = _parseTilesetNode(child, &set, tilesetPath);
		if (error)
		{
			LOGE("Error processing tileset node...");
			return error;
		}

		outMap->tilesetCollection.push_back(set);
	}

	for (tinyxml2::XMLElement* child = element->FirstChildElement("layer"); child != NULL; child = child->NextSiblingElement("layer"))
	{
		TmxLayer layer;
		error = _parseLayerNode(child, outMap->tilesetCollection, &layer);
		if (error)
		{
			LOGE("Error processing layer node...");
			return error;
		}

		outMap->layerCollection.push_back(layer);
	}

	for (tinyxml2::XMLElement* child = element->FirstChildElement("objectgroup"); child != NULL; child = child->NextSiblingElement("objectgroup"))
	{
		TmxObjectGroup group;
		error = _parseObjectGroupNode(child, &group);
		if (error)
		{
			LOGE("Error processing objectgroup node...");
			return error;
		}

		outMap->objectGroupCollection.push_back(group);
	}

	for (tinyxml2::XMLElement* child = element->FirstChildElement("imagelayer"); child != NULL; child = child->NextSiblingElement("imagelayer"))
	{
		TmxImageLayer imageLayer;
		error = _parseImageLayerNode(child, &imageLayer);
		if (error)
		{
			LOGE("Error parsing imagelayer node...");
			return error;
		}

		outMap->imageLayerCollection.push_back(imageLayer);
	}

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, -0x38(%rbp)
testq %rdi, %rdi
je 0x48ac
movq %rsi, %r14
movq %rdi, %r15
leaq 0xb827(%rip), %rsi      # 0x10065
xorl %edx, %edx
callq 0xc8a0
movq %r14, %rdi
movq %rax, %rsi
callq 0x4420
leaq 0xb816(%rip), %rsi      # 0x1006d
movq %r15, %rdi
xorl %edx, %edx
callq 0xc8a0
testq %rax, %rax
je 0x48c5
movq %rax, %rbx
leaq 0xb809(%rip), %rsi      # 0x10079
movq %rax, %rdi
callq 0x42e0
testl %eax, %eax
je 0x48b4
leaq 0xb801(%rip), %rsi      # 0x10084
movq %rbx, %rdi
callq 0x42e0
testl %eax, %eax
je 0x48bb
leaq 0xb7f8(%rip), %rsi      # 0x1008e
movq %rbx, %rdi
callq 0x42e0
testl %eax, %eax
jne 0x48ec
movl $0x2, 0x20(%r14)
jmp 0x48ec
pushq $0x3
popq %rbx
jmp 0x4e20
andl $0x0, 0x20(%r14)
jmp 0x48ec
movl $0x1, 0x20(%r14)
jmp 0x48ec
movq 0x14704(%rip), %rbx     # 0x18fd0
movq (%rbx), %rcx
leaq 0xb7c2(%rip), %rdi      # 0x10098
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x4270
leaq 0x24(%r14), %rdx
leaq 0xb807(%rip), %rsi      # 0x100fe
movq %r15, %rdi
callq 0x6932
cmpl $0x1, %eax
je 0x4d9a
leaq 0x28(%r14), %rdx
leaq 0xb7f5(%rip), %rsi      # 0x10108
movq %r15, %rdi
callq 0x6932
cmpl $0x1, %eax
je 0x4db4
leaq 0x2c(%r14), %rdx
leaq 0xb7cb(%rip), %rsi      # 0x100fa
movq %r15, %rdi
callq 0x6932
cmpl $0x1, %eax
je 0x4dce
leaq 0x30(%r14), %rdx
leaq 0xb7b9(%rip), %rsi      # 0x10104
movq %r15, %rdi
callq 0x6932
cmpl $0x1, %eax
je 0x4dec
leaq 0xb7ac(%rip), %rsi      # 0x1010f
movq %r15, %rdi
xorl %edx, %edx
callq 0xc8a0
testq %rax, %rax
je 0x4991
leaq 0xb796(%rip), %rsi      # 0x1010f
movq %r15, %rdi
xorl %edx, %edx
callq 0xc8a0
leaq 0x38(%r14), %rdi
movq %rax, %rsi
callq 0x4420
jmp 0x499c
leaq 0x38(%r14), %rdi
xorl %esi, %esi
callq 0x43a0
leaq 0xb77c(%rip), %rsi      # 0x1011f
movq %r15, %rdi
xorl %edx, %edx
callq 0xc8a0
testq %rax, %rax
je 0x49d1
leaq 0xb766(%rip), %rsi      # 0x1011f
movq %r15, %rdi
xorl %edx, %edx
callq 0xc8a0
leaq 0x58(%r14), %rdi
movq %rax, %rsi
callq 0x4420
jmp 0x49dc
leaq 0x58(%r14), %rdi
xorl %esi, %esi
callq 0x43a0
leaq 0xb748(%rip), %rsi      # 0x1012b
movq %r15, %rdi
callq 0xbae8
leaq 0x78(%r14), %rsi
movq %rax, %rdi
callq 0x5089
testl %eax, %eax
jne 0x4e34
leaq 0xb765(%rip), %rsi      # 0x1016b
movq %r15, -0x48(%rbp)
movq %r15, %rdi
callq 0xbae8
movq %r14, %rcx
movq %rax, %r14
movq %rcx, -0x40(%rbp)
leaq 0xb0(%rcx), %r13
leaq -0x150(%rbp), %rbx
leaq -0x170(%rbp), %r12
testq %r14, %r14
je 0x4ad0
movq %rbx, %rdi
callq 0x6960
movq %r12, %rdi
movq -0x38(%rbp), %rsi
callq 0x42d0
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x519e
movl %eax, %r15d
movq %r12, %rdi
callq 0x4478
testl %r15d, %r15d
jne 0x4a9c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x69ce
movq %rbx, %rdi
callq 0x6a0c
testl %r15d, %r15d
jne 0x4d92
movq %r14, %rdi
leaq 0xb6d9(%rip), %rsi      # 0x1016b
callq 0xbbb8
movq %rax, %r14
jmp 0x4a31
movq 0x1452d(%rip), %rax     # 0x18fd0
movq (%rax), %rcx
leaq 0xb6c6(%rip), %rdi      # 0x10173
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq 0x14511(%rip), %rax     # 0x18fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x4270
movl %r15d, -0x2c(%rbp)
jmp 0x4a77
leaq 0xb748(%rip), %rsi      # 0x1021f
movq -0x48(%rbp), %rdi
callq 0xbae8
movq %rax, %r14
leaq -0x140(%rbp), %rbx
movq -0x40(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x38(%rbp)
leaq -0x150(%rbp), %r12
testq %r14, %r14
je 0x4bd2
movq %rbx, -0x150(%rbp)
andq $0x0, -0x148(%rbp)
movb $0x0, -0x140(%rbp)
leaq -0xf0(%rbp), %rax
movq %rax, -0x120(%rbp)
movq $0x1, -0x118(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
movl $0x3f800000, -0x100(%rbp) # imm = 0x3F800000
movups %xmm0, 0x58(%rbx)
movups %xmm0, 0x48(%rbx)
andq $0x0, 0x68(%rbx)
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x53c7
movl %eax, %r15d
testl %eax, %eax
jne 0x4b9e
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x6a42
movq %r12, %rdi
callq 0x6a7e
testl %r15d, %r15d
jne 0x4d92
movq %r14, %rdi
leaq 0xb68e(%rip), %rsi      # 0x1021f
callq 0xbbb8
movq %rax, %r14
jmp 0x4aff
movq 0x1442b(%rip), %rax     # 0x18fd0
movq (%rax), %rcx
leaq 0xb5f7(%rip), %rdi      # 0x101a6
pushq $0x30
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq 0x1440f(%rip), %rax     # 0x18fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x4270
movl %r15d, -0x2c(%rbp)
jmp 0x4b76
leaq 0xb5fe(%rip), %rsi      # 0x101d7
movq -0x48(%rbp), %rdi
callq 0xbae8
movq %rax, %r14
leaq -0x120(%rbp), %r15
movq -0x40(%rbp), %rax
addq $0xe0, %rax
movq %rax, -0x38(%rbp)
leaq -0x150(%rbp), %r12
testq %r14, %r14
je 0x4ce9
movq %rbx, -0x150(%rbp)
andq $0x0, -0x148(%rbp)
xorl %eax, %eax
movb %al, -0x140(%rbp)
movq %r15, -0x130(%rbp)
andq $0x0, -0x128(%rbp)
movb %al, -0x120(%rbp)
leaq -0xd8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq $0x1, -0x100(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rbx)
movl $0x3f800000, -0xe8(%rbp) # imm = 0x3F800000
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x40(%r15)
andq $0x0, 0x60(%r15)
movq %r14, %rdi
movq %r12, %rsi
callq 0x552e
movl %eax, %r13d
testl %eax, %eax
jne 0x4cb5
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x6aa8
movq %r12, %rdi
callq 0x6ae6
testl %r13d, %r13d
jne 0x4d92
movq %r14, %rdi
leaq 0xb52f(%rip), %rsi      # 0x101d7
callq 0xbbb8
movq %rax, %r14
jmp 0x4c01
movq 0x14314(%rip), %rax     # 0x18fd0
movq (%rax), %rcx
leaq 0xb51d(%rip), %rdi      # 0x101e3
pushq $0x36
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq 0x142f8(%rip), %rax     # 0x18fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x4270
movl %r13d, -0x2c(%rbp)
jmp 0x4c8d
leaq 0xb52a(%rip), %rbx      # 0x1021a
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0xbae8
movq %rax, %r14
addq $0xf8, -0x40(%rbp)
leaq -0x150(%rbp), %r15
pushq $0xa
popq %r13
testq %r14, %r14
je 0x4de8
movq %r15, %rdi
callq 0x6b1c
movq %r14, %rdi
movq %r15, %rsi
callq 0x574b
movl %eax, %r12d
testl %eax, %eax
jne 0x4d5e
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x6b5c
movq %r15, %rdi
callq 0x6b9a
testl %r12d, %r12d
jne 0x4d92
movq %r14, %rdi
movq %rbx, %rsi
callq 0xbbb8
movq %rax, %r14
jmp 0x4d12
movq 0x1426b(%rip), %rax     # 0x18fd0
movq (%rax), %rcx
leaq 0xb4b6(%rip), %rdi      # 0x10225
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq 0x1424f(%rip), %rax     # 0x18fd0
movq (%rax), %rsi
movl %r13d, %edi
callq 0x4270
movl %r12d, -0x2c(%rbp)
jmp 0x4d41
movl -0x2c(%rbp), %ebx
jmp 0x4e20
movq 0x1422f(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
leaq 0xb31d(%rip), %rsi      # 0x100c8
leaq 0xb34c(%rip), %rdx      # 0x100fe
jmp 0x4e04
movq 0x14215(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
leaq 0xb303(%rip), %rsi      # 0x100c8
leaq 0xb33c(%rip), %rdx      # 0x10108
jmp 0x4e04
movq 0x141fb(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
leaq 0xb2e9(%rip), %rsi      # 0x100c8
leaq 0xb314(%rip), %rdx      # 0x100fa
jmp 0x4e04
xorl %ebx, %ebx
jmp 0x4e20
movq 0x141dd(%rip), %rax     # 0x18fd0
movq (%rax), %rdi
leaq 0xb2cb(%rip), %rsi      # 0x100c8
leaq 0xb300(%rip), %rdx      # 0x10104
xorl %eax, %eax
callq 0x42f0
pushq $0x2
popq %rbx
movq 0x141bb(%rip), %rax     # 0x18fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x4270
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebx
movq 0x14193(%rip), %rax     # 0x18fd0
movq (%rax), %rcx
leaq 0xb2ef(%rip), %rdi      # 0x10136
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
jmp 0x4e0e
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x6b9a
jmp 0x4ea7
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x6ae6
jmp 0x4ea7
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x6a7e
jmp 0x4ea7
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
callq 0x4478
jmp 0x4e9b
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x6a0c
movq %rbx, %rdi
callq 0x43d0