// File: adamiaonr[P]rid-analytics/src/pugixml.cpp
// Function: unsigned int pugi::impl::(anonymous namespace)::string_to_integer<unsigned int>(char const*, unsigned int, unsigned int)
U string_to_integer(const char_t* value, U minneg, U maxpos)
	{
		U result = 0;
		const char_t* s = value;

		while (PUGI__IS_CHARTYPE(*s, ct_space))
			s++;

		bool negative = (*s == '-');

		s += (*s == '+' || *s == '-');

		bool overflow = false;

		if (s[0] == '0' && (s[1] | ' ') == 'x')
		{
			s += 2;

			// since overflow detection relies on length of the sequence skip leading zeros
			while (*s == '0')
				s++;

			const char_t* start = s;

			for (;;)
			{
				if (static_cast<unsigned>(*s - '0') < 10)
					result = result * 16 + (*s - '0');
				else if (static_cast<unsigned>((*s | ' ') - 'a') < 6)
					result = result * 16 + ((*s | ' ') - 'a' + 10);
				else
					break;

				s++;
			}

			size_t digits = static_cast<size_t>(s - start);

			overflow = digits > sizeof(U) * 2;
		}
		else
		{
			// since overflow detection relies on length of the sequence skip leading zeros
			while (*s == '0')
				s++;

			const char_t* start = s;

			for (;;)
			{
				if (static_cast<unsigned>(*s - '0') < 10)
					result = result * 10 + (*s - '0');
				else
					break;

				s++;
			}

			size_t digits = static_cast<size_t>(s - start);

			PUGI__STATIC_ASSERT(sizeof(U) == 8 || sizeof(U) == 4 || sizeof(U) == 2);

			const size_t max_digits10 = sizeof(U) == 8 ? 20 : sizeof(U) == 4 ? 10 : 5;
			const char_t max_lead = sizeof(U) == 8 ? '1' : sizeof(U) == 4 ? '4' : '6';
			const size_t high_bit = sizeof(U) * 8 - 1;

			overflow = digits >= max_digits10 && !(digits == max_digits10 && (*start < max_lead || (*start == max_lead && result >> high_bit)));
		}

		if (negative)
			return (overflow || result > minneg) ? 0 - minneg : 0 - result;
		else
			return (overflow || result > maxpos) ? maxpos : result;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x4b9e3(%rip), %rax     # 0x5e8f0
movzbl (%rax,%rcx), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x12f27
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12efd
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
andb $0x1, %al
movb %al, -0x29(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x2b, %ecx
movb %al, -0x69(%rbp)
je 0x12f5a
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movb $0x0, -0x2a(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x1304e
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x1304e
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x12fbe
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12fa4
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0xa, %eax
jae 0x12fec
movl -0x1c(%rbp), %eax
shll $0x4, %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1301f
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
orl $0x20, %eax
subl $0x61, %eax
cmpl $0x6, %eax
jae 0x1301b
movl -0x1c(%rbp), %eax
shll $0x4, %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
orl $0x20, %ecx
subl $0x61, %ecx
addl $0xa, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1301d
jmp 0x1302d
jmp 0x1301f
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12fc6
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
cmpq $0x8, -0x40(%rbp)
seta %al
andb $0x1, %al
movb %al, -0x2a(%rbp)
jmp 0x1312e
jmp 0x13050
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x1306a
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x13050
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
cmpl $0xa, %eax
jae 0x13096
imull $0xa, -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
subl $0x30, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13098
jmp 0x130a6
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x13072
movq -0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq $0xa, -0x58(%rbp)
movb $0x34, -0x59(%rbp)
movq $0x1f, -0x68(%rbp)
xorl %eax, %eax
cmpq $0xa, -0x50(%rbp)
movb %al, -0x6a(%rbp)
jb 0x13126
xorl %eax, %eax
cmpq $0xa, -0x50(%rbp)
movb %al, -0x6b(%rbp)
jne 0x1311e
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x34, %ecx
movb %al, -0x6c(%rbp)
jl 0x13118
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x34, %ecx
movb %al, -0x6d(%rbp)
jne 0x13112
movl -0x1c(%rbp), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x6d(%rbp)
movb -0x6d(%rbp), %al
movb %al, -0x6c(%rbp)
movb -0x6c(%rbp), %al
movb %al, -0x6b(%rbp)
movb -0x6b(%rbp), %al
xorb $-0x1, %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
andb $0x1, %al
movb %al, -0x2a(%rbp)
testb $0x1, -0x29(%rbp)
je 0x1315c
testb $0x1, -0x2a(%rbp)
jne 0x13142
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jbe 0x1314c
xorl %eax, %eax
subl -0x14(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x13154
xorl %eax, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1317e
testb $0x1, -0x2a(%rbp)
jne 0x1316a
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jbe 0x13172
movl -0x18(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x13178
movl -0x1c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)