// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/encseq.c
// Function: gt_encseq_delete
void gt_encseq_delete(GtEncseq *encseq)
{
  if (encseq == NULL)
    return;
  gt_mutex_lock(encseq->refcount_lock);
  if (encseq->reference_count) {
    encseq->reference_count--;
    gt_mutex_unlock(encseq->refcount_lock);
    return;
  }
  if (encseq->mappedptr != NULL) {
    if (encseq->bitpackarray != NULL) {
      /* store points to some subarea of the region mapped by mappedptr:
         therefore we have to set it to NULL to prevent that it is freed */
      BITPACKARRAYSTOREVAR(encseq->bitpackarray) = NULL;
      bitpackarray_delete(encseq->bitpackarray);
      encseq->bitpackarray = NULL;
    }
    gt_fa_xmunmap(encseq->mappedptr);
  }
  else {
    gt_free(encseq->headerptr.characterdistribution);
    switch (encseq->sat) {
      case  GT_ACCESS_TYPE_DIRECTACCESS:
        if (!encseq->hasplainseqptr)
          gt_free(encseq->plainseq);
        break;
      case GT_ACCESS_TYPE_BYTECOMPRESS:
        bitpackarray_delete(encseq->bitpackarray);
        encseq->bitpackarray = NULL;
        break;
      case GT_ACCESS_TYPE_EQUALLENGTH:
        gt_free(encseq->twobitencoding);
        break;
      case GT_ACCESS_TYPE_BITACCESS:
        gt_free(encseq->twobitencoding);
        gt_free(encseq->specialbits);
        encseq->specialbits = NULL;
        break;
      case GT_ACCESS_TYPE_UCHARTABLES:
        gt_free(encseq->twobitencoding);
        gt_free(encseq->wildcardrangetable.st_uchar.positions);
        gt_free(encseq->wildcardrangetable.st_uchar.endidxinpage);
        gt_free(encseq->wildcardrangetable.st_uchar.rangelengths);
        break;
      case GT_ACCESS_TYPE_USHORTTABLES:
        gt_free(encseq->twobitencoding);
        gt_free(encseq->wildcardrangetable.st_uint16.positions);
        gt_free(encseq->wildcardrangetable.st_uint16.endidxinpage);
        gt_free(encseq->wildcardrangetable.st_uint16.rangelengths);
        break;
      case GT_ACCESS_TYPE_UINT32TABLES:
        gt_free(encseq->twobitencoding);
        gt_free(encseq->wildcardrangetable.st_uint32.positions);
        gt_free(encseq->wildcardrangetable.st_uint32.endidxinpage);
        gt_free(encseq->wildcardrangetable.st_uint32.rangelengths);
        break;
      default: break;
    }
    if (encseq->has_exceptiontable) {
      gt_free(encseq->exceptiontable.st_uint32.positions);
      gt_free(encseq->exceptiontable.st_uint32.endidxinpage);
      gt_free(encseq->exceptiontable.st_uint32.mappositions);
      gt_free(encseq->exceptiontable.st_uint32.rangelengths);
    }
    gt_ssptab_delete(encseq->satsep, &encseq->ssptab);
  }
  if (encseq->ssptabmappedptr != NULL)
    gt_fa_xmunmap(encseq->ssptabmappedptr);
  if (encseq->oistabmappedptr != NULL)
    gt_fa_xmunmap(encseq->oistabmappedptr);
  encseq->headerptr.characterdistribution = NULL;
  encseq->plainseq = NULL;
  encseq->specialbits = NULL;
  encseq->twobitencoding = NULL;
  setencsequtablesNULL(encseq->sat, &encseq->wildcardrangetable);
  setencsequtablesNULL(encseq->satsep, &encseq->ssptab);
  if (encseq->destab != NULL) {
    if (encseq->hasallocateddestab)
      gt_free(encseq->destab);
    else
      gt_fa_xmunmap((void *) encseq->destab);
    encseq->destab = NULL;
  }
  if (encseq->sdstab != NULL) {
    if (encseq->hasallocatedsdstab)
      gt_free(encseq->sdstab);
    else
      gt_fa_xmunmap((void *) encseq->sdstab);
    encseq->sdstab = NULL;
  }
  if (encseq->fsptab != NULL) {
    gt_free(encseq->fsptab);
    encseq->fsptab = NULL;
  }
  if (encseq->exceptions != NULL) {
    if (encseq->oistabmappedptr != NULL)
      BITPACKARRAYSTOREVAR(encseq->exceptions) = NULL;
    bitpackarray_delete(encseq->exceptions);
    encseq->exceptions = NULL;
  }
  gt_alphabet_delete((GtAlphabet*) encseq->alpha);
  gt_str_array_delete(encseq->filenametab);
  encseq->filenametab = NULL;
  if (encseq->alphadef != NULL)
    gt_free(encseq->alphadef);
  if (encseq->mappedptr == NULL)
    gt_free(encseq->headerptr.filelengthtab);
  encseq->headerptr.filelengthtab = NULL;
  if (encseq->md5_tab != NULL)
    gt_md5_tab_delete(encseq->md5_tab);
  if (encseq->indexname != NULL)
    gt_free(encseq->indexname);
  gt_mutex_unlock(encseq->refcount_lock);
  gt_mutex_delete(encseq->refcount_lock);
  gt_free(encseq);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xc2786
movq %rdi, %rbx
movq 0x398(%rdi), %rdi
callq 0x3d043
movq 0x390(%rbx), %rax
testq %rax, %rax
je 0xc2792
decq %rax
movq %rax, 0x390(%rbx)
movq 0x398(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3d05e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0xc27e8
movq 0x2a0(%rbx), %r14
testq %r14, %r14
je 0xc27de
xorl %r12d, %r12d
movq %r12, (%r14)
leaq 0x434c4(%rip), %r15     # 0x105c78
xorl %edi, %edi
movq %r15, %rsi
movl $0x5d, %edx
callq 0x35c27
movq %r14, %rdi
movq %r15, %rsi
movl $0x5e, %edx
callq 0x35c27
movq %r12, 0x2a0(%rbx)
movq 0x10(%rbx), %rdi
callq 0x750ec
jmp 0xc2a25
movq 0xf8(%rbx), %rdi
leaq 0x40124(%rip), %rsi     # 0x10291a
movl $0x7a5, %edx            # imm = 0x7A5
callq 0x35c27
movl (%rbx), %eax
cmpq $0x6, %rax
ja 0xc29b6
leaq 0x3ff3d(%rip), %rcx     # 0x102750
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x298(%rbx)
jne 0xc29b6
movq 0x290(%rbx), %rdi
leaq 0x400e3(%rip), %rsi     # 0x10291a
movl $0x7a9, %edx            # imm = 0x7A9
jmp 0xc29b1
movq 0x280(%rbx), %rdi
leaq 0x400cb(%rip), %r14     # 0x10291a
movq %r14, %rsi
movl $0x7b8, %edx            # imm = 0x7B8
callq 0x35c27
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7b9, %edx            # imm = 0x7B9
callq 0x35c27
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7ba, %edx            # imm = 0x7BA
callq 0x35c27
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7bb, %edx            # imm = 0x7BB
jmp 0xc29b1
movq 0x280(%rbx), %rdi
leaq 0x40074(%rip), %rsi     # 0x10291a
movl $0x7b0, %edx            # imm = 0x7B0
jmp 0xc29b1
movq 0x280(%rbx), %rdi
leaq 0x4005c(%rip), %r14     # 0x10291a
movq %r14, %rsi
movl $0x7b3, %edx            # imm = 0x7B3
callq 0x35c27
movq 0x2b0(%rbx), %rdi
movq %r14, %rsi
movl $0x7b4, %edx            # imm = 0x7B4
callq 0x35c27
movq $0x0, 0x2b0(%rbx)
jmp 0xc29b6
movq 0x2a0(%rbx), %rdi
callq 0xc2cb8
movq $0x0, 0x2a0(%rbx)
jmp 0xc29b6
movq 0x280(%rbx), %rdi
leaq 0x40001(%rip), %r14     # 0x10291a
movq %r14, %rsi
movl $0x7be, %edx            # imm = 0x7BE
callq 0x35c27
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7bf, %edx            # imm = 0x7BF
callq 0x35c27
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c0, %edx            # imm = 0x7C0
callq 0x35c27
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c1, %edx            # imm = 0x7C1
jmp 0xc29b1
movq 0x280(%rbx), %rdi
leaq 0x3ffad(%rip), %r14     # 0x10291a
movq %r14, %rsi
movl $0x7c4, %edx            # imm = 0x7C4
callq 0x35c27
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c5, %edx            # imm = 0x7C5
callq 0x35c27
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c6, %edx            # imm = 0x7C6
callq 0x35c27
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c7, %edx            # imm = 0x7C7
callq 0x35c27
cmpb $0x1, 0x2f0(%rbx)
jne 0xc2a16
movq 0x2f8(%rbx), %rdi
leaq 0x3ff4d(%rip), %r14     # 0x10291a
movq %r14, %rsi
movl $0x7cc, %edx            # imm = 0x7CC
callq 0x35c27
movq 0x308(%rbx), %rdi
movq %r14, %rsi
movl $0x7cd, %edx            # imm = 0x7CD
callq 0x35c27
movq 0x310(%rbx), %rdi
movq %r14, %rsi
movl $0x7ce, %edx            # imm = 0x7CE
callq 0x35c27
movq 0x300(%rbx), %rdi
movq %r14, %rsi
movl $0x7cf, %edx            # imm = 0x7CF
callq 0x35c27
movl 0x4(%rbx), %edi
leaq 0x240(%rbx), %rsi
callq 0xc2cf3
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xc2a33
callq 0x750ec
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0xc2a41
callq 0x750ec
xorl %eax, %eax
movq %rax, 0xf8(%rbx)
movq %rax, 0x290(%rbx)
movq %rax, 0x2b0(%rbx)
movq %rax, 0x280(%rbx)
movl (%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0xc2a7a
xorps %xmm0, %xmm0
movups %xmm0, 0x2c8(%rbx)
movups %xmm0, 0x2b8(%rbx)
movl 0x4(%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0xc2a96
xorps %xmm0, %xmm0
movups %xmm0, 0x250(%rbx)
movups %xmm0, 0x240(%rbx)
movq 0x200(%rbx), %rdi
testq %rdi, %rdi
je 0xc2ace
cmpb $0x1, 0x208(%rbx)
jne 0xc2abe
leaq 0x3fe68(%rip), %rsi     # 0x10291a
movl $0x7df, %edx            # imm = 0x7DF
callq 0x35c27
jmp 0xc2ac3
callq 0x750ec
movq $0x0, 0x200(%rbx)
movq 0x218(%rbx), %rdi
testq %rdi, %rdi
je 0xc2b06
cmpb $0x1, 0x20a(%rbx)
jne 0xc2af6
leaq 0x3fe30(%rip), %rsi     # 0x10291a
movl $0x7e6, %edx            # imm = 0x7E6
callq 0x35c27
jmp 0xc2afb
callq 0x750ec
movq $0x0, 0x218(%rbx)
movq 0x278(%rbx), %rdi
testq %rdi, %rdi
je 0xc2b2e
leaq 0x3fe01(%rip), %rsi     # 0x10291a
movl $0x7ec, %edx            # imm = 0x7EC
callq 0x35c27
movq $0x0, 0x278(%rbx)
movq 0x330(%rbx), %r14
testq %r14, %r14
je 0xc2b7e
cmpq $0x0, 0x20(%rbx)
je 0xc2b4c
movq $0x0, (%r14)
xorl %edi, %edi
jmp 0xc2b4f
movq (%r14), %rdi
leaq 0x43122(%rip), %r15     # 0x105c78
movq %r15, %rsi
movl $0x5d, %edx
callq 0x35c27
movq %r14, %rdi
movq %r15, %rsi
movl $0x5e, %edx
callq 0x35c27
movq $0x0, 0x330(%rbx)
movq 0x220(%rbx), %rdi
callq 0xba400
movq 0x1f8(%rbx), %rdi
callq 0x3cc00
movq $0x0, 0x1f8(%rbx)
movq 0x228(%rbx), %rdi
testq %rdi, %rdi
je 0xc2bbe
leaq 0x3fd66(%rip), %rsi     # 0x10291a
movl $0x7f9, %edx            # imm = 0x7F9
callq 0x35c27
cmpq $0x0, 0x10(%rbx)
jne 0xc2bdd
movq 0xf0(%rbx), %rdi
leaq 0x3fd47(%rip), %rsi     # 0x10291a
movl $0x7fb, %edx            # imm = 0x7FB
callq 0x35c27
movq $0x0, 0xf0(%rbx)
movq 0x3a0(%rbx), %rdi
testq %rdi, %rdi
je 0xc2bf9
callq 0xd7c78
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xc2c13
leaq 0x3fd11(%rip), %rsi     # 0x10291a
movl $0x800, %edx            # imm = 0x800
callq 0x35c27
movq 0x398(%rbx), %rdi
callq 0x3d05e
movq 0x398(%rbx), %rdi
callq 0x3d021
leaq 0x3fce8(%rip), %rsi     # 0x10291a
movq %rbx, %rdi
movl $0x803, %edx            # imm = 0x803
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x35c27