// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/eis-mrangealphabet.c
// Function: gt_newMultiRangeAlphabetEncodingUInt8
MRAEnc *
gt_newMultiRangeAlphabetEncodingUInt8(AlphabetRangeID numRanges,
                                   const AlphabetRangeSize symbolsPerRange[],
                                   const uint8_t *mappings)
{
  MRAEncUInt8 *newAlpha = NULL;
  size_t rEIOffset = offsetAlign(
    sizeof (MRAEncUInt8),
    sizeof (newAlpha->baseClass.rangeEndIndices[0]));
  size_t sPROffset = offsetAlign(
    rEIOffset  +  sizeof (newAlpha->baseClass.rangeEndIndices[0]) * numRanges,
    sizeof (newAlpha->baseClass.symbolsPerRange[0]));
  AlphabetRangeID i;
  if ((newAlpha = gt_calloc(
         sPROffset
         + sizeof (newAlpha->baseClass.symbolsPerRange[0]) * numRanges,
         1)))
  {
    newAlpha->baseClass.rangeEndIndices
      = (AlphabetRangeSize *)((char *)newAlpha + rEIOffset);
    newAlpha->baseClass.symbolsPerRange
      = (AlphabetRangeSize *)((char *)newAlpha + sPROffset);
    newAlpha->baseClass.encType = sourceUInt8;
    newAlpha->baseClass.numRanges = numRanges;
    memset(newAlpha->mappings, UNDEF_UCHAR, UINT8_MAX+1);
    memset(newAlpha->revMappings, UNDEF_UCHAR, UINT8_MAX+1);
    newAlpha->baseClass.rangeEndIndices[0] =
      newAlpha->baseClass.symbolsPerRange[0] = symbolsPerRange[0];
    for (i = 1; i < numRanges; ++i)
    {
      newAlpha->baseClass.rangeEndIndices[i] =
        newAlpha->baseClass.rangeEndIndices[i-1]
        + (newAlpha->baseClass.symbolsPerRange[i] = symbolsPerRange[i]);
    }
    for (i = 0; i <= UINT8_MAX; ++i)
    {
      newAlpha->mappings[i] = mappings[i];
      newAlpha->revMappings[mappings[i]] = i;
    }
  }
  else
  {
    if (newAlpha)
    {
      if (newAlpha->baseClass.symbolsPerRange)
        gt_free(newAlpha->baseClass.symbolsPerRange);
      if (newAlpha->baseClass.rangeEndIndices)
        gt_free(newAlpha->baseClass.rangeEndIndices);
      gt_free(newAlpha);
    }
    return NULL;
  }
  return &(newAlpha->baseClass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %ebp
movl %edi, %r12d
leaq 0x218(,%r12,2), %rax
andq $-0x4, %rax
movl %edi, %ecx
andl $0x1, %ecx
leaq (%rax,%rcx,4), %r13
leaq (,%r12,2), %rdi
addq %r13, %rdi
leaq 0x206d4f(%rip), %rdx    # 0x3acd08
movl $0x1, %esi
movl $0x31, %ecx
callq 0x1093ef
testq %rax, %rax
je 0x1a6067
movq %rax, %r14
addq $0x218, %rax            # imm = 0x218
movq %rax, 0x8(%r14)
leaq (%r14,%r13), %rax
movq %rax, 0x10(%r14)
movl $0x1, (%r14)
movl %ebp, 0x4(%r14)
movq %r14, %rdi
addq $0x18, %rdi
movl $0x200, %edx            # imm = 0x200
movl $0xff, %esi
callq 0x173a0
movzwl (%r15), %eax
movw %ax, (%r14,%r13)
movw %ax, 0x218(%r14)
cmpl $0x2, %ebp
jb 0x1a6044
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
movzwl (%rax), %edx
movl $0x1, %esi
movzwl (%r15,%rsi,2), %edi
movw %di, (%rcx,%rsi,2)
addl %edi, %edx
movw %dx, (%rax,%rsi,2)
incq %rsi
cmpq %rsi, %r12
jne 0x1a602d
xorl %eax, %eax
movb (%rbx,%rax), %cl
movb %cl, 0x18(%r14,%rax)
movzbl (%rbx,%rax), %ecx
movb %al, 0x118(%r14,%rcx)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x1a6046
jmp 0x1a606a
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq