// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::node_output(pugi::impl::(anonymous namespace)::xml_buffered_writer&, pugi::xml_node_struct*, char const*, unsigned int, unsigned int)
PUGI__FN void node_output(xml_buffered_writer& writer, xml_node_struct* root, const char_t* indent, unsigned int flags, unsigned int depth)
	{
		size_t indent_length = ((flags & (format_indent | format_indent_attributes)) && (flags & format_raw) == 0) ? strlength(indent) : 0;
		unsigned int indent_flags = indent_indent;

		xml_node_struct* node = root;

		do
		{
			assert(node);

			// begin writing current node
			if (PUGI__NODETYPE(node) == node_pcdata || PUGI__NODETYPE(node) == node_cdata)
			{
				node_output_simple(writer, node, flags);

				indent_flags = 0;
			}
			else
			{
				if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
					writer.write('\n');

				if ((indent_flags & indent_indent) && indent_length)
					text_output_indent(writer, indent, indent_length, depth);

				if (PUGI__NODETYPE(node) == node_element)
				{
					indent_flags = indent_newline | indent_indent;

					if (node_output_start(writer, node, indent, indent_length, flags, depth))
					{
						// element nodes can have value if parse_embed_pcdata was used
						if (node->value)
							indent_flags = 0;

						node = node->first_child;
						depth++;
						continue;
					}
				}
				else if (PUGI__NODETYPE(node) == node_document)
				{
					indent_flags = indent_indent;

					if (node->first_child)
					{
						node = node->first_child;
						continue;
					}
				}
				else
				{
					node_output_simple(writer, node, flags);

					indent_flags = indent_newline | indent_indent;
				}
			}

			// continue to the next node
			while (node != root)
			{
				if (node->next_sibling)
				{
					node = node->next_sibling;
					break;
				}

				node = node->parent;

				// write closing node
				if (PUGI__NODETYPE(node) == node_element)
				{
					depth--;

					if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
						writer.write('\n');

					if ((indent_flags & indent_indent) && indent_length)
						text_output_indent(writer, indent, indent_length, depth);

					node_output_end(writer, node);

					indent_flags = indent_newline | indent_indent;
				}
			}
		}
		while (node != root);

		if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
			writer.write('\n');
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x1c(%rbp), %eax
andl $0x41, %eax
cmpl $0x0, %eax
je 0x45ad0
movl -0x1c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x45ad0
movq -0x18(%rbp), %rdi
callq 0x418f0
movq %rax, -0x40(%rbp)
jmp 0x45ad8
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x45ad8
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x2, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x45af8
jmp 0x45b17
leaq 0x270a7(%rip), %rdi     # 0x6cba6
leaq 0x2584f(%rip), %rsi     # 0x6b355
movl $0x1089, %edx           # imm = 0x1089
leaq 0x27099(%rip), %rcx     # 0x6cbab
callq 0x7180
movq -0x38(%rbp), %rax
movq (%rax), %rax
andq $0xf, %rax
cmpl $0x3, %eax
je 0x45b37
movq -0x38(%rbp), %rax
movq (%rax), %rax
andq $0xf, %rax
cmpl $0x4, %eax
jne 0x45b53
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x56e50
movl $0x0, -0x2c(%rbp)
jmp 0x45c55
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x45b77
movl -0x1c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x45b77
movq -0x8(%rbp), %rdi
movl $0xa, %esi
callq 0x48cf0
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x45b9d
cmpq $0x0, -0x28(%rbp)
je 0x45b9d
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x20(%rbp), %ecx
callq 0x57120
movq -0x38(%rbp), %rax
movq (%rax), %rax
andq $0xf, %rax
cmpl $0x2, %eax
jne 0x45c05
movl $0x3, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
callq 0x57290
testb $0x1, %al
jne 0x45bd7
jmp 0x45c03
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x45be9
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x45d0b
jmp 0x45c53
movq -0x38(%rbp), %rax
movq (%rax), %rax
andq $0xf, %rax
cmpl $0x1, %eax
jne 0x45c3a
movl $0x2, -0x2c(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x45c38
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x45d0b
jmp 0x45c51
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x56e50
movl $0x3, -0x2c(%rbp)
jmp 0x45c53
jmp 0x45c55
jmp 0x45c57
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x45d09
movq -0x38(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x45c81
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x45d09
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
andq $0xf, %rax
cmpl $0x2, %eax
jne 0x45d04
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x45cca
movl -0x1c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x45cca
movq -0x8(%rbp), %rdi
movl $0xa, %esi
callq 0x48cf0
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x45cf0
cmpq $0x0, -0x28(%rbp)
je 0x45cf0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x20(%rbp), %ecx
callq 0x57120
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x57450
movl $0x3, -0x2c(%rbp)
jmp 0x45c57
jmp 0x45d0b
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x45aef
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x45d3d
movl -0x1c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x45d3d
movq -0x8(%rbp), %rdi
movl $0xa, %esi
callq 0x48cf0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)