// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
callq 0xd476
leaq 0xc501(%rip), %rsi      # 0x1216b
movq %rax, %rdi
callq 0x42c0
testl %eax, %eax
jne 0x5e02
leaq 0xc6e4(%rip), %rsi      # 0x12365
movq %r15, %rdi
callq 0xe962
testq %rax, %rax
je 0x5e18
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0xe58c
cmpl $0x1, %eax
je 0x5e18
leaq 0xc5be(%rip), %rsi      # 0x1226c
movq %r15, %rdi
xorl %edx, %edx
callq 0xe9e8
testq %rax, %rax
je 0x5dd8
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 -0x2e0(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xf5c4
leaq -0x50(%rbp), %r15
movq %r15, -0x10(%r15)
movq %r12, %rdi
callq 0x4100
movq %r12, %rdx
addq %rax, %rdx
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
callq 0x9152
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %r14, %rdx
callq 0x590c
movq -0x40(%rbp), %rsi
leaq -0x2e0(%rbp), %rdi
callq 0xf784
movl %eax, %r14d
leaq -0x30(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x5d4e
callq 0x41c0
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x5d5c
callq 0x41c0
testl %r14d, %r14d
jne 0x5e25
leaq 0xc3ff(%rip), %rsi      # 0x1216b
leaq -0x2e0(%rbp), %rdi
callq 0xd6a6
testq %rax, %rax
je 0x5dea
movq %rax, %rdi
movq %rbx, %rsi
callq 0x656d
movl %eax, %r14d
testl %eax, %eax
jne 0x5df0
movq %rbx, %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x4450
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4220
addq $0x28, %rbx
leaq -0x40(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4250
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x5dd4
callq 0x41c0
movb $0x1, %bl
jmp 0x5df2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x656d
movl %eax, %r14d
xorl %ebx, %ebx
jmp 0x5dfe
movl $0x5, %r14d
xorl %ebx, %ebx
leaq -0x2e0(%rbp), %rdi
callq 0xf6d0
testb %bl, %bl
je 0x5e05
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x46de
movl $0x2, %r14d
jmp 0x5e05
callq 0x46aa
movl $0x1, %r14d
jmp 0x5df0
jmp 0x5e62
jmp 0x5e62
jmp 0x5e62
movq %rax, %rbx
leaq -0x30(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5e52
callq 0x41c0
jmp 0x5e52
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x5e65
callq 0x41c0
jmp 0x5e65
movq %rax, %rbx
leaq -0x2e0(%rbp), %rdi
callq 0xf6d0
movq %rbx, %rdi
callq 0x43d0