// File: /workspace/github_cpp_makefile_star2_O1/jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::parse_declaration_encoding(unsigned char const*, unsigned long, unsigned char const*&, unsigned long&)
PUGI__FN bool parse_declaration_encoding(const uint8_t* data, size_t size, const uint8_t*& out_encoding, size_t& out_length)
	{
	#define PUGI__SCANCHAR(ch) { if (offset >= size || data[offset] != ch) return false; offset++; }
	#define PUGI__SCANCHARTYPE(ct) { while (offset < size && PUGI__IS_CHARTYPE(data[offset], ct)) offset++; }

		// check if we have a non-empty XML declaration
		if (size < 6 || !((data[0] == '<') & (data[1] == '?') & (data[2] == 'x') & (data[3] == 'm') & (data[4] == 'l') && PUGI__IS_CHARTYPE(data[5], ct_space)))
			return false;

		// scan XML declaration until the encoding field
		for (size_t i = 6; i + 1 < size; ++i)
		{
			// declaration can not contain ? in quoted values
			if (data[i] == '?')
				return false;

			if (data[i] == 'e' && data[i + 1] == 'n')
			{
				size_t offset = i;

				// encoding follows the version field which can't contain 'en' so this has to be the encoding if XML is well formed
				PUGI__SCANCHAR('e'); PUGI__SCANCHAR('n'); PUGI__SCANCHAR('c'); PUGI__SCANCHAR('o');
				PUGI__SCANCHAR('d'); PUGI__SCANCHAR('i'); PUGI__SCANCHAR('n'); PUGI__SCANCHAR('g');

				// S? = S?
				PUGI__SCANCHARTYPE(ct_space);
				PUGI__SCANCHAR('=');
				PUGI__SCANCHARTYPE(ct_space);

				// the only two valid delimiters are ' and "
				uint8_t delimiter = (offset < size && data[offset] == '"') ? '"' : '\'';

				PUGI__SCANCHAR(delimiter);

				size_t start = offset;

				out_encoding = data + offset;

				PUGI__SCANCHARTYPE(ct_symbol);

				out_length = offset - start;

				PUGI__SCANCHAR(delimiter);

				return true;
			}
		}

		return false;

	#undef PUGI__SCANCHAR
	#undef PUGI__SCANCHARTYPE
	}

// Assembly:
cmpq $0x6, %rsi
jae 0x28dae
xorl %eax, %eax
retq
xorl %eax, %eax
cmpb $0x3c, (%rdi)
jne 0x28dad
cmpb $0x3f, 0x1(%rdi)
jne 0x28dad
cmpb $0x78, 0x2(%rdi)
jne 0x28dad
cmpb $0x6d, 0x3(%rdi)
jne 0x28dad
cmpb $0x6c, 0x4(%rdi)
jne 0x28dad
movzbl 0x5(%rdi), %r8d
leaq 0x9ea7(%rip), %rax      # 0x32c80
testb $0x8, (%r8,%rax)
sete %r8b
cmpq $0x8, %rsi
setb %r9b
orb %r8b, %r9b
jne 0x28dab
movl $0x7, %r9d
subq %rsi, %r9
movl $0xf, %r8d
movzbl -0x9(%rdi,%r8), %r10d
cmpl $0x65, %r10d
je 0x28e12
cmpl $0x3f, %r10d
jne 0x28e1a
jmp 0x28dab
cmpb $0x6e, -0x8(%rdi,%r8)
je 0x28e2f
leaq (%r9,%r8), %r10
incq %r10
incq %r8
cmpq $0xf, %r10
jne 0x28dfe
jmp 0x28dab
leaq -0x9(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
leaq -0x7(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x63, -0x7(%rdi,%r8)
jne 0x28dab
leaq -0x6(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x6f, -0x6(%rdi,%r8)
jne 0x28dab
leaq -0x5(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x64, -0x5(%rdi,%r8)
jne 0x28dab
leaq -0x4(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x69, -0x4(%rdi,%r8)
jne 0x28dab
leaq -0x3(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x6e, -0x3(%rdi,%r8)
jne 0x28dab
leaq -0x2(%r8), %r9
cmpq %rsi, %r9
jae 0x28dab
cmpb $0x67, -0x2(%rdi,%r8)
jne 0x28dab
leaq -0x1(%r8), %r9
cmpq %rsi, %r9
setb %r10b
jae 0x28dab
movzbl -0x1(%rdi,%r8), %r11d
testb $0x8, (%r11,%rax)
je 0x28f12
cmpq %rsi, %r8
setb %r10b
jae 0x28dab
movzbl (%rdi,%r8), %r9d
incq %r8
testb $0x8, (%r9,%rax)
jne 0x28ef0
decq %r8
movq %r8, %r9
testb %r10b, %r10b
je 0x28dab
cmpb $0x3d, (%rdi,%r9)
jne 0x28dab
addq $0x2, %r9
movq %r9, %r8
leaq -0x1(%r9), %r10
cmpq %rsi, %r10
jae 0x28f5c
movzbl -0x1(%rdi,%r8), %r11d
leaq 0x1(%r8), %r9
testb $0x8, (%r11,%rax)
jne 0x28f2a
xorl %r9d, %r9d
cmpb $0x22, %r11b
setne %r9b
leal (%r9,%r9,4), %r9d
addl $0x22, %r9d
jmp 0x28f62
movl $0x27, %r9d
cmpq %rsi, %r10
jae 0x28dab
movzbl -0x1(%rdi,%r8), %r10d
cmpl %r10d, %r9d
jne 0x28dab
leaq (%rdi,%r8), %r10
movq %r10, (%rdx)
cmpq %rsi, %r8
setb %r10b
jae 0x28fe2
movzbl (%rdi,%r8), %edx
testb $0x40, (%rdx,%rax)
movq %r8, %rdx
je 0x28fc5
movl $0x3, %r10d
subq %rsi, %r10
movq %r8, %rdx
leaq (%r10,%rdx), %r11
cmpq $0x2, %r11
je 0x28fe2
movzbl 0x1(%rdi,%rdx), %r11d
incq %rdx
testb $0x40, (%r11,%rax)
jne 0x28fa4
cmpq %rsi, %rdx
setb %r10b
movq %rdx, %rax
subq %r8, %rax
movq %rax, (%rcx)
testb %r10b, %r10b
je 0x28dab
movzbl (%rdi,%rdx), %eax
cmpl %eax, %r9d
sete %al
retq
xorl %eax, %eax
subq %r8, %rsi
movl $0x0, %edx
cmovaeq %rsi, %rdx
movq %rdx, (%rcx)
retq