// File: /workspace/github_cpp_makefile_star2_O3/halsafar[P]libtmx-parser/./src/tmxparser.cpp
// Function: tmxparser::_parseTilesetNode(tinyxml2::XMLElement*, tmxparser::TmxTileset*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
TmxReturn _parseTilesetNode(tinyxml2::XMLElement* element, TmxTileset* outTileset, std::string tilesetPath)
{
	if (strcmp(element->Name(), "tileset") == 0)
	{
		CHECK_AND_RETRIEVE_REQ_ATTRIBUTE(element->QueryUnsignedAttribute, "firstgid", &outTileset->firstgid);

    // External tileset file
    char const* source = element->Attribute("source");
    if (source != nullptr)
    {
      outTileset->source = source;

      tinyxml2::XMLDocument tileDoc;
      if (tileDoc.LoadFile(_updatePath(source, tilesetPath).c_str()) != tinyxml2::XML_SUCCESS)
      {
        LOGE("Cannot read tileset xml file");
        return TmxReturn::kErrorParsing;
      }

      tinyxml2::XMLElement* tileElement = tileDoc.FirstChildElement("tileset");

      if (tileElement == NULL)
      {
        return TmxReturn::kMissingTilesetNode;
      }

      TmxReturn retVal = _parseTileset(tileElement, outTileset);
      if (retVal != TmxReturn::kSuccess)
      {
        return retVal;
      }

      outTileset->name = outTileset->source.substr(0, outTileset->source.rfind('.'));

    }

    // Embedded tileset
    else
    {
      return _parseTileset(element, outTileset);
    }

	}

	return TmxReturn::kSuccess;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
callq 0xd3dc
leaq 0xc51a(%rip), %rsi      # 0x1216b
movq %rax, %rdi
callq 0x42c0
xorl %r12d, %r12d
testl %eax, %eax
jne 0x5e0d
leaq 0xc6fa(%rip), %rsi      # 0x12365
movq %r15, %rdi
callq 0xe794
testq %rax, %rax
je 0x5e02
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0xe3d2
cmpl $0x1, %eax
je 0x5e02
leaq 0xc5d4(%rip), %rsi      # 0x1226c
movq %r15, %rdi
xorl %edx, %edx
callq 0xe806
testq %rax, %rax
je 0x5dd2
movq %rax, %r12
movq 0x8(%rbx), %r15
movq %rax, %rdi
callq 0x4100
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x4330
leaq -0x2e8(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xf3bc
leaq -0x58(%rbp), %r13
movq %r13, -0x10(%r13)
movq %r12, %rdi
callq 0x4100
movq %r12, %rdx
addq %rax, %rdx
leaq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x9184
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r14, %rdx
callq 0x58f1
movq -0x48(%rbp), %rsi
leaq -0x2e8(%rbp), %rdi
callq 0xf57c
movl %eax, %r14d
leaq -0x38(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x5d37
callq 0x41c0
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5d45
callq 0x41c0
testl %r14d, %r14d
jne 0x5e22
leaq 0xc416(%rip), %rsi      # 0x1216b
leaq -0x2e8(%rbp), %rdi
callq 0xd5f8
testq %rax, %rax
je 0x5dee
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6559
movl %eax, %r12d
testl %eax, %eax
jne 0x5df4
movq %rbx, %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x4450
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4220
addq $0x28, %rbx
leaq -0x48(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4250
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x5dc1
callq 0x41c0
leaq -0x2e8(%rbp), %rdi
callq 0xf4c8
xorl %r12d, %r12d
jmp 0x5e0d
movq %r15, %rdi
movq %rbx, %rsi
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6559
movl $0x5, %r12d
leaq -0x2e8(%rbp), %rdi
callq 0xf4c8
jmp 0x5e0d
callq 0x46de
movl $0x2, %r12d
movl %r12d, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x46aa
movl $0x1, %r12d
jmp 0x5df4
jmp 0x5e5f
jmp 0x5e5f
jmp 0x5e5f
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5e4f
callq 0x41c0
jmp 0x5e4f
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5e62
callq 0x41c0
jmp 0x5e62
movq %rax, %rbx
leaq -0x2e8(%rbp), %rdi
callq 0xf4c8
movq %rbx, %rdi
callq 0x43d0