// File: halsafar[P]libtmx-parser/./src/tmxparser.cpp
// Function: tmxparser::_parseObjectNode(tinyxml2::XMLElement*, tmxparser::TmxObject*)
TmxReturn _parseObjectNode(tinyxml2::XMLElement* element, TmxObject* outObj)
{
	TmxReturn error = TmxReturn::kSuccess;

	if (element->Attribute("name"))
	{
		outObj->name = element->Attribute("name");
	}

	if (element->Attribute("type"))
	{
		outObj->type = element->Attribute("type");
	}
	outObj->x = element->FloatAttribute("x");
	outObj->y = element->FloatAttribute("y");
	outObj->width = element->FloatAttribute("width");
	outObj->height = element->FloatAttribute("height");
	outObj->rotation = element->FloatAttribute("rotation");
	outObj->referenceGid = element->UnsignedAttribute("gid");
	outObj->visible = element->BoolAttribute("visible");

	error = _parsePropertyNode(element->FirstChildElement("properties"), &outObj->propertyMap);
	if (error)
	{
		return error;
	}


	tinyxml2::XMLElement* shapeElement = NULL;
	if ((shapeElement = element->FirstChildElement("ellipse")) != NULL)
	{
		outObj->shapeType = kEllipse;
	}
	else if ((shapeElement = element->FirstChildElement("polygon")) != NULL)
	{
		outObj->shapeType = kPolygon;
	}
	else if ((shapeElement = element->FirstChildElement("polyline")) != NULL)
	{
		outObj->shapeType = kPolyline;
	}
	else
	{
		outObj->shapeType = kSquare;
	}

	if ((outObj->shapeType == kPolygon || outObj->shapeType == kPolyline) && shapeElement != NULL)
	{
		if (shapeElement->Attribute("points") == NULL)
		{
			LOGE("Missing points attribute for shape requiring one...");
			return TmxReturn::kErrorParsing;
		}

		std::string pointString = shapeElement->Attribute("points");
		std::istringstream pairStringStream(pointString);
		std::string pairToken;
		while(std::getline(pairStringStream, pairToken, ' '))
		{
			TmxShapePoint pair;
			std::istringstream pointStringString(pairToken);
			std::string pointToken;
			std::getline(pointStringString, pointToken, ',');
			pair.first = (float)atof(pointToken.c_str());
			std::getline(pointStringString, pointToken, ',');
			pair.second = (float)atof(pointToken.c_str());

			outObj->shapePoints.push_back(pair);
		}
	}

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1adcc(%rip), %rsi     # 0x22271
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
cmpq $0x0, %rax
je 0x74d4
movq -0x10(%rbp), %rdi
leaq 0x1adb2(%rip), %rsi     # 0x22271
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
movq %rax, %rsi
movq -0x18(%rbp), %rdi
callq 0x4360
movq -0x10(%rbp), %rdi
leaq 0x1b03a(%rip), %rsi     # 0x22519
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
cmpq $0x0, %rax
je 0x7512
movq -0x10(%rbp), %rdi
leaq 0x1b020(%rip), %rsi     # 0x22519
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
movq %rax, %rsi
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x4360
movq -0x10(%rbp), %rdi
leaq 0x1b3d3(%rip), %rsi     # 0x228f0
callq 0x84d0
movq -0x18(%rbp), %rax
movss %xmm0, 0x40(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1ae9d(%rip), %rsi     # 0x223d3
callq 0x84d0
movq -0x18(%rbp), %rax
movss %xmm0, 0x44(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1abbf(%rip), %rsi     # 0x2210e
callq 0x84d0
movq -0x18(%rbp), %rax
movss %xmm0, 0x48(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1abb0(%rip), %rsi     # 0x22118
callq 0x84d0
movq -0x18(%rbp), %rax
movss %xmm0, 0x4c(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1af9d(%rip), %rsi     # 0x2251e
callq 0x84d0
movq -0x18(%rbp), %rax
movss %xmm0, 0x50(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1ade0(%rip), %rsi     # 0x2237a
callq 0x82f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1ae22(%rip), %rsi     # 0x223d5
callq 0x87e0
movb %al, %cl
movq -0x18(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x58(%rax)
movq -0x10(%rbp), %rdi
leaq 0x1ab6c(%rip), %rsi     # 0x2213b
callq 0x7b60
movq %rax, %rdi
movq -0x18(%rbp), %rsi
addq $0x60, %rsi
callq 0x55c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x75f8
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7961
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1af1c(%rip), %rsi     # 0x22527
callq 0x7b60
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x762a
movq -0x18(%rbp), %rax
movl $0x2, 0x98(%rax)
jmp 0x7690
movq -0x10(%rbp), %rdi
leaq 0x1aefa(%rip), %rsi     # 0x2252f
callq 0x7b60
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x7654
movq -0x18(%rbp), %rax
movl $0x0, 0x98(%rax)
jmp 0x768e
movq -0x10(%rbp), %rdi
leaq 0x1aed8(%rip), %rsi     # 0x22537
callq 0x7b60
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x767e
movq -0x18(%rbp), %rax
movl $0x1, 0x98(%rax)
jmp 0x768c
movq -0x18(%rbp), %rax
movl $0x3, 0x98(%rax)
jmp 0x768e
jmp 0x7690
movq -0x18(%rbp), %rax
cmpl $0x0, 0x98(%rax)
je 0x76ae
movq -0x18(%rbp), %rax
cmpl $0x1, 0x98(%rax)
jne 0x795b
cmpq $0x0, -0x28(%rbp)
je 0x795b
movq -0x28(%rbp), %rdi
leaq 0x1ae7c(%rip), %rsi     # 0x22540
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
cmpq $0x0, %rax
jne 0x770f
movq 0x2b8fe(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
leaq 0x1ae63(%rip), %rsi     # 0x22547
movb $0x0, %al
callq 0x43a0
movq 0x2b8e6(%rip), %rax     # 0x32fd8
movq (%rax), %rdi
leaq 0x1b234(%rip), %rsi     # 0x22930
movb $0x0, %al
callq 0x43a0
movl $0x1, -0x4(%rbp)
jmp 0x7961
movq -0x28(%rbp), %rdi
leaq 0x1ae26(%rip), %rsi     # 0x22540
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
movq %rax, -0x3b8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x4480
movq -0x3b8(%rbp), %rsi
movq -0x3b0(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x4370
jmp 0x7753
leaq -0x49(%rbp), %rdi
callq 0x42a0
leaq -0x1e0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x8, %edx
callq 0x4460
jmp 0x7773
leaq -0x200(%rbp), %rdi
callq 0x4380
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
movl $0x20, %edx
callq 0x44a0
movq %rax, -0x3c0(%rbp)
jmp 0x77a0
movq -0x3c0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4300
movb %al, -0x3c1(%rbp)
jmp 0x77be
movb -0x3c1(%rbp), %al
testb $0x1, %al
jne 0x77cd
jmp 0x7915
leaq -0x208(%rbp), %rdi
callq 0x8920
jmp 0x77db
leaq -0x388(%rbp), %rdi
leaq -0x200(%rbp), %rsi
movl $0x8, %edx
callq 0x4460
jmp 0x77f5
leaq -0x3a8(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x4380
movq -0x3d0(%rbp), %rsi
leaq -0x388(%rbp), %rdi
movl $0x2c, %edx
callq 0x44a0
jmp 0x7822
leaq -0x3a8(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x4100
movq %rax, %rdi
callq 0x42f0
movq -0x3d8(%rbp), %rsi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x208(%rbp)
leaq -0x388(%rbp), %rdi
movl $0x2c, %edx
callq 0x44a0
jmp 0x7863
leaq -0x3a8(%rbp), %rdi
callq 0x4100
movq %rax, %rdi
callq 0x42f0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x204(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
leaq -0x208(%rbp), %rsi
callq 0x8940
jmp 0x789c
leaq -0x3a8(%rbp), %rdi
callq 0x4508
leaq -0x388(%rbp), %rdi
callq 0x4140
jmp 0x777f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x42a0
jmp 0x796d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7950
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7938
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x4508
leaq -0x388(%rbp), %rdi
callq 0x4140
jmp 0x7938
leaq -0x200(%rbp), %rdi
callq 0x4508
leaq -0x1e0(%rbp), %rdi
callq 0x4140
leaq -0x48(%rbp), %rdi
callq 0x4508
jmp 0x795b
leaq -0x200(%rbp), %rdi
callq 0x4508
leaq -0x1e0(%rbp), %rdi
callq 0x4140
leaq -0x48(%rbp), %rdi
callq 0x4508
jmp 0x796d
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x4470
nopw %cs:(%rax,%rax)