// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/expat-2.0.1/lib/xmltok.c
// Function: initScan
static int
initScan(const ENCODING * const *encodingTable,
         const INIT_ENCODING *enc,
         int state,
         const char *ptr,
         const char *end,
         const char **nextTokPtr)
{
  const ENCODING **encPtr;

  if (ptr == end)
    return XML_TOK_NONE;
  encPtr = enc->encPtr;
  if (ptr + 1 == end) {
    /* only a single byte available for auto-detection */
#ifndef XML_DTD /* FIXME */
    /* a well-formed document entity must have more than one byte */
    if (state != XML_CONTENT_STATE)
      return XML_TOK_PARTIAL;
#endif
    /* so we're parsing an external text entity... */
    /* if UTF-16 was externally specified, then we need at least 2 bytes */
    switch (INIT_ENC_INDEX(enc)) {
    case UTF_16_ENC:
    case UTF_16LE_ENC:
    case UTF_16BE_ENC:
      return XML_TOK_PARTIAL;
    }
    switch ((unsigned char)*ptr) {
    case 0xFE:
    case 0xFF:
    case 0xEF: /* possibly first byte of UTF-8 BOM */
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      /* fall through */
    case 0x00:
    case 0x3C:
      return XML_TOK_PARTIAL;
    }
  }
  else {
    switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
    case 0xFEFF:
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      *nextTokPtr = ptr + 2;
      *encPtr = encodingTable[UTF_16BE_ENC];
      return XML_TOK_BOM;
    /* 00 3C is handled in the default case */
    case 0x3C00:
      if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
           || INIT_ENC_INDEX(enc) == UTF_16_ENC)
          && state == XML_CONTENT_STATE)
        break;
      *encPtr = encodingTable[UTF_16LE_ENC];
      return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
    case 0xFFFE:
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      *nextTokPtr = ptr + 2;
      *encPtr = encodingTable[UTF_16LE_ENC];
      return XML_TOK_BOM;
    case 0xEFBB:
      /* Maybe a UTF-8 BOM (EF BB BF) */
      /* If there's an explicitly specified (external) encoding
         of ISO-8859-1 or some flavour of UTF-16
         and this is an external text entity,
         don't look for the BOM,
         because it might be a legal data.
      */
      if (state == XML_CONTENT_STATE) {
        int e = INIT_ENC_INDEX(enc);
        if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC
            || e == UTF_16LE_ENC || e == UTF_16_ENC)
          break;
      }
      if (ptr + 2 == end)
        return XML_TOK_PARTIAL;
      if ((unsigned char)ptr[2] == 0xBF) {
        *nextTokPtr = ptr + 3;
        *encPtr = encodingTable[UTF_8_ENC];
        return XML_TOK_BOM;
      }
      break;
    default:
      if (ptr[0] == '\0') {
        /* 0 isn't a legal data character. Furthermore a document
           entity can only start with ASCII characters.  So the only
           way this can fail to be big-endian UTF-16 if it it's an
           external parsed general entity that's labelled as
           UTF-16LE.
        */
        if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
          break;
        *encPtr = encodingTable[UTF_16BE_ENC];
        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
      }
      else if (ptr[1] == '\0') {
        /* We could recover here in the case:
            - parsing an external entity
            - second byte is 0
            - no externally specified encoding
            - no encoding declaration
           by assuming UTF-16LE.  But we don't, because this would mean when
           presented just with a single byte, we couldn't reliably determine
           whether we needed further bytes.
        */
        if (state == XML_CONTENT_STATE)
          break;
        *encPtr = encodingTable[UTF_16LE_ENC];
        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
      }
      break;
    }
  }
  *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
}

