// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/reads2twobit.c
// Function: gt_reads2twobit_write_encoded
GtTwobitencoding* gt_reads2twobit_write_encoded(GtReads2Twobit *r2t,
    GtUword seqnum, GtTwobitencoding *outputbuffer,
    GtTwobitencoding outputoffset, GtTwobitencoding *lastcodeoffsetptr)
{
  GtUword firstpos, firstcodeidx, lastpos, lastcodeidx, seqlen;
  GtTwobitencoding  inputoffset;

  firstpos = (seqnum == 0)
    ? 0
    : (r2t->seqlen_eqlen > 0)
        ? r2t->seqlen_eqlen * seqnum
        : r2t->seppos[seqnum - 1UL] + 1UL;
  firstcodeidx = GT_DIVBYUNITSIN2BITENC(firstpos);

  lastpos = (r2t->seqlen_eqlen > 0)
    ? r2t->seqlen_eqlen * (seqnum + 1UL) - 1UL
    : r2t->seppos[seqnum];
  lastcodeidx = GT_DIVBYUNITSIN2BITENC(lastpos);

  seqlen = (r2t->seqlen_eqlen > 0)
    ? r2t->seqlen_eqlen
    : lastpos - firstpos + 1UL;

  inputoffset = (GtTwobitencoding)GT_MODBYUNITSIN2BITENC(firstpos);

  if (inputoffset == outputoffset)
  {
    gt_reads2twobit_write_encoded_nocodesshift(r2t, outputbuffer, inputoffset,
        firstcodeidx, lastcodeidx);
    *lastcodeoffsetptr = (GtTwobitencoding)GT_MODBYUNITSIN2BITENC(lastpos + 1);
  }
  else if (inputoffset > outputoffset)
  {
    gt_reads2twobit_write_encoded_leftcodesshift(r2t,
        outputbuffer, inputoffset, outputoffset, firstcodeidx, lastcodeidx);
    *lastcodeoffsetptr = GT_MODBYUNITSIN2BITENC(outputoffset + seqlen);
  }
  else
  {
    gt_reads2twobit_write_encoded_rightcodesshift(r2t,
        outputbuffer, inputoffset, outputoffset, firstcodeidx, lastcodeidx);
    *lastcodeoffsetptr = GT_MODBYUNITSIN2BITENC(outputoffset + seqlen);
  }
  return outputbuffer + GT_DIVBYUNITSIN2BITENC(outputoffset + seqlen);
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
cmpq $0x0, 0x68(%rsp)
jne 0x2a2d8e
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x2a2dd9
movq 0x70(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x2a2db0
movq 0x70(%rsp), %rax
movq 0x48(%rax), %rax
imulq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x2a2dcf
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x68(%rsp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
shrq $0x5, %rax
movq %rax, 0x40(%rsp)
movq 0x70(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x2a2e1e
movq 0x70(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x68(%rsp), %rcx
addq $0x1, %rcx
imulq %rcx, %rax
subq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x2a2e35
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x68(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
shrq $0x5, %rax
movq %rax, 0x30(%rsp)
movq 0x70(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x2a2e68
movq 0x70(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, (%rsp)
jmp 0x2a2e7a
movq 0x38(%rsp), %rax
subq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
andq $0x1f, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x58(%rsp), %rax
jne 0x2a2ed5
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x30(%rsp), %r8
callq 0x2a2f80
movq 0x38(%rsp), %rcx
addq $0x1, %rcx
andq $0x1f, %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
jmp 0x2a2f57
movq 0x20(%rsp), %rax
cmpq 0x58(%rsp), %rax
jbe 0x2a2f1c
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x30(%rsp), %r9
callq 0x2a3060
movq 0x58(%rsp), %rcx
addq 0x28(%rsp), %rcx
andq $0x1f, %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
jmp 0x2a2f55
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x30(%rsp), %r9
callq 0x2a31d0
movq 0x58(%rsp), %rcx
addq 0x28(%rsp), %rcx
andq $0x1f, %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
jmp 0x2a2f57
movq 0x60(%rsp), %rax
movq 0x58(%rsp), %rcx
addq 0x28(%rsp), %rcx
shrq $0x5, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)