// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/reads2twobit.c
// Function: gt_reads2twobit_finalize_encode
static void gt_reads2twobit_finalize_encode(GtReads2Twobit *r2t,
    GtReads2TwobitEncodeState *state)
{
  unsigned int i;
  r2t->nofseqs = state->current.nofseqs;
  r2t->current_sepcode = GT_READS2TWOBIT_DEFAULT_SEPARATOR;
  r2t->invalid_sequences = state->invalid_sequences;
  r2t->invalid_total_length = state->invalid_total_length;
  for (i = 0; i < GT_READS2TWOBIT_ALPHASIZE; i++)
    r2t->chardistri[i] = state->current.chardistri[i];
  if (state->varlen_mode)
  {
    state->seppos = gt_realloc(state->seppos, sizeof (state->seppos) *
        (state->current.nofseqs));
    r2t->seqlen_eqlen = 0;
    r2t->seqlen_max = state->current.seqlen_max;
    r2t->seqlen_min = state->current.seqlen_min;
    r2t->total_seqlength = state->seppos[state->current.nofseqs - 1UL];
    r2t->seppos = state->seppos;
  }
  else
  {
    r2t->seqlen_eqlen = state->current.seqlen_first;
    r2t->seqlen_max = state->current.seqlen_first;
    r2t->seqlen_min = state->current.seqlen_first;
    if (state->current.seqlen_first > 0)
      r2t->total_seqlength = state->current.seqlen_first *
        state->current.nofseqs - 1UL;
    else
      r2t->total_seqlength = 0;
    gt_assert(state->seppos == NULL);
  }
  if (r2t->use_rle)
  {
    if (r2t->total_seqlength > 0)
    {
      r2t->hplengths = state->hplengths;
      gt_hplstore_finalize(r2t->hplengths, r2t->total_seqlength);
      r2t->approx_avhlen = (double)state->hsum / state->nofh + 1;
    }
    else
    {
      gt_hplstore_delete(state->hplengths);
    }
  }
  if (state->qbuf_size > 0)
    gt_free(state->qbuf);
  if (state->qbuf2_size > 0)
    gt_free(state->qbuf2);
  gt_str_delete(state->dbuf);
  gt_str_delete(state->dbuf2);
  gt_reads2twobit_tbe_flush_and_realloc(r2t, state);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq 0x860(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x10(%rsp), %rax
movq $0x3, 0x68(%rax)
movq 0x8(%rsp), %rax
movq 0x8f8(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x8(%rsp), %rax
movq 0x900(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x78(%rax)
movl $0x0, 0x4(%rsp)
cmpl $0x4, 0x4(%rsp)
jae 0x2a2205
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movq 0x838(%rax,%rcx,8), %rdx
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
movq %rdx, 0x18(%rax,%rcx,8)
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x2a21d2
movq 0x8(%rsp), %rax
testb $0x1, 0x8f0(%rax)
je 0x2a22cd
movq 0x8(%rsp), %rax
movq 0x908(%rax), %rdi
movq 0x8(%rsp), %rax
movq 0x860(%rax), %rsi
shlq $0x3, %rsi
leaq 0x2e2d76(%rip), %rdx    # 0x584fb0
movl $0x572, %ecx            # imm = 0x572
callq 0xe8540
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x908(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x48(%rax)
movq 0x8(%rsp), %rax
movq 0x870(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x8(%rsp), %rax
movq 0x878(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x8(%rsp), %rax
movq 0x908(%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x860(%rcx), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x8(%rsp), %rax
movq 0x908(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x38(%rax)
jmp 0x2a239d
movq 0x8(%rsp), %rax
movq 0x880(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x8(%rsp), %rax
movq 0x880(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x8(%rsp), %rax
movq 0x880(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x8(%rsp), %rax
cmpq $0x0, 0x880(%rax)
jbe 0x2a2343
movq 0x8(%rsp), %rax
movq 0x880(%rax), %rcx
movq 0x8(%rsp), %rax
imulq 0x860(%rax), %rcx
subq $0x1, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x60(%rax)
jmp 0x2a2350
movq 0x10(%rsp), %rax
movq $0x0, 0x60(%rax)
jmp 0x2a2352
movq 0x8(%rsp), %rax
cmpq $0x0, 0x908(%rax)
je 0x2a2399
movq 0x399c38(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x273ca1(%rip), %rsi    # 0x516013
leaq 0x2e3696(%rip), %rdx    # 0x585a0f
leaq 0x2e398a(%rip), %rcx    # 0x585d0a
leaq 0x2e2c29(%rip), %r8     # 0x584fb0
movl $0x583, %r9d            # imm = 0x583
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2a239b
jmp 0x2a239d
movq 0x10(%rsp), %rax
testb $0x1, 0x91(%rax)
je 0x2a2468
movq 0x10(%rsp), %rax
cmpq $0x0, 0x60(%rax)
jbe 0x2a2455
movq 0x8(%rsp), %rax
movq 0x970(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0xc0(%rax)
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rsi
movq 0xc0(%rax), %rdi
callq 0x4d12e0
movq 0x8(%rsp), %rax
movq 0x980(%rax), %xmm0
movaps 0x276530(%rip), %xmm3   # 0x518930
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x276534(%rip), %xmm2   # 0x518940
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x988(%rax), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x274dfe(%rip), %xmm1   # 0x517240
addsd %xmm1, %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, 0xc8(%rax)
jmp 0x2a2466
movq 0x8(%rsp), %rax
movq 0x970(%rax), %rdi
callq 0x4d12a0
jmp 0x2a2468
movq 0x8(%rsp), %rax
cmpq $0x0, 0x938(%rax)
jbe 0x2a2494
movq 0x8(%rsp), %rax
movq 0x920(%rax), %rdi
leaq 0x2e2b26(%rip), %rsi    # 0x584fb0
movl $0x593, %edx            # imm = 0x593
callq 0xe88c0
movq 0x8(%rsp), %rax
cmpq $0x0, 0x940(%rax)
jbe 0x2a24c0
movq 0x8(%rsp), %rax
movq 0x928(%rax), %rdi
leaq 0x2e2afa(%rip), %rsi    # 0x584fb0
movl $0x595, %edx            # imm = 0x595
callq 0xe88c0
movq 0x8(%rsp), %rax
movq 0x948(%rax), %rdi
callq 0x11f560
movq 0x8(%rsp), %rax
movq 0x950(%rax), %rdi
callq 0x11f560
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2a8600
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)