// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::xml_parser::parse(char*, unsigned long, pugi::impl::(anonymous namespace)::xml_document_struct*, pugi::xml_node_struct*, unsigned int)
static xml_parse_result parse(char_t* buffer, size_t length, xml_document_struct* xmldoc, xml_node_struct* root, unsigned int optmsk)
		{
			// early-out for empty documents
			if (length == 0)
				return make_parse_result(PUGI__OPTSET(parse_fragment) ? status_ok : status_no_document_element);

			// get last child of the root before parsing
			xml_node_struct* last_root_child = root->first_child ? root->first_child->prev_sibling_c + 0 : 0;

			// create parser on stack
			xml_parser parser(static_cast<xml_allocator*>(xmldoc));

			// save last character and make buffer zero-terminated (speeds up parsing)
			char_t endch = buffer[length - 1];
			buffer[length - 1] = 0;

			// skip BOM to make sure it does not end up as part of parse output
			char_t* buffer_data = parse_skip_bom(buffer);

			// perform actual parsing
			parser.parse_tree(buffer_data, root, optmsk, endch);

			xml_parse_result result = make_parse_result(parser.error_status, parser.error_offset ? parser.error_offset - buffer : 0);
			assert(result.offset >= 0 && static_cast<size_t>(result.offset) <= length);

			if (result)
			{
				// since we removed last character, we have to handle the only possible false positive (stray <)
				if (endch == '<')
					return make_parse_result(status_unrecognized_tag, length - 1);

				// check if there are any element nodes parsed
				xml_node_struct* first_root_child_parsed = last_root_child ? last_root_child->next_sibling + 0 : root->first_child+ 0;

				if (!PUGI__OPTSET(parse_fragment) && !has_element_node_siblings(first_root_child_parsed))
					return make_parse_result(status_no_document_element, length - 1);
			}
			else
			{
				// roll back offset if it occurs on a null terminator in the source buffer
				if (result.offset > 0 && static_cast<size_t>(result.offset) == length - 1 && endch == 0)
					result.offset--;
			}

			return result;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x88(%rbp)
movq %rdi, -0x80(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5033c
movq -0x88(%rbp), %rdi
movl -0x24(%rbp), %ecx
andl $0x1000, %ecx           # imm = 0x1000
movl $0x10, %esi
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x44e10
jmp 0x50577
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x5035c
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x50367
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0x50367
movq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0x98(%rbp)
je 0x5039e
movq -0xa0(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x51fb0
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rdi
callq 0x51fe0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
leaq -0x48(%rbp), %rdi
movsbl -0x49(%rbp), %r8d
callq 0x52030
movl -0x38(%rbp), %eax
movl %eax, -0xa4(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x5041a
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
jmp 0x50425
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x50425
movl -0xa4(%rbp), %esi
movq -0xb0(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x44e10
xorl %eax, %eax
cmpq $0x0, -0x68(%rbp)
movb %al, -0xb1(%rbp)
jl 0x5045b
movq -0x68(%rbp), %rax
cmpq -0x10(%rbp), %rax
setbe %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x50467
jmp 0x50469
jmp 0x50488
leaq 0x1c2e8(%rip), %rdi     # 0x6c758
leaq 0x1aede(%rip), %rsi     # 0x6b355
movl $0xdc8, %edx            # imm = 0xDC8
leaq 0x1c318(%rip), %rcx     # 0x6c79b
callq 0x7180
leaq -0x70(%rbp), %rdi
callq 0x47550
testb $0x1, %al
jne 0x5049a
jmp 0x5052a
movsbl -0x49(%rbp), %eax
cmpl $0x3c, %eax
jne 0x504c1
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
movl $0x5, %esi
callq 0x44e10
jmp 0x50577
cmpq $0x0, -0x30(%rbp)
je 0x504d9
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x504e8
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x24(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0x50528
movq -0x78(%rbp), %rdi
callq 0x52ca0
testb $0x1, %al
jne 0x50528
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
movl $0x10, %esi
callq 0x44e10
jmp 0x50577
jmp 0x50559
cmpq $0x0, -0x68(%rbp)
jle 0x50557
movq -0x68(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x50557
movsbl -0x49(%rbp), %eax
cmpl $0x0, %eax
jne 0x50557
movq -0x68(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x50559
movq -0x88(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x80(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)