// File: /workspace/github_cpp_makefile_star2_O2/jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::get_buffer_encoding(pugi::xml_encoding, void const*, unsigned long)
PUGI__FN xml_encoding get_buffer_encoding(xml_encoding encoding, const void* contents, size_t size)
	{
		// replace wchar encoding with utf implementation
		if (encoding == encoding_wchar) return get_wchar_encoding();

		// replace utf16 encoding with utf16 with specific endianness
		if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;

		// replace utf32 encoding with utf32 with specific endianness
		if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;

		// only do autodetection if no explicit encoding is requested
		if (encoding != encoding_auto) return encoding;

		// try to guess encoding (based on XML specification, Appendix F.1)
		const uint8_t* data = static_cast<const uint8_t*>(contents);

		return guess_buffer_encoding(data, size);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %eax
cmpl $0x8, %edi
ja 0x22ea0
movl %eax, %ecx
leaq 0x8bfb(%rip), %rdi      # 0x2ba3c
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
movl $0x5, %r11d
jmpq *%rcx
movl %r11d, %eax
jmp 0x22ea0
movl $0x1, %ecx
cmpq $0x4, %rdx
jae 0x22e6b
movl %ecx, %eax
jmp 0x22ea0
movl $0x2, %eax
jmp 0x22ea0
movb (%rsi), %r10b
movb 0x1(%rsi), %r9b
movb 0x2(%rsi), %r8b
movb 0x3(%rsi), %dil
movl %r10d, %eax
orb %r9b, %al
sete %bl
cmpb $-0x2, %r8b
sete %bpl
andb %bl, %bpl
cmpb $-0x1, %dil
sete %r14b
movl $0x6, %eax
testb %r14b, %bpl
je 0x22ea9
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %r10d, %ebp
notb %bpl
movl %r9d, %r14d
xorb $-0x2, %r14b
orb %bpl, %r14b
sete %bpl
orb %r8b, %r14b
orb %dil, %r14b
je 0x22e50
movl %r10d, %r15d
xorb $-0x2, %r15b
movl %r9d, %r12d
notb %r12b
xorl %r14d, %r14d
orb %r15b, %r12b
sete %r15b
orb %r15b, %bpl
je 0x22eed
movb %r15b, %r14b
orl $0x2, %r14d
movl %r14d, %eax
jmp 0x22ea0
movl %r10d, %ebp
xorb $-0x11, %bpl
movl %r9d, %r14d
xorb $-0x45, %r14b
orb %bpl, %r14b
movl %r8d, %ebp
xorb $-0x41, %bpl
orb %r14b, %bpl
je 0x22e60
testb %r8b, %r8b
sete %bpl
andb %bpl, %bl
cmpb $0x3c, %dil
sete %bpl
testb %bpl, %bl
jne 0x22ea0
movl %r10d, %eax
xorb $0x3c, %al
orb %r9b, %al
sete %bl
orb %r8b, %al
orb %dil, %al
movl %r11d, %eax
je 0x22ea0
movl %r9d, %ebp
xorb $0x3c, %bpl
xorl %r11d, %r11d
orb %r10b, %bpl
sete %al
orb %r8b, %bpl
movl %edi, %r14d
xorb $0x3f, %r14b
orb %bpl, %r14b
jne 0x22f6c
movl $0x3, %eax
jmp 0x22ea0
movl %r8d, %ebp
xorb $0x3f, %bpl
movl %ebx, %r14d
orb %al, %r14b
movb %al, %r11b
orl $0x2, %r11d
orb %dil, %bpl
movl $0x2, %eax
cmovnel %r11d, %eax
testb %bl, %bl
cmovel %r11d, %eax
testb %r14b, %r14b
jne 0x22ea0
cmpq $0x6, %rdx
jb 0x22e60
cmpb $0x3c, %r10b
jne 0x22e60
cmpb $0x3f, %r9b
jne 0x22e60
cmpb $0x78, %r8b
jne 0x22e60
cmpb $0x6d, %dil
jne 0x22e60
cmpb $0x6c, 0x4(%rsi)
jne 0x22e60
movzbl 0x5(%rsi), %eax
leaq 0x8cde(%rip), %rdi      # 0x2bcc0
testb $0x8, (%rax,%rdi)
je 0x22e60
movabsq $0xe, %rax
leaq -0x7(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
movzbl -0x8(%rsi,%rax), %r8d
cmpl $0x65, %r8d
je 0x2301a
cmpl $0x3f, %r8d
jne 0x23021
jmp 0x22e60
cmpb $0x6e, -0x7(%rsi,%rax)
je 0x23026
incq %rax
jmp 0x22ff6
leaq -0x6(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x63, -0x6(%rsi,%rax)
jne 0x22e60
leaq -0x5(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x6f, -0x5(%rsi,%rax)
jne 0x22e60
leaq -0x4(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x64, -0x4(%rsi,%rax)
jne 0x22e60
leaq -0x3(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x69, -0x3(%rsi,%rax)
jne 0x22e60
leaq -0x2(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x6e, -0x2(%rsi,%rax)
jne 0x22e60
leaq -0x1(%rax), %r8
cmpq %rdx, %r8
jae 0x22e60
cmpb $0x67, -0x1(%rsi,%rax)
jne 0x22e60
cmpq %rdx, %rax
jae 0x22e60
movzbl (%rsi,%rax), %r8d
testb $0x8, (%r8,%rdi)
je 0x230d0
incq %rax
jmp 0x230b6
cmpb $0x3d, %r8b
jne 0x22e60
incq %rax
cmpq %rdx, %rax
jae 0x22e60
movzbl (%rsi,%rax), %r8d
incq %rax
testb $0x8, (%r8,%rdi)
jne 0x230dd
xorl %r9d, %r9d
cmpl $0x22, %r8d
setne %r9b
leal (%r9,%r9,4), %r9d
addl $0x22, %r9d
cmpl %r8d, %r9d
jne 0x22e60
leaq (%rsi,%rax), %r10
xorl %r8d, %r8d
movq %rax, %r11
cmpq %rdx, %r11
jae 0x22e60
movzbl (%r10), %ebx
testb $0x40, (%rbx,%rdi)
je 0x23139
incq %r11
incq %r8
incq %r10
jmp 0x2311b
cmpl %ebx, %r9d
jne 0x22e60
cmpq $0x6, %r8
je 0x231d4
cmpq $0xa, %r8
jne 0x22e60
movb (%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x49, %dl
jne 0x22e60
movb 0x1(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x53, %dl
jne 0x22e60
movb 0x2(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x4f, %dl
jne 0x22e60
cmpb $0x2d, 0x3(%rsi,%rax)
jne 0x22e60
cmpb $0x38, 0x4(%rsi,%rax)
jne 0x22e60
cmpb $0x38, 0x5(%rsi,%rax)
jne 0x22e60
cmpb $0x35, 0x6(%rsi,%rax)
jne 0x22e60
cmpb $0x39, 0x7(%rsi,%rax)
jne 0x22e60
cmpb $0x2d, 0x8(%rsi,%rax)
jne 0x22e60
cmpb $0x31, 0x9(%rsi,%rax)
jne 0x22e60
jmp 0x2322e
movb (%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x4c, %dl
jne 0x22e60
movb 0x1(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x41, %dl
jne 0x22e60
movb 0x2(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x54, %dl
jne 0x22e60
movb 0x3(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x49, %dl
jne 0x22e60
movb 0x4(%rsi,%rax), %dl
andb $-0x21, %dl
cmpb $0x4e, %dl
jne 0x22e60
cmpb $0x31, 0x5(%rsi,%rax)
jne 0x22e60
movl $0x9, %eax
jmp 0x22ea0