// File: /workspace/github_c_makefile_star2_O1/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 0x26444a(%rip), %rbp    # 0x4c0a00
movb (%rax,%rbp), %sil
movb %sil, (%rbx,%rax)
incq %rax
cmpq $0x1d0, %rax            # imm = 0x1D0
jne 0x25c5b6
xorl %eax, %eax
movzbl 0x88(%rax,%rbp), %esi
testl %esi, %esi
je 0x25c5e9
cmpl $0x1c, %esi
je 0x25c5e9
movl (%r12,%rax,4), %esi
cmpq %rsi, %rax
jne 0x25c82c
incq %rax
cmpq $0x80, %rax
jne 0x25c5cb
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 0x25c674
testl %r13d, %r13d
js 0x25c698
cmpl $0x7f, %r13d
jg 0x25c6c8
movzbl 0x88(%r13,%rbp), %eax
testl %eax, %eax
je 0x25c63f
cmpl $0x1c, %eax
je 0x25c63f
cmpq %r13, %r14
jne 0x25c82c
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 0x25c78f
movb $0x1, 0x88(%rbx,%r14)
movw $0xffff, 0x1e0(%rbx,%r14,2) # imm = 0xFFFF
movw $0x1, 0x3e0(%rbx,%r14,4)
jmp 0x25c78f
cmpl $-0x4, %r13d
jl 0x25c82c
movb $0x3, %al
subb %r13b, %al
movb %al, 0x88(%rbx,%r14)
movb $0x0, 0x3e0(%rbx,%r14,4)
movw $0x0, 0x1e0(%rbx,%r14,2)
jmp 0x25c78f
movl %r13d, %edi
callq 0x25c840
testl %eax, %eax
js 0x25c76b
cmpl $0xffff, %r13d          # imm = 0xFFFF
jg 0x25c82c
movl %r13d, %edx
shrl $0x8, %edx
leaq 0x17a55e(%rip), %rax    # 0x3d6c50
movzbl (%rdx,%rax), %edi
movl %r13d, %eax
shrl $0x5, %eax
andl $0x7, %eax
shll $0x5, %edi
movl $0x1, %esi
movl %r13d, %ecx
shll %cl, %esi
leal (%rdi,%rax,4), %ecx
leaq 0x17a03a(%rip), %rdi    # 0x3d6750
movl (%rcx,%rdi), %edi
movb $0x16, %cl
btl %r13d, %edi
jb 0x25c744
leaq 0x17a628(%rip), %rcx    # 0x3d6d50
movzbl (%rdx,%rcx), %ecx
shll $0x5, %ecx
leal (%rcx,%rax,4), %eax
leaq 0x17a017(%rip), %rcx    # 0x3d6750
testl %esi, (%rax,%rcx)
sete %cl
addb %cl, %cl
addb $0x1a, %cl
movb %cl, 0x88(%rbx,%r14)
leaq (%rbx,%r15), %rsi
movl %r13d, %edi
callq 0x25c4a8
movb %al, 0x3e0(%rbx,%r14,4)
movw %r13w, 0x1e0(%rbx,%r14,2)
jmp 0x25c78a
movb $0x0, 0x88(%rbx,%r14)
movw $0xffff, 0x1e0(%rbx,%r14,2) # imm = 0xFFFF
movw $0x1, 0x3e0(%rbx,%r14,4)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
incq %r14
addq $0x4, %r15
cmpq $0x100, %r14            # imm = 0x100
jne 0x25c60c
movq 0x8(%rsp), %rax
movq %rax, 0x1d8(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x1d0(%rbx)
testq %rax, %rax
je 0x25c814
leaq 0xc1(%rip), %rax        # 0x25c888
movq %rax, 0x188(%rbx)
movq %rax, 0x190(%rbx)
movq %rax, 0x198(%rbx)
leaq 0xf3(%rip), %rax        # 0x25c8d6
movq %rax, 0x1a0(%rbx)
movq %rax, 0x1a8(%rbx)
movq %rax, 0x1b0(%rbx)
leaq 0x125(%rip), %rax       # 0x25c924
movq %rax, 0x1b8(%rbx)
movq %rax, 0x1c0(%rbx)
movq %rax, 0x1c8(%rbx)
leaq 0x133(%rip), %rax       # 0x25c94e
movq %rax, 0x70(%rbx)
leaq 0x220(%rip), %rax       # 0x25ca46
movq %rax, 0x78(%rbx)
jmp 0x25c82e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq