// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::convert_number_to_string(double, pugi::impl::(anonymous namespace)::xpath_allocator*)
PUGI__FN xpath_string convert_number_to_string(double value, xpath_allocator* alloc)
	{
		// try special number conversion
		const char_t* special = convert_number_to_string_special(value);
		if (special) return xpath_string::from_const(special);

		// get mantissa + exponent form
		char mantissa_buffer[32];

		char* mantissa;
		int exponent;
		convert_number_to_mantissa_exponent(value, mantissa_buffer, &mantissa, &exponent);

		// allocate a buffer of suitable length for the number
		size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4;
		char_t* result = static_cast<char_t*>(alloc->allocate(sizeof(char_t) * result_size));
		if (!result) return xpath_string();

		// make the number!
		char_t* s = result;

		// sign
		if (value < 0) *s++ = '-';

		// integer part
		if (exponent <= 0)
		{
			*s++ = '0';
		}
		else
		{
			while (exponent > 0)
			{
				assert(*mantissa == 0 || static_cast<unsigned int>(*mantissa - '0') <= 9);
				*s++ = *mantissa ? *mantissa++ : '0';
				exponent--;
			}
		}

		// fractional part
		if (*mantissa)
		{
			// decimal point
			*s++ = '.';

			// extra zeroes from negative exponent
			while (exponent < 0)
			{
				*s++ = '0';
				exponent++;
			}

			// extra mantissa digits
			while (*mantissa)
			{
				assert(static_cast<unsigned int>(*mantissa - '0') <= 9);
				*s++ = *mantissa++;
			}
		}

		// zero-terminate
		assert(s < result + result_size);
		*s = 0;

		return xpath_string::from_heap_preallocated(result, s);
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x78(%rbp)
movq %rdi, -0x70(%rbp)
movsd %xmm0, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x62480
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x61e13
movq -0x78(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x60df0
jmp 0x62078
movsd -0x8(%rbp), %xmm0
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
callq 0x62530
leaq -0x40(%rbp), %rdi
callq 0x7390
movq %rax, -0x80(%rbp)
cmpl $0x0, -0x4c(%rbp)
jle 0x61e47
movl -0x4c(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x61e52
xorl %eax, %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rax
movl -0x84(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
shlq $0x0, %rsi
callq 0x5cde0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x61e94
movq -0x78(%rbp), %rdi
callq 0x4e460
jmp 0x62078
movq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0x61eb8
movq -0x68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x68(%rbp)
movb $0x2d, (%rax)
cmpl $0x0, -0x4c(%rbp)
jg 0x61ed5
movq -0x68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x68(%rbp)
movb $0x30, (%rax)
jmp 0x61f8b
jmp 0x61ed7
cmpl $0x0, -0x4c(%rbp)
jle 0x61f89
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x85(%rbp)
je 0x61f0b
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x9, %eax
setbe %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
testb $0x1, %al
jne 0x61f17
jmp 0x61f19
jmp 0x61f38
leaq 0xc696(%rip), %rdi      # 0x6e5b6
leaq 0x942e(%rip), %rsi      # 0x6b355
movl $0x2016, %edx           # imm = 0x2016
leaq 0xc6c5(%rip), %rcx      # 0x6e5f8
callq 0x7180
movq -0x48(%rbp), %rax
cmpb $0x0, (%rax)
je 0x61f5a
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb (%rax), %al
movb %al, -0x86(%rbp)
jmp 0x61f64
movb $0x30, %al
movb %al, -0x86(%rbp)
jmp 0x61f64
movb -0x86(%rbp), %cl
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x68(%rbp)
movb %cl, (%rax)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x61ed7
jmp 0x61f8b
movq -0x48(%rbp), %rax
cmpb $0x0, (%rax)
je 0x6202e
movq -0x68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x68(%rbp)
movb $0x2e, (%rax)
cmpl $0x0, -0x4c(%rbp)
jge 0x61fcd
movq -0x68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x68(%rbp)
movb $0x30, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x61faa
jmp 0x61fcf
movq -0x48(%rbp), %rax
cmpb $0x0, (%rax)
je 0x6202c
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0x9, %eax
ja 0x61fe9
jmp 0x62008
leaq 0xc5d8(%rip), %rdi      # 0x6e5c8
leaq 0x935e(%rip), %rsi      # 0x6b355
movl $0x202c, %edx           # imm = 0x202C
leaq 0xc5f5(%rip), %rcx      # 0x6e5f8
callq 0x7180
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb (%rax), %cl
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x68(%rbp)
movb %cl, (%rax)
jmp 0x61fcf
jmp 0x6202e
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
addq -0x58(%rbp), %rcx
cmpq %rcx, %rax
jae 0x62041
jmp 0x62060
leaq 0xc614(%rip), %rdi      # 0x6e65c
leaq 0x9306(%rip), %rsi      # 0x6b355
movl $0x2032, %edx           # imm = 0x2032
leaq 0xc59d(%rip), %rcx      # 0x6e5f8
callq 0x7180
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rax
movb $0x0, (%rax)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x61be0
movq -0x70(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)