// File: /workspace/github_cpp_makefile_star2_O2/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 $0x2d0, %rsp            # imm = 0x2D0
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
callq 0xb914
leaq 0xafa6(%rip), %rsi      # 0x1016b
movq %rax, %rdi
callq 0x42e0
testl %eax, %eax
je 0x51e7
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%rbx), %rdx
leaq 0xb173(%rip), %rsi      # 0x10365
movq %r14, %rdi
callq 0x6932
cmpl $0x1, %eax
je 0x5332
leaq 0xb062(%rip), %rsi      # 0x1026c
movq %r14, %rdi
xorl %edx, %edx
callq 0xc8a0
testq %rax, %rax
je 0x52f9
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4420
leaq -0x2e8(%rbp), %rdi
pushq $0x1
popq %r14
movl %r14d, %esi
xorl %edx, %edx
callq 0xd1a4
leaq -0x68(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %r12, %rsi
callq 0x40d0
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r15, %rdx
callq 0x4f8a
movq -0x48(%rbp), %rsi
leaq -0x2e8(%rbp), %rdi
callq 0xd360
movl %eax, %r15d
leaq -0x48(%rbp), %rdi
callq 0x4478
leaq -0x68(%rbp), %rdi
callq 0x4478
testl %r15d, %r15d
jne 0x5365
leaq 0xaed6(%rip), %rsi      # 0x1016b
leaq -0x2e8(%rbp), %rdi
callq 0xbae8
testq %rax, %rax
je 0x5313
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5a1f
movl %eax, %r14d
testl %eax, %eax
jne 0x5317
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x4450
xorl %r14d, %r14d
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4220
addq $0x28, %rbx
leaq -0x48(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4250
movq %r15, %rdi
callq 0x4478
movb $0x1, %bl
jmp 0x5319
movq %r14, %rdi
movq %rbx, %rsi
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5a1f
pushq $0x5
popq %r14
xorl %ebx, %ebx
leaq -0x2e8(%rbp), %rdi
callq 0xd2b2
testb %bl, %bl
jne 0x51d1
jmp 0x51d4
movq 0x13c97(%rip), %rbx     # 0x18fd0
movq (%rbx), %rdi
leaq 0xad85(%rip), %rsi      # 0x100c8
leaq 0xb01b(%rip), %rdx      # 0x10365
xorl %eax, %eax
callq 0x42f0
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x4270
pushq $0x2
popq %r14
jmp 0x51d4
movq 0x13c64(%rip), %rbx     # 0x18fd0
movq (%rbx), %rcx
leaq 0xaff8(%rip), %rdi      # 0x1036e
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x4430
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x4270
jmp 0x5317
jmp 0x53b0
jmp 0x53b0
jmp 0x53b0
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x4478
jmp 0x53a5
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x4478
jmp 0x53b3
movq %rax, %rbx
leaq -0x2e8(%rbp), %rdi
callq 0xd2b2
movq %rbx, %rdi
callq 0x43d0