// File: /workspace/github_c_makefile_star2_O1/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 0xc16d9
movq %rdi, %rbx
movq 0x398(%rdi), %rdi
callq 0x3d9b7
movq 0x390(%rbx), %rax
testq %rax, %rax
je 0xc16e5
decq %rax
movq %rax, 0x390(%rbx)
movq 0x398(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3d9d2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq $0x0, 0x10(%rbx)
je 0xc1739
movq 0x2a0(%rbx), %r14
testq %r14, %r14
je 0xc172b
xorl %r12d, %r12d
movq %r12, (%r14)
leaq 0x446d8(%rip), %r15     # 0x105ddd
xorl %edi, %edi
movq %r15, %rsi
movl $0x5d, %edx
callq 0x362a0
movq %r14, %rdi
movq %r15, %rsi
movl $0x5e, %edx
callq 0x362a0
movq %r12, 0x2a0(%rbx)
movq 0x10(%rbx), %rdi
callq 0x74bae
jmp 0xc1976
movq 0xf8(%rbx), %rdi
leaq 0x412e3(%rip), %rsi     # 0x102a2a
movl $0x7a5, %edx            # imm = 0x7A5
callq 0x362a0
movl (%rbx), %eax
cmpq $0x6, %rax
ja 0xc1907
leaq 0x4107c(%rip), %rcx     # 0x1027e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x298(%rbx)
jne 0xc1907
movq 0x290(%rbx), %rdi
leaq 0x412a2(%rip), %rsi     # 0x102a2a
movl $0x7a9, %edx            # imm = 0x7A9
jmp 0xc1902
movq 0x280(%rbx), %rdi
leaq 0x4128a(%rip), %r14     # 0x102a2a
movq %r14, %rsi
movl $0x7b8, %edx            # imm = 0x7B8
callq 0x362a0
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7b9, %edx            # imm = 0x7B9
callq 0x362a0
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7ba, %edx            # imm = 0x7BA
callq 0x362a0
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7bb, %edx            # imm = 0x7BB
jmp 0xc1902
movq 0x280(%rbx), %rdi
leaq 0x41233(%rip), %rsi     # 0x102a2a
movl $0x7b0, %edx            # imm = 0x7B0
jmp 0xc1902
movq 0x280(%rbx), %rdi
leaq 0x4121b(%rip), %r14     # 0x102a2a
movq %r14, %rsi
movl $0x7b3, %edx            # imm = 0x7B3
callq 0x362a0
movq 0x2b0(%rbx), %rdi
movq %r14, %rsi
movl $0x7b4, %edx            # imm = 0x7B4
callq 0x362a0
movq $0x0, 0x2b0(%rbx)
jmp 0xc1907
movq 0x2a0(%rbx), %rdi
callq 0xc1c05
movq $0x0, 0x2a0(%rbx)
jmp 0xc1907
movq 0x280(%rbx), %rdi
leaq 0x411c0(%rip), %r14     # 0x102a2a
movq %r14, %rsi
movl $0x7be, %edx            # imm = 0x7BE
callq 0x362a0
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7bf, %edx            # imm = 0x7BF
callq 0x362a0
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c0, %edx            # imm = 0x7C0
callq 0x362a0
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c1, %edx            # imm = 0x7C1
jmp 0xc1902
movq 0x280(%rbx), %rdi
leaq 0x4116c(%rip), %r14     # 0x102a2a
movq %r14, %rsi
movl $0x7c4, %edx            # imm = 0x7C4
callq 0x362a0
movq 0x2b8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c5, %edx            # imm = 0x7C5
callq 0x362a0
movq 0x2c8(%rbx), %rdi
movq %r14, %rsi
movl $0x7c6, %edx            # imm = 0x7C6
callq 0x362a0
movq 0x2c0(%rbx), %rdi
movq %r14, %rsi
movl $0x7c7, %edx            # imm = 0x7C7
callq 0x362a0
cmpb $0x1, 0x2f0(%rbx)
jne 0xc1967
movq 0x2f8(%rbx), %rdi
leaq 0x4110c(%rip), %r14     # 0x102a2a
movq %r14, %rsi
movl $0x7cc, %edx            # imm = 0x7CC
callq 0x362a0
movq 0x308(%rbx), %rdi
movq %r14, %rsi
movl $0x7cd, %edx            # imm = 0x7CD
callq 0x362a0
movq 0x310(%rbx), %rdi
movq %r14, %rsi
movl $0x7ce, %edx            # imm = 0x7CE
callq 0x362a0
movq 0x300(%rbx), %rdi
movq %r14, %rsi
movl $0x7cf, %edx            # imm = 0x7CF
callq 0x362a0
movl 0x4(%rbx), %edi
leaq 0x240(%rbx), %rsi
callq 0xc1c40
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xc1984
callq 0x74bae
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0xc1992
callq 0x74bae
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 0xc19cb
xorps %xmm0, %xmm0
movups %xmm0, 0x2c8(%rbx)
movups %xmm0, 0x2b8(%rbx)
movl 0x4(%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0xc19e7
xorps %xmm0, %xmm0
movups %xmm0, 0x250(%rbx)
movups %xmm0, 0x240(%rbx)
movq 0x200(%rbx), %rdi
testq %rdi, %rdi
je 0xc1a1f
cmpb $0x1, 0x208(%rbx)
jne 0xc1a0f
leaq 0x41027(%rip), %rsi     # 0x102a2a
movl $0x7df, %edx            # imm = 0x7DF
callq 0x362a0
jmp 0xc1a14
callq 0x74bae
movq $0x0, 0x200(%rbx)
movq 0x218(%rbx), %rdi
testq %rdi, %rdi
je 0xc1a57
cmpb $0x1, 0x20a(%rbx)
jne 0xc1a47
leaq 0x40fef(%rip), %rsi     # 0x102a2a
movl $0x7e6, %edx            # imm = 0x7E6
callq 0x362a0
jmp 0xc1a4c
callq 0x74bae
movq $0x0, 0x218(%rbx)
movq 0x278(%rbx), %rdi
testq %rdi, %rdi
je 0xc1a7f
leaq 0x40fc0(%rip), %rsi     # 0x102a2a
movl $0x7ec, %edx            # imm = 0x7EC
callq 0x362a0
movq $0x0, 0x278(%rbx)
movq 0x330(%rbx), %r14
testq %r14, %r14
je 0xc1acb
cmpq $0x0, 0x20(%rbx)
je 0xc1a99
movq $0x0, (%r14)
movq (%r14), %rdi
leaq 0x4433a(%rip), %r15     # 0x105ddd
movq %r15, %rsi
movl $0x5d, %edx
callq 0x362a0
movq %r14, %rdi
movq %r15, %rsi
movl $0x5e, %edx
callq 0x362a0
movq $0x0, 0x330(%rbx)
movq 0x220(%rbx), %rdi
callq 0xb9301
movq 0x1f8(%rbx), %rdi
callq 0x3d573
movq $0x0, 0x1f8(%rbx)
movq 0x228(%rbx), %rdi
testq %rdi, %rdi
je 0xc1b0b
leaq 0x40f29(%rip), %rsi     # 0x102a2a
movl $0x7f9, %edx            # imm = 0x7F9
callq 0x362a0
cmpq $0x0, 0x10(%rbx)
jne 0xc1b2a
movq 0xf0(%rbx), %rdi
leaq 0x40f0a(%rip), %rsi     # 0x102a2a
movl $0x7fb, %edx            # imm = 0x7FB
callq 0x362a0
movq $0x0, 0xf0(%rbx)
movq 0x3a0(%rbx), %rdi
testq %rdi, %rdi
je 0xc1b46
callq 0xd757b
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xc1b60
leaq 0x40ed4(%rip), %rsi     # 0x102a2a
movl $0x800, %edx            # imm = 0x800
callq 0x362a0
movq 0x398(%rbx), %rdi
callq 0x3d9d2
movq 0x398(%rbx), %rdi
callq 0x3d995
leaq 0x40eab(%rip), %rsi     # 0x102a2a
movq %rbx, %rdi
movl $0x803, %edx            # imm = 0x803
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x362a0