// File: /workspace/github_c_makefile_star2_O2/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 0x2316f2(%rip), %rbp    # 0x434a10
cmpq $0x1d0, %rax            # imm = 0x1D0
je 0x203333
movb (%rax,%rbp), %sil
movb %sil, (%rbx,%rax)
incq %rax
jmp 0x20331e
xorl %eax, %eax
cmpq $0x80, %rax
je 0x203360
movzbl 0x88(%rax,%rbp), %esi
testl %esi, %esi
je 0x20335b
cmpl $0x1c, %esi
je 0x20335b
movl (%r12,%rax,4), %esi
cmpq %rsi, %rax
jne 0x20359e
incq %rax
jmp 0x203335
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movl $0x3e1, %r15d           # imm = 0x3E1
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x203515
movl (%r12,%r14,4), %r13d
cmpq %rcx, %r13
je 0x2033ed
testl %r13d, %r13d
js 0x203410
cmpl $0x7f, %r13d
ja 0x20343f
movzbl 0x88(%r13,%rbp), %eax
testl %eax, %eax
je 0x2033b8
cmpl $0x1c, %eax
je 0x2033b8
cmpq %r13, %r14
jne 0x20359e
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 0x203509
movb $0x1, 0x88(%rbx,%r14)
orw $-0x1, 0x1e0(%rbx,%r14,2)
movw $0x1, 0x3e0(%rbx,%r14,4)
jmp 0x203509
cmpl $-0x4, %r13d
jb 0x20359e
movb $0x3, %al
subb %r13b, %al
movb %al, 0x88(%rbx,%r14)
movb $0x0, 0x3e0(%rbx,%r14,4)
andw $0x0, 0x1e0(%rbx,%r14,2)
jmp 0x203509
movl %r13d, %edi
callq 0x2035b2
testl %eax, %eax
js 0x20349c
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x20359e
movl %r13d, %edx
shrl $0x8, %edx
leaq 0x16a4bb(%rip), %rax    # 0x36d920
movzbl (%rdx,%rax), %ecx
movl %r13d, %eax
shrl $0x5, %eax
andl $0x7, %eax
shll $0x5, %ecx
leal (%rcx,%rax,4), %ecx
leaq 0x169fa1(%rip), %r8     # 0x36d420
movl (%rcx,%r8), %edi
pushq $0x1
popq %rsi
movl %r13d, %ecx
shll %cl, %esi
btl %r13d, %edi
jae 0x2034bc
movb $0x16, 0x88(%rbx,%r14)
jmp 0x2034e7
movb $0x0, 0x88(%rbx,%r14)
orw $-0x1, 0x1e0(%rbx,%r14,2)
movw $0x1, 0x3e0(%rbx,%r14,4)
jmp 0x203504
leaq 0x16a55d(%rip), %rcx    # 0x36da20
movzbl (%rdx,%rcx), %ecx
shll $0x5, %ecx
leal (%rcx,%rax,4), %eax
testl %esi, (%rax,%r8)
je 0x2034de
movb $0x1a, 0x88(%rbx,%r14)
jmp 0x2034e7
movb $0x1c, 0x88(%rbx,%r14)
leaq (%rbx,%r15), %rsi
movl %r13d, %edi
callq 0x20321c
movb %al, 0x3e0(%rbx,%r14,4)
movw %r13w, 0x1e0(%rbx,%r14,2)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
incq %r14
addq $0x4, %r15
jmp 0x203378
movq 0x8(%rsp), %rax
movq %rax, 0x1d8(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x1d0(%rbx)
testq %rax, %rax
je 0x203586
leaq 0xbf(%rip), %rax        # 0x2035f8
movq %rax, 0x188(%rbx)
movq %rax, 0x190(%rbx)
movq %rax, 0x198(%rbx)
leaq 0xef(%rip), %rax        # 0x203644
movq %rax, 0x1a0(%rbx)
movq %rax, 0x1a8(%rbx)
movq %rax, 0x1b0(%rbx)
leaq 0x11f(%rip), %rax       # 0x203690
movq %rax, 0x1b8(%rbx)
movq %rax, 0x1c0(%rbx)
movq %rax, 0x1c8(%rbx)
leaq 0x12c(%rip), %rax       # 0x2036b9
movq %rax, 0x70(%rbx)
leaq 0x1f1(%rip), %rax       # 0x203789
movq %rax, 0x78(%rbx)
jmp 0x2035a0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq