// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xa502a
movq %rdi, %rbx
movq 0x398(%rdi), %rdi
callq 0x16028
movq 0x390(%rbx), %rax
testq %rax, %rax
je 0xa5032
decq %rax
movq %rax, 0x390(%rbx)
movq 0x398(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1609f
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0xa5069
movq 0x2a0(%rbx), %rax
testq %rax, %rax
je 0xa505f
andq $0x0, (%rax)
movq %rax, %rdi
callq 0xa5527
andq $0x0, 0x2a0(%rbx)
movq 0x10(%rbx), %rdi
callq 0x530de
jmp 0xa52a0
movq 0xf8(%rbx), %rdi
leaq 0x46b23(%rip), %rsi     # 0xebb9a
movl $0x7a5, %edx            # imm = 0x7A5
callq 0xd249
movl (%rbx), %eax
cmpq $0x6, %rax
ja 0xa5231
leaq 0x4693c(%rip), %rcx     # 0xeb9d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x298(%rbx)
jne 0xa5231
movq 0x290(%rbx), %rdi
leaq 0x46ae2(%rip), %rsi     # 0xebb9a
movl $0x7a9, %edx            # imm = 0x7A9
jmp 0xa522c
movq 0x280(%rbx), %rdi
leaq 0x46aca(%rip), %r14     # 0xebb9a
movq %r14, %rsi
movl $0x7b8, %edx            # imm = 0x7B8
callq 0xd249
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7b9, %edx            # imm = 0x7B9
callq 0xd249
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7ba, %edx            # imm = 0x7BA
callq 0xd249
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7bb, %edx            # imm = 0x7BB
jmp 0xa522c
movq 0x280(%rbx), %rdi
leaq 0x46a73(%rip), %rsi     # 0xebb9a
movl $0x7b0, %edx            # imm = 0x7B0
jmp 0xa522c
movq 0x280(%rbx), %rdi
leaq 0x46a5b(%rip), %r14     # 0xebb9a
movq %r14, %rsi
movl $0x7b3, %edx            # imm = 0x7B3
callq 0xd249
movq 0x2b0(%rbx), %rdi
movq %r14, %rsi
movl $0x7b4, %edx            # imm = 0x7B4
callq 0xd249
andq $0x0, 0x2b0(%rbx)
jmp 0xa5231
movq 0x2a0(%rbx), %rdi
callq 0xa5527
andq $0x0, 0x2a0(%rbx)
jmp 0xa5231
movq 0x280(%rbx), %rdi
leaq 0x46a06(%rip), %r14     # 0xebb9a
movq %r14, %rsi
movl $0x7be, %edx            # imm = 0x7BE
callq 0xd249
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7bf, %edx            # imm = 0x7BF
callq 0xd249
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c0, %edx            # imm = 0x7C0
callq 0xd249
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c1, %edx            # imm = 0x7C1
jmp 0xa522c
movq 0x280(%rbx), %rdi
leaq 0x469b2(%rip), %r14     # 0xebb9a
movq %r14, %rsi
movl $0x7c4, %edx            # imm = 0x7C4
callq 0xd249
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c5, %edx            # imm = 0x7C5
callq 0xd249
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c6, %edx            # imm = 0x7C6
callq 0xd249
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c7, %edx            # imm = 0x7C7
callq 0xd249
cmpb $0x1, 0x2f0(%rbx)
jne 0xa5291
movq 0x2f8(%rbx), %rdi
leaq 0x46952(%rip), %r14     # 0xebb9a
movq %r14, %rsi
movl $0x7cc, %edx            # imm = 0x7CC
callq 0xd249
movq 0x308(%rbx), %rdi
movq %r14, %rsi
movl $0x7cd, %edx            # imm = 0x7CD
callq 0xd249
movq 0x310(%rbx), %rdi
movq %r14, %rsi
movl $0x7ce, %edx            # imm = 0x7CE
callq 0xd249
movq 0x300(%rbx), %rdi
movq %r14, %rsi
movl $0x7cf, %edx            # imm = 0x7CF
callq 0xd249
movl 0x4(%rbx), %edi
leaq 0x240(%rbx), %rsi
callq 0xa555e
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xa52ae
callq 0x530de
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0xa52bc
callq 0x530de
andq $0x0, 0xf8(%rbx)
andq $0x0, 0x290(%rbx)
andq $0x0, 0x2b0(%rbx)
andq $0x0, 0x280(%rbx)
movl (%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0xa52f7
xorps %xmm0, %xmm0
movups %xmm0, 0x2c8(%rbx)
movups %xmm0, 0x2b8(%rbx)
movl 0x4(%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0xa5313
xorps %xmm0, %xmm0
movups %xmm0, 0x250(%rbx)
movups %xmm0, 0x240(%rbx)
movq 0x200(%rbx), %rdi
testq %rdi, %rdi
je 0xa5348
cmpb $0x1, 0x208(%rbx)
jne 0xa533b
leaq 0x4686b(%rip), %rsi     # 0xebb9a
movl $0x7df, %edx            # imm = 0x7DF
callq 0xd249
jmp 0xa5340
callq 0x530de
andq $0x0, 0x200(%rbx)
movq 0x218(%rbx), %rdi
testq %rdi, %rdi
je 0xa537d
cmpb $0x1, 0x20a(%rbx)
jne 0xa5370
leaq 0x46836(%rip), %rsi     # 0xebb9a
movl $0x7e6, %edx            # imm = 0x7E6
callq 0xd249
jmp 0xa5375
callq 0x530de
andq $0x0, 0x218(%rbx)
movq 0x278(%rbx), %rdi
testq %rdi, %rdi
je 0xa53a2
leaq 0x4680a(%rip), %rsi     # 0xebb9a
movl $0x7ec, %edx            # imm = 0x7EC
callq 0xd249
andq $0x0, 0x278(%rbx)
movq 0x330(%rbx), %rdi
testq %rdi, %rdi
je 0xa53c6
cmpq $0x0, 0x20(%rbx)
je 0xa53b9
andq $0x0, (%rdi)
callq 0xa5527
andq $0x0, 0x330(%rbx)
movq 0x220(%rbx), %rdi
callq 0x9b1c1
movq 0x1f8(%rbx), %rdi
callq 0x1583a
andq $0x0, 0x1f8(%rbx)
movq 0x228(%rbx), %rdi
testq %rdi, %rdi
je 0xa5403
leaq 0x467a1(%rip), %rsi     # 0xebb9a
movl $0x7f9, %edx            # imm = 0x7F9
callq 0xd249
cmpq $0x0, 0x10(%rbx)
jne 0xa5422
movq 0xf0(%rbx), %rdi
leaq 0x46782(%rip), %rsi     # 0xebb9a
movl $0x7fb, %edx            # imm = 0x7FB
callq 0xd249
andq $0x0, 0xf0(%rbx)
movq 0x3a0(%rbx), %rdi
testq %rdi, %rdi
je 0xa543b
callq 0xbf2f3
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xa5455
leaq 0x4674f(%rip), %rsi     # 0xebb9a
movl $0x800, %edx            # imm = 0x800
callq 0xd249
movq 0x398(%rbx), %rdi
callq 0x1609f
movq 0x398(%rbx), %rdi
callq 0x15fd3
leaq 0x46726(%rip), %rsi     # 0xebb9a
movq %rbx, %rdi
movl $0x803, %edx            # imm = 0x803
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xd249