// File: /workspace/github_cpp_makefile_star2_O2/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:
decq %rdi
leaq 0x18438(%rip), %rax     # 0x26580
movzbl 0x1(%rdi), %ecx
incq %rdi
testb $0x8, (%rcx,%rax)
jne 0xe148
leal -0x2b(%rcx), %r8d
xorl %eax, %eax
testb $-0x3, %r8b
sete %al
leaq (%rdi,%rax), %r8
cmpb $0x30, (%rdi,%rax)
jne 0xe1cb
movb 0x1(%rdi,%rax), %r9b
andb $-0x21, %r9b
cmpb $0x58, %r9b
jne 0xe1cb
addq %rax, %rdi
addq $0x2, %rdi
movb (%rdi), %r9b
incq %rdi
cmpb $0x30, %r9b
je 0xe182
xorl %r8d, %r8d
xorl %eax, %eax
movsbl %r9b, %r9d
leal -0x30(%r9), %r10d
cmpl $0x9, %r10d
ja 0xe1a9
shll $0x4, %eax
orl %r10d, %eax
jmp 0xe1c0
orl $0x20, %r9d
leal -0x61(%r9), %r10d
cmpl $0x5, %r10d
ja 0xe215
shll $0x4, %eax
addl %r9d, %eax
addl $-0x57, %eax
movb (%rdi), %r9b
incq %r8
incq %rdi
jmp 0xe193
movb (%r8), %dil
incq %r8
cmpb $0x30, %dil
je 0xe1cb
xorl %r9d, %r9d
movl %edi, %r11d
xorl %eax, %eax
movsbl %r11b, %r10d
addl $-0x30, %r10d
cmpl $0x9, %r10d
ja 0xe1ff
imull $0xa, %eax, %eax
addl %eax, %r10d
movb (%r8,%r9), %r11b
incq %r9
movl %r10d, %eax
jmp 0xe1df
cmpq $0xa, %r9
jb 0xe210
movb $0x1, %r8b
jne 0xe22c
cmpb $0x34, %dil
jge 0xe21f
xorl %r8d, %r8d
jmp 0xe22c
cmpq $0x9, %r8
setae %r8b
jmp 0xe22c
setne %dil
testl %eax, %eax
setns %r8b
orb %dil, %r8b
cmpb $0x2d, %cl
jne 0xe23f
cmpl %esi, %eax
cmovael %esi, %eax
testb %r8b, %r8b
cmovnel %esi, %eax
negl %eax
retq
cmpl %edx, %eax
cmovael %edx, %eax
testb %r8b, %r8b
cmovnel %edx, %eax
retq