// File: halsafar[P]libtmx-parser/./src/tmxparser.cpp
// Function: tmxparser::_updatePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string _updatePath(std::string path, const std::string& tilesetPath)
{
	auto pathSeperatorMissing = (path.find(PATH_SEPARATOR) == std::string::npos);
	auto pathSeperatorAltMissing = (path.find(PATH_SEPARATOR_ALT) == std::string::npos);

	if (pathSeperatorMissing && pathSeperatorAltMissing) // no path_seperator found --> relative path
	{
		std::string baseFilename = path.substr(path.find_last_of(PATH_SEPARATOR) + 1);

		/*
		 * here we find out what separator is used in tilesetPath and choose it
		 * if both (alternative and normal) separators are used, we always use the normal separator
		 **/
		auto seperatorThere = (tilesetPath.find(PATH_SEPARATOR) != std::string::npos);
		auto seperatorAltThere = (tilesetPath.find(PATH_SEPARATOR_ALT) != std::string::npos);
		auto tileSetPathSeparator = PATH_SEPARATOR;

		if (!seperatorThere && seperatorAltThere) // only alternative separator exists in tilesetPath --> choose it
			tileSetPathSeparator = PATH_SEPARATOR_ALT;

		return tilesetPath + tileSetPathSeparator + baseFilename;
	}

  return path;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x88(%rbp)
movq %rdi, %rax
movq -0x88(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq %rax, %rcx
movq %rcx, -0x90(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0x1d9c2(%rip), %rsi     # 0x22e02
xorl %eax, %eax
movl %eax, %edx
callq 0x44f0
movq -0x88(%rbp), %rdi
cmpq $-0x1, %rax
sete %al
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq 0x1d99f(%rip), %rsi     # 0x22e02
xorl %eax, %eax
movl %eax, %edx
callq 0x44f0
cmpq $-0x1, %rax
sete %al
andb $0x1, %al
movb %al, -0x1a(%rbp)
testb $0x1, -0x19(%rbp)
je 0x5591
testb $0x1, -0x1a(%rbp)
je 0x5591
movq -0x88(%rbp), %rdi
leaq 0x1d968(%rip), %rsi     # 0x22e02
movq $-0x1, %rdx
callq 0x4240
movq -0x88(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
leaq -0x40(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4290
movq -0x18(%rbp), %rdi
leaq 0x1d933(%rip), %rsi     # 0x22e02
xorl %eax, %eax
movl %eax, %edx
callq 0x44f0
cmpq $-0x1, %rax
setne %al
andb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1d913(%rip), %rsi     # 0x22e02
xorl %eax, %eax
movl %eax, %edx
callq 0x44f0
cmpq $-0x1, %rax
setne %al
andb $0x1, %al
movb %al, -0x42(%rbp)
leaq 0x1d8f7(%rip), %rax     # 0x22e02
movq %rax, -0x50(%rbp)
testb $0x1, -0x41(%rbp)
jne 0x5526
testb $0x1, -0x42(%rbp)
je 0x5526
leaq 0x1d8e0(%rip), %rax     # 0x22e02
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x7da0
jmp 0x5539
movq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x7d50
jmp 0x554f
leaq -0x70(%rbp), %rdi
callq 0x4508
leaq -0x40(%rbp), %rdi
callq 0x4508
jmp 0x55a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x5586
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4508
leaq -0x40(%rbp), %rdi
callq 0x4508
jmp 0x55b4
movq -0x88(%rbp), %rsi
movq -0x98(%rbp), %rdi
callq 0x4190
movq -0x90(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x4470
nopl (%rax)