// Assembly:
pushq %rbp
pushq %rbx
cmpq %rcx, %rdx
je 0x25d69d
movq 0x88(%rdi), %r9
leaq 0x1(%rdx), %rax
cmpq %rcx, %rax
je 0x25d6a7
movzbl (%rdx), %r10d
movl %r10d, %r11d
shll $0x8, %r11d
movzbl 0x1(%rdx), %eax
orl %eax, %r11d
movzwl %r11w, %r11d
cmpl $0xfefe, %r11d          # imm = 0xFEFE
jg 0x25d6fa
cmpl $0x3c00, %r11d          # imm = 0x3C00
je 0x25d766
cmpl $0xefbb, %r11d          # imm = 0xEFBB
jne 0x25d72e
cmpl $0x1, %esi
jne 0x25d674
movzbl 0x85(%rdi), %eax
cmpl $0x5, %eax
ja 0x25d674
movl $0x39, %r10d
btl %eax, %r10d
jb 0x25d7eb
leaq 0x2(%rdx), %rax
cmpq %rcx, %rax
je 0x25d814
cmpb $-0x41, (%rax)
jne 0x25d7eb
addq $0x3, %rdx
movq %rdx, (%r8)
leaq 0x258930(%rip), %rax    # 0x4b5fc8
jmp 0x25d793
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x25d79b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x1, %esi
jne 0x25d79b
movb 0x85(%rdi), %r10b
leal -0x3(%r10), %r11d
cmpb $0x3, %r11b
jb 0x25d79b
movzbl (%rdx), %r11d
leal -0xef(%r11), %ebx
cmpl $0x10, %ebx
ja 0x25d7e0
movl $0x18001, %ebp          # imm = 0x18001
btl %ebx, %ebp
jae 0x25d7e0
testb %r10b, %r10b
jne 0x25d79b
jmp 0x25d7eb
cmpl $0xfffe, %r11d          # imm = 0xFFFE
je 0x25d777
cmpl $0xfeff, %r11d          # imm = 0xFEFF
jne 0x25d72e
cmpl $0x1, %esi
jne 0x25d71e
cmpb $0x0, 0x85(%rdi)
je 0x25d7eb
addq $0x2, %rdx
movq %rdx, (%r8)
leaq 0x258a6c(%rip), %rax    # 0x4b6198
jmp 0x25d793
testb %r10b, %r10b
je 0x25d7b8
testb %al, %al
setne %al
cmpl $0x1, %esi
sete %r10b
orb %al, %r10b
jne 0x25d7eb
leaq 0x258c15(%rip), %rdi    # 0x4b6368
movq %rdi, (%r9)
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
popq %rbx
popq %rbp
jmp 0x2573d7
movb 0x85(%rdi), %al
cmpb $0x4, %al
jne 0x25d79e
cmpl $0x1, %esi
jne 0x25d7af
jmp 0x25d7eb
cmpl $0x1, %esi
jne 0x25d785
cmpb $0x0, 0x85(%rdi)
je 0x25d7eb
addq $0x2, %rdx
movq %rdx, (%r8)
leaq 0x258bd5(%rip), %rax    # 0x4b6368
movq %rax, (%r9)
movl $0xe, %eax
popq %rbx
popq %rbp
retq
cmpb $0x3, %al
sete %al
cmpl $0x1, %esi
sete %r10b
testb %al, %r10b
jne 0x25d7eb
leaq 0x258bb2(%rip), %rdi    # 0x4b6368
jmp 0x25d7cd
cmpl $0x1, %esi
jne 0x25d7c6
cmpb $0x5, 0x85(%rdi)
je 0x25d7eb
leaq 0x2589cb(%rip), %rdi    # 0x4b6198
movq %rdi, (%r9)
movl %esi, %eax
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
popq %rbx
popq %rbp
jmpq *(%rdi,%rax,8)
testl %r11d, %r11d
je 0x25d79b
cmpl $0x3c, %r11d
je 0x25d79b
movsbq 0x85(%rdi), %rax
leaq 0x258796(%rip), %rdi    # 0x4b5f90
movq (%rdi,%rax,8), %rdi
movq %rdi, (%r9)
movl %esi, %eax
movq (%rdi,%rax,8), %rax
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
popq %rbx
popq %rbp
jmpq *%rax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x25d79b