// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl %edx, 0x3c(%rsp)
movq %rcx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %r9, 0x20(%rsp)
movq 0x30(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x39808a
movl $0xfffffffc, 0x54(%rsp) # imm = 0xFFFFFFFC
jmp 0x39845f
movq 0x40(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
addq $0x1, %rax
cmpq 0x28(%rsp), %rax
jne 0x39814e
cmpl $0x1, 0x3c(%rsp)
je 0x3980c3
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x39845f
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
addl $-0x3, %eax
subl $0x2, %eax
ja 0x3980e6
jmp 0x3980d9
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x39845f
movq 0x30(%rsp), %rax
movzbl (%rax), %eax
movl %eax, 0x10(%rsp)
testl %eax, %eax
je 0x39813c
jmp 0x3980f8
movl 0x10(%rsp), %eax
subl $0x3c, %eax
je 0x39813c
jmp 0x398103
movl 0x10(%rsp), %eax
subl $0xef, %eax
je 0x398120
jmp 0x398110
movl 0x10(%rsp), %eax
addl $0xffffff02, %eax       # imm = 0xFFFFFF02
subl $0x1, %eax
ja 0x398149
jmp 0x398120
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x0, %eax
jne 0x39813a
cmpl $0x1, 0x3c(%rsp)
jne 0x39813a
jmp 0x398149
jmp 0x39813c
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x39845f
jmp 0x398411
movq 0x30(%rsp), %rax
movw (%rax), %ax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0xc(%rsp)
subl $0x3c00, %eax           # imm = 0x3C00
je 0x3981ec
jmp 0x39816e
movl 0xc(%rsp), %eax
subl $0xefbb, %eax           # imm = 0xEFBB
je 0x3982aa
jmp 0x39817f
movl 0xc(%rsp), %eax
subl $0xfeff, %eax           # imm = 0xFEFF
je 0x3981a0
jmp 0x39818c
movl 0xc(%rsp), %eax
subl $0xfffe, %eax           # imm = 0xFFFE
je 0x39825e
jmp 0x398345
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x0, %eax
jne 0x3981bd
cmpl $0x1, 0x3c(%rsp)
jne 0x3981bd
jmp 0x39840f
movq 0x30(%rsp), %rcx
addq $0x2, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movl $0xe, 0x54(%rsp)
jmp 0x39845f
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x4, %eax
je 0x39820e
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x3, %eax
jne 0x39821a
cmpl $0x1, 0x3c(%rsp)
jne 0x39821a
jmp 0x39840f
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x54(%rsp)
jmp 0x39845f
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x0, %eax
jne 0x39827b
cmpl $0x1, 0x3c(%rsp)
jne 0x39827b
jmp 0x39840f
movq 0x30(%rsp), %rcx
addq $0x2, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movl $0xe, 0x54(%rsp)
jmp 0x39845f
cmpl $0x1, 0x3c(%rsp)
jne 0x3982e4
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
je 0x3982dd
cmpl $0x4, 0x14(%rsp)
je 0x3982dd
cmpl $0x5, 0x14(%rsp)
je 0x3982dd
cmpl $0x3, 0x14(%rsp)
jne 0x3982e2
jmp 0x39840f
jmp 0x3982e4
movq 0x30(%rsp), %rax
addq $0x2, %rax
cmpq 0x28(%rsp), %rax
jne 0x398301
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x39845f
movq 0x30(%rsp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xbf, %eax
jne 0x398340
movq 0x30(%rsp), %rcx
addq $0x3, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movl $0xe, 0x54(%rsp)
jmp 0x39845f
jmp 0x39840f
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x3983b3
cmpl $0x1, 0x3c(%rsp)
jne 0x39836f
movq 0x40(%rsp), %rax
movsbl 0x85(%rax), %eax
cmpl $0x5, %eax
jne 0x39836f
jmp 0x39840f
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x54(%rsp)
jmp 0x39845f
movq 0x30(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x39840b
cmpl $0x1, 0x3c(%rsp)
jne 0x3983ca
jmp 0x39840f
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x54(%rsp)
jmp 0x39845f
jmp 0x39840d
jmp 0x39840f
jmp 0x398411
movq 0x48(%rsp), %rax
movq 0x40(%rsp), %rcx
movsbl 0x85(%rcx), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq 0x3c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax,%rax)