// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/condenseq.c
// Function: gt_condenseq_extract_encoded_range
const GtUchar *gt_condenseq_extract_encoded_range(GtCondenseq *condenseq,
                                                  GtRange range)
{
  GtUchar *buf;
  GtUword nextsep,
          linkid = 0,
          uniqueid,
          buffoffset = 0,
          length;
  GtCondenseqLink *link = NULL;
  GtCondenseqUnique *unique = NULL;

  gt_assert(condenseq && condenseq->uds_nelems != 0);
  gt_assert(condenseq->uniques[0].orig_startpos == 0);
  gt_assert(range.start <= range.end);
  gt_assert(range.end < condenseq->orig_len);

  nextsep = condenseq_next_sep(condenseq, range.start);
  uniqueid = gt_condenseq_uniques_position_binsearch(condenseq,
                                                     range.start);

  length = range.end - range.start + 1;

  /* TODO DW check if there is another way than using this buffer, so we could
     use const for condenseq here. */
  if (condenseq->ubuffer == NULL || condenseq->ubuffsize < length) {
    condenseq->ubuffer = gt_realloc(condenseq->ubuffer,
                                    sizeof (*condenseq->ubuffer) * length);
    condenseq->ubuffsize = length;
  }

  buf = condenseq->ubuffer;

  unique = &condenseq->uniques[uniqueid];

  if (unique->orig_startpos + unique->len <= range.start) {
    uniqueid++;
    if (uniqueid == condenseq->uds_nelems)
      unique = NULL;
    else {
      unique = &condenseq->uniques[uniqueid];
      gt_assert(unique->orig_startpos + unique->len > range.start);
    }
  }

  if (condenseq->lds_nelems != 0) {
      linkid = condenseq_links_position_binsearch(condenseq, range.start);
    if (linkid == condenseq->lds_nelems)
      linkid = 0;
    link = &condenseq->links[linkid];
  }
  if (link != NULL &&
      link->orig_startpos + link->len <= range.start) {
    linkid++;
    if (linkid == condenseq->lds_nelems)
      link = NULL;
    else {
      link = &condenseq->links[linkid];
      gt_assert(link->orig_startpos + link->len > range.start);
    }
  }

  while (buffoffset < length) {
    gt_assert(nextsep == range.start + buffoffset ||
              unique != NULL ||
              link != NULL);
    if (nextsep != 0 && nextsep == range.start + buffoffset) {
      buf[buffoffset++] = GT_SEPARATOR;
      nextsep = condenseq_next_sep(condenseq, range.start + buffoffset);
    }
    else if (unique != NULL &&
             (link == NULL || unique->orig_startpos < link->orig_startpos)) {
      buffoffset += condenseq_unique_extract_encoded(condenseq, uniqueid,
                                                     buf + buffoffset,
                                                     range.start + buffoffset,
                                                     range.end);
      if (++uniqueid == condenseq->uds_nelems)
        unique = NULL;
      else {
        unique = &condenseq->uniques[uniqueid];
        gt_assert(unique->orig_startpos + unique->len > range.start);
      }
    }
    else {
      gt_assert(link != NULL);
      buffoffset += condenseq_link_extract_encoded(condenseq, linkid,
                                                   buf + buffoffset,
                                                   range.start + buffoffset,
                                                   range.end);
      if (++linkid == condenseq->lds_nelems)
        link = NULL;
      else {
        link = &condenseq->links[linkid];
        gt_assert(link->orig_startpos + link->len > range.start);
      }
    }
  }
  gt_assert(buffoffset == length);
  return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0x133527
movq %rdi, %r13
cmpq $0x0, 0x98(%rdi)
je 0x133527
movq 0x10(%r13), %rax
cmpq $0x0, 0x18(%rax)
jne 0x13352c
movq %rdx, %rbx
movq %rsi, %r12
movq %rdx, %r14
subq %rsi, %r14
jb 0x133531
cmpq %rbx, 0x78(%r13)
jbe 0x133536
movq %r13, %rdi
movq %r12, %rsi
callq 0x13354f
movq %rax, %rbp
movq %r13, %rdi
movq %r12, %rsi
callq 0x133015
movq %rax, %r15
incq %r14
movq 0x30(%r13), %rdi
testq %rdi, %rdi
je 0x13310b
cmpq %r14, 0x88(%r13)
jae 0x13312a
leaq 0x24ee32(%rip), %rdx    # 0x381f44
movq %r14, %rsi
movl $0x2f4, %ecx            # imm = 0x2F4
callq 0x1094e6
movq %rax, 0x30(%r13)
movq %r14, 0x88(%r13)
movq 0x10(%r13), %rsi
movq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
leaq (%r15,%r15,4), %rcx
movl 0x20(%rsi,%rcx,8), %edx
addq 0x18(%rsi,%rcx,8), %rdx
cmpq %r12, %rdx
movq %rbp, %rax
ja 0x133173
incq %r15
cmpq 0x98(%r13), %r15
jne 0x13315d
xorl %r9d, %r9d
jmp 0x133177
leaq (%r15,%r15,4), %rcx
movl 0x20(%rsi,%rcx,8), %edx
addq 0x18(%rsi,%rcx,8), %rdx
cmpq %r12, %rdx
jbe 0x133545
leaq (%rsi,%rcx,8), %r9
movq 0x70(%r13), %r8
testq %r8, %r8
je 0x1331f4
jle 0x133540
leaq -0x1(%r8), %rcx
sarq %rcx
movq 0x8(%r13), %r10
movq $-0x1, %rdx
movq %r8, %rsi
movq %rcx, %rdi
shlq $0x5, %rdi
cmpq %r12, 0x8(%r10,%rdi)
ja 0x1331ae
movq %rcx, %rdx
jmp 0x1331b1
movq %rcx, %rsi
leaq (%rdx,%rsi), %rcx
sarq %rcx
movq %rsi, %rdi
subq %rdx, %rdi
cmpq $0x1, %rdi
jg 0x13319b
testq %rdx, %rdx
js 0x1331d7
movq %rcx, %rdx
shlq $0x5, %rdx
cmpq %r12, 0x8(%r10,%rdx)
jbe 0x1331da
movq %r8, %rcx
xorl %edx, %edx
cmpq %r8, %rcx
cmovneq %rcx, %rdx
movq %rdx, 0x10(%rsp)
movq %rdx, %rcx
shlq $0x5, %rcx
addq %rcx, %r10
jmp 0x133200
movq $0x0, 0x10(%rsp)
xorl %r10d, %r10d
testq %r10, %r10
je 0x133224
movl 0x10(%r10), %ecx
addq 0x8(%r10), %rcx
cmpq %r12, %rcx
ja 0x133247
movq 0x10(%rsp), %rdx
incq %rdx
cmpq %r8, %rdx
movq %rdx, 0x10(%rsp)
jne 0x133229
xorl %r10d, %r10d
jmp 0x133247
movq 0x8(%r13), %r10
shlq $0x5, %rdx
movl 0x10(%r10,%rdx), %ecx
addq 0x8(%r10,%rdx), %rcx
cmpq %r12, %rcx
jbe 0x13354a
addq %rdx, %r10
testq %r14, %r14
je 0x1334df
movq %r15, 0x18(%rsp)
movq %rbx, 0x50(%rsp)
xorl %r15d, %r15d
movq %r12, 0x38(%rsp)
movq %r14, 0x20(%rsp)
leaq (%r15,%r12), %rbp
cmpq %rbp, %rax
je 0x13327e
testq %r9, %r9
jne 0x13327e
testq %r10, %r10
je 0x1334fa
testq %rax, %rax
je 0x1332b6
cmpq %rbp, %rax
jne 0x1332b6
leaq 0x1(%r15), %rbx
movq 0x30(%rsp), %rax
movb $-0x1, (%rax,%r15)
leaq (%r15,%r12), %rsi
incq %rsi
movq %r13, %rdi
movq %r9, %r15
movq %r10, %rbp
callq 0x13354f
movq %rbp, %r10
movq %r15, %r9
jmp 0x1334d1
testq %r9, %r9
movq %rax, 0x48(%rsp)
je 0x1333a3
testq %r10, %r10
je 0x1332d7
movq 0x18(%r9), %rcx
cmpq 0x8(%r10), %rcx
jae 0x1333a3
movq 0x10(%r13), %rsi
movq 0x18(%rsp), %rcx
leaq (%rcx,%rcx,4), %rcx
movq %rbp, %rbx
subq 0x18(%rsi,%rcx,8), %rbx
jb 0x133518
movq %r13, %r14
movq %r10, 0x28(%rsp)
leaq (%rsi,%rcx,8), %rax
movl 0x20(%rax), %r12d
movq %r12, %r13
subq %rbx, %r13
jbe 0x133513
movq 0x30(%rsp), %rax
addq %r15, %rax
movq %rax, 0x40(%rsp)
movq 0x18(%r14), %rdi
movq 0x18(%rsp), %rsi
movq %rsi, 0x18(%rsp)
callq 0xefce0
addq %rax, %rbx
movq 0x50(%rsp), %rcx
subq %rbp, %rcx
leaq (%rbx,%rcx), %rdx
incq %rcx
cmpq %rcx, %r13
leaq -0x1(%r12,%rax), %r13
cmovaeq %rdx, %r13
movq 0x18(%r14), %rdi
movq 0x40(%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xed6e0
subq %rbx, %r15
leaq (%r15,%r13), %rbx
incq %rbx
movq 0x18(%rsp), %rcx
movq %r14, %r13
incq %rcx
cmpq 0x98(%r14), %rcx
movq %rcx, 0x18(%rsp)
jne 0x1334a3
xorl %r9d, %r9d
movq 0x38(%rsp), %r12
movq 0x20(%rsp), %r14
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %r10
jmp 0x1334d1
testq %r10, %r10
je 0x133504
movq %r9, 0x28(%rsp)
movq 0x8(%r13), %rax
movq 0x10(%rsp), %rcx
shlq $0x5, %rcx
movq %r13, %r14
movq %rbp, %r13
subq 0x8(%rax,%rcx), %r13
jb 0x1334ff
leaq (%rax,%rcx), %rdx
movq (%rax,%rcx), %rsi
movq %rsi, 0x40(%rsp)
movl 0x10(%rax,%rcx), %r12d
movl 0x18(%rax,%rcx), %ebx
movl 0x14(%rdx), %esi
movq 0x18(%r14), %rdi
callq 0xefce0
movq %r12, %rcx
subq %r13, %rcx
jbe 0x133509
movq 0x30(%rsp), %rdx
addq %r15, %rdx
movq 0x50(%rsp), %rsi
subq %rbp, %rsi
decl %r12d
leaq (%rsi,%r13), %rdi
incq %rsi
cmpq %rsi, %rcx
cmovaeq %rdi, %r12
movq 0x18(%r14), %rsi
addq %rbx, %rax
movq %rdx, (%rsp)
movq 0x40(%rsp), %rdi
movq %rax, %rdx
xorl %ecx, %ecx
movq %r13, %r8
movq %r12, %r9
callq 0x13f227
subq %r13, %r12
incq %r12
cmpq %r12, %rax
jne 0x13350e
movq %rax, %rbx
addq %r15, %rbx
movq 0x10(%rsp), %rdx
incq %rdx
cmpq 0x70(%r14), %rdx
movq 0x38(%rsp), %r12
movq %r14, %r13
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %r9
movq %rdx, 0x10(%rsp)
jne 0x133482
xorl %r10d, %r10d
movq 0x20(%rsp), %r14
jmp 0x1334d1
movq 0x8(%r13), %r10
shlq $0x5, %rdx
movl 0x10(%r10,%rdx), %ecx
addq 0x8(%r10,%rdx), %rcx
cmpq %r12, %rcx
movq 0x20(%rsp), %r14
jbe 0x13351d
addq %rdx, %r10
jmp 0x1334d1
movq 0x10(%r13), %rsi
leaq (%rcx,%rcx,4), %rcx
movl 0x20(%rsi,%rcx,8), %edx
addq 0x18(%rsi,%rcx,8), %rdx
movq 0x38(%rsp), %r12
cmpq %r12, %rdx
movq 0x20(%rsp), %r14
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %r10
jbe 0x133522
leaq (%rsi,%rcx,8), %r9
movq %rbx, %r15
cmpq %r14, %rbx
jb 0x133267
jmp 0x1334e1
xorl %ebx, %ebx
cmpq %r14, %rbx
jne 0x13353b
movq 0x30(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3dfa0
callq 0x3e0bd
callq 0x3dfd9
callq 0x3e012
callq 0x3e04b
callq 0x3e0f6
callq 0x3e168
callq 0x3e084
callq 0x3e12f
callq 0x3e213
callq 0x3de8f
callq 0x3e1da
callq 0x3dec8
callq 0x3e1a1
callq 0x3df3a
callq 0x3df01
callq 0x3df67