// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movl %edi, 0x3c(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x218, %edi            # imm = 0x218
movl $0x2, %esi
callq 0x22aa70
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movl 0x3c(%rsp), %eax
shlq %rax
addq %rax, %rdi
movl $0x2, %esi
callq 0x22aa70
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movl 0x3c(%rsp), %eax
shlq %rax
addq %rax, %rdi
movl $0x1, %esi
leaq 0x34b606(%rip), %rdx    # 0x575e7e
movl $0x31, %ecx
callq 0xe83c0
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x22a9e6
movq 0x20(%rsp), %rcx
addq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rcx
addq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movl 0x3c(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
movl $0xff, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x19360
movq 0x20(%rsp), %rdi
addq $0x118, %rdi            # imm = 0x118
movl $0xff, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x19360
movq 0x30(%rsp), %rax
movw (%rax), %cx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movw %cx, (%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movw %cx, (%rax)
movl $0x1, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jae 0x22a98d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl 0xc(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %eax
movq 0x30(%rsp), %rcx
movl 0xc(%rsp), %edx
movw (%rcx,%rdx,2), %cx
movq 0x20(%rsp), %rdx
movq 0x10(%rdx), %rdx
movl 0xc(%rsp), %esi
movw %cx, (%rdx,%rsi,2)
movzwl %cx, %ecx
addl %ecx, %eax
movw %ax, %dx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl 0xc(%rsp), %ecx
movw %dx, (%rax,%rcx,2)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x22a929
movl $0x0, 0xc(%rsp)
cmpl $0xff, 0xc(%rsp)
ja 0x22a9e4
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movb (%rax,%rcx), %dl
movq 0x20(%rsp), %rax
movl 0xc(%rsp), %ecx
movb %dl, 0x18(%rax,%rcx)
movl 0xc(%rsp), %eax
movb %al, %dl
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movl 0xc(%rsp), %esi
movzbl (%rcx,%rsi), %ecx
movb %dl, 0x118(%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x22a995
jmp 0x22aa5b
cmpq $0x0, 0x20(%rsp)
je 0x22aa50
movq 0x20(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x22aa14
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x34b474(%rip), %rsi    # 0x575e7e
movl $0x4e, %edx
callq 0xe88c0
movq 0x20(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x22aa3a
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x34b44e(%rip), %rsi    # 0x575e7e
movl $0x50, %edx
callq 0xe88c0
movq 0x20(%rsp), %rdi
leaq 0x34b438(%rip), %rsi    # 0x575e7e
movl $0x51, %edx
callq 0xe88c0
movq $0x0, 0x40(%rsp)
jmp 0x22aa65
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nop