// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::xml_node::first_element_by_path(char const*, char) const
PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const
	{
		xml_node found = *this; // Current search context.

		if (!_root || !path_[0]) return found;

		if (path_[0] == delimiter)
		{
			// Absolute path; e.g. '/foo/bar'
			found = found.root();
			++path_;
		}

		const char_t* path_segment = path_;

		while (*path_segment == delimiter) ++path_segment;

		const char_t* path_segment_end = path_segment;

		while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end;

		if (path_segment == path_segment_end) return found;

		const char_t* next_segment = path_segment_end;

		while (*next_segment == delimiter) ++next_segment;

		if (*path_segment == '.' && path_segment + 1 == path_segment_end)
			return found.first_element_by_path(next_segment, delimiter);
		else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end)
			return found.parent().first_element_by_path(next_segment, delimiter);
		else
		{
			for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling)
			{
				if (j->name && impl::strequalrange(j->name, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
				{
					xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter);

					if (subsearch) return subsearch;
				}
			}

			return xml_node();
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x28(%rbp)
cmpq $0x0, (%rax)
je 0x4550f
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x4551c
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x456fd
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jne 0x4554c
leaq -0x28(%rbp), %rdi
callq 0x42730
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jne 0x45571
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x45554
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpb $0x0, (%rcx)
movb %al, -0x61(%rbp)
je 0x4559a
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x455a3
jmp 0x455b1
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x45579
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x455c8
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x456fd
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jne 0x455ed
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x455d0
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x45621
movq -0x38(%rbp), %rax
addq $0x1, %rax
cmpq -0x40(%rbp), %rax
jne 0x45621
movq -0x48(%rbp), %rsi
leaq -0x28(%rbp), %rdi
movsbl -0x19(%rbp), %edx
callq 0x454e0
movq %rax, -0x8(%rbp)
jmp 0x456fd
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x4566f
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2e, %eax
jne 0x4566f
movq -0x38(%rbp), %rax
addq $0x2, %rax
cmpq -0x40(%rbp), %rax
jne 0x4566f
leaq -0x28(%rbp), %rdi
callq 0x426e0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movsbl -0x19(%rbp), %edx
callq 0x454e0
movq %rax, -0x8(%rbp)
jmp 0x456fd
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x456f4
movq -0x58(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x456e4
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rax
subq %rax, %rdx
callq 0x45710
testb $0x1, %al
jne 0x456af
jmp 0x456e4
movq -0x58(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x41c10
movq -0x48(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movsbl -0x19(%rbp), %edx
callq 0x454e0
movq %rax, -0x8(%rbp)
leaq -0x8(%rbp), %rdi
callq 0x41c30
cmpq $0x0, %rax
je 0x456e2
jmp 0x456fd
jmp 0x456e4
jmp 0x456e6
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x4567b
leaq -0x8(%rbp), %rdi
callq 0x41bf0
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)