// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/expat-2.0.1/lib/xmltok.c
// Function: XmlInitUnknownEncoding
ENCODING *
XmlInitUnknownEncoding(void *mem,
                       int *table,
                       CONVERTER convert, 
                       void *userData)
{
  int i;
  struct unknown_encoding *e = (struct unknown_encoding *)mem;
  for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
    ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
  for (i = 0; i < 128; i++)
    if (latin1_encoding.type[i] != BT_OTHER
        && latin1_encoding.type[i] != BT_NONXML
        && table[i] != i)
      return 0;
  for (i = 0; i < 256; i++) {
    int c = table[i];
    if (c == -1) {
      e->normal.type[i] = BT_MALFORM;
      /* This shouldn't really get used. */
      e->utf16[i] = 0xFFFF;
      e->utf8[i][0] = 1;
      e->utf8[i][1] = 0;
    }
    else if (c < 0) {
      if (c < -4)
        return 0;
      e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
      e->utf8[i][0] = 0;
      e->utf16[i] = 0;
    }
    else if (c < 0x80) {
      if (latin1_encoding.type[c] != BT_OTHER
          && latin1_encoding.type[c] != BT_NONXML
          && c != i)
        return 0;
      e->normal.type[i] = latin1_encoding.type[c];
      e->utf8[i][0] = 1;
      e->utf8[i][1] = (char)c;
      e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
    }
    else if (checkCharRefNumber(c) < 0) {
      e->normal.type[i] = BT_NONXML;
      /* This shouldn't really get used. */
      e->utf16[i] = 0xFFFF;
      e->utf8[i][0] = 1;
      e->utf8[i][1] = 0;
    }
    else {
      if (c > 0xFFFF)
        return 0;
      if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
        e->normal.type[i] = BT_NMSTRT;
      else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
        e->normal.type[i] = BT_NAME;
      else
        e->normal.type[i] = BT_OTHER;
      e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
      e->utf16[i] = (unsigned short)c;
    }
  }
  e->userData = userData;
  e->convert = convert;
  if (convert) {
    e->normal.isName2 = unknown_isName;
    e->normal.isName3 = unknown_isName;
    e->normal.isName4 = unknown_isName;
    e->normal.isNmstrt2 = unknown_isNmstrt;
    e->normal.isNmstrt3 = unknown_isNmstrt;
    e->normal.isNmstrt4 = unknown_isNmstrt;
    e->normal.isInvalid2 = unknown_isInvalid;
    e->normal.isInvalid3 = unknown_isInvalid;
    e->normal.isInvalid4 = unknown_isInvalid;
  }
  e->normal.enc.utf8Convert = unknown_toUtf8;
  e->normal.enc.utf16Convert = unknown_toUtf16;
  return &(e->normal.enc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
xorl %eax, %eax
leaq 0x261be6(%rip), %rbp    # 0x4b59f0
movb (%rax,%rbp), %sil
movb %sil, (%rbx,%rax)
incq %rax
cmpq $0x1d0, %rax            # imm = 0x1D0
jne 0x253e0a
xorl %eax, %eax
movzbl 0x88(%rax,%rbp), %esi
testl %esi, %esi
je 0x253e3d
cmpl $0x1c, %esi
je 0x253e3d
movl (%r12,%rax,4), %esi
cmpq %rsi, %rax
jne 0x254086
incq %rax
cmpq $0x80, %rax
jne 0x253e1f
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movl $0x3e1, %r15d           # imm = 0x3E1
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movl (%r12,%r14,4), %r13d
cmpq %rcx, %r13
je 0x253ec8
testl %r13d, %r13d
js 0x253eec
cmpl $0x7f, %r13d
ja 0x253f1c
movzbl 0x88(%r13,%rbp), %eax
testl %eax, %eax
je 0x253e93
cmpl $0x1c, %eax
je 0x253e93
cmpq %r13, %r14
jne 0x254086
movb %al, 0x88(%rbx,%r14)
movb $0x1, 0x3e0(%rbx,%r14,4)
movb %r13b, 0x3e1(%rbx,%r14,4)
cmpq $0x1, %r13
movl $0x0, %eax
sbbl %eax, %eax
orl %r13d, %eax
movw %ax, 0x1e0(%rbx,%r14,2)
jmp 0x253fe9
movb $0x1, 0x88(%rbx,%r14)
movw $0xffff, 0x1e0(%rbx,%r14,2) # imm = 0xFFFF
movw $0x1, 0x3e0(%rbx,%r14,4)
jmp 0x253fe9
cmpl $-0x4, %r13d
jb 0x254086
movb $0x3, %al
subb %r13b, %al
movb %al, 0x88(%rbx,%r14)
movb $0x0, 0x3e0(%rbx,%r14,4)
movw $0x0, 0x1e0(%rbx,%r14,2)
jmp 0x253fe9
movl %r13d, %edi
callq 0x25409a
testl %eax, %eax
js 0x253f7b
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x254086
movl %r13d, %edx
shrl $0x8, %edx
leaq 0x1795ce(%rip), %rax    # 0x3cd510
movzbl (%rdx,%rax), %ecx
movl %r13d, %eax
shrl $0x5, %eax
andl $0x7, %eax
shll $0x5, %ecx
leal (%rcx,%rax,4), %ecx
leaq 0x1790b4(%rip), %r8     # 0x3cd010
movl (%rcx,%r8), %edi
movl $0x1, %esi
movl %r13d, %ecx
shll %cl, %esi
btl %r13d, %edi
jae 0x253f9c
movb $0x16, 0x88(%rbx,%r14)
jmp 0x253fc7
movb $0x0, 0x88(%rbx,%r14)
movw $0xffff, 0x1e0(%rbx,%r14,2) # imm = 0xFFFF
movw $0x1, 0x3e0(%rbx,%r14,4)
jmp 0x253fe4
leaq 0x17966d(%rip), %rcx    # 0x3cd610
movzbl (%rdx,%rcx), %ecx
shll $0x5, %ecx
leal (%rcx,%rax,4), %eax
testl %esi, (%rax,%r8)
je 0x253fbe
movb $0x1a, 0x88(%rbx,%r14)
jmp 0x253fc7
movb $0x1c, 0x88(%rbx,%r14)
leaq (%rbx,%r15), %rsi
movl %r13d, %edi
callq 0x253cfc
movb %al, 0x3e0(%rbx,%r14,4)
movw %r13w, 0x1e0(%rbx,%r14,2)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
incq %r14
addq $0x4, %r15
cmpq $0x100, %r14            # imm = 0x100
jne 0x253e60
movq 0x8(%rsp), %rax
movq %rax, 0x1d8(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x1d0(%rbx)
testq %rax, %rax
je 0x25406e
leaq 0xc1(%rip), %rax        # 0x2540e2
movq %rax, 0x188(%rbx)
movq %rax, 0x190(%rbx)
movq %rax, 0x198(%rbx)
leaq 0xf3(%rip), %rax        # 0x254130
movq %rax, 0x1a0(%rbx)
movq %rax, 0x1a8(%rbx)
movq %rax, 0x1b0(%rbx)
leaq 0x125(%rip), %rax       # 0x25417e
movq %rax, 0x1b8(%rbx)
movq %rax, 0x1c0(%rbx)
movq %rax, 0x1c8(%rbx)
leaq 0x133(%rip), %rax       # 0x2541a8
movq %rax, 0x70(%rbx)
leaq 0x203(%rip), %rax       # 0x254283
movq %rax, 0x78(%rbx)
jmp 0x254088
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq