// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/condenseq.c
// Function: gt_condenseq_each_redundant_range
GtUword gt_condenseq_each_redundant_range(
                                      const GtCondenseq *condenseq,
                                      GtUword uid,
                                      GtRange urange,
                                      GtUword left_extend,
                                      GtUword right_extend,
                                      GtCondenseqProcessExtractedRange callback,
                                      void *callback_data,
                                      GtError *err)
{
  int had_err = 0;
  GtUword num_ranges = (GtUword) 1,
          linkidx,
          orig_seqnum,
          orig_seqstart,
          orig_seqend;
  const GtCondenseqUnique *unique;
  GtRange extract;

  gt_assert(condenseq != NULL);
  gt_assert(uid < condenseq->uds_nelems);
  gt_assert(urange.start <= urange.end);

  unique = &condenseq->uniques[uid];

  /* handle unique itself */
  orig_seqnum = gt_condenseq_pos2seqnum(condenseq, unique->orig_startpos);
  orig_seqstart = gt_condenseq_seqstartpos(condenseq, orig_seqnum);
  orig_seqend = orig_seqstart + condenseq_seqlength_help(condenseq, orig_seqnum,
                                                         orig_seqstart) - 1;
  extract.start = unique->orig_startpos + urange.start;
  extract.start = extract.start < left_extend ?
    0 : extract.start - left_extend;
  extract.start = extract.start < orig_seqstart ?
    orig_seqstart : extract.start;
  extract.end = unique->orig_startpos + urange.end + right_extend;
  extract.end = extract.end > orig_seqend ?
    orig_seqend : extract.end;

  gt_assert(extract.start <= extract.end);
  had_err = callback(callback_data, orig_seqnum, extract, err);

  for (linkidx = 0;
       !had_err && linkidx < unique->links.nextfreeuint32_t;
       ++linkidx) {
    const GtCondenseqLink *link =
      &condenseq->links[unique->links.spaceuint32_t[linkidx]];

    /* the second part is a little heuristic, the len of the link could be
       completely comprised of insertions, which would place it downstream of
       urange.start. But we assume ~ similar lengths for links and their unique
       counterpart */
    if (!(urange.end < link->unique_offset ||
        urange.start > link->unique_offset + link->len - 1)) {
      GtUword shift;
      orig_seqnum = gt_condenseq_pos2seqnum(condenseq, link->orig_startpos);
      orig_seqstart = gt_condenseq_seqstartpos(condenseq, orig_seqnum);
      orig_seqend = orig_seqstart + condenseq_seqlength_help(condenseq,
                                                             orig_seqnum,
                                                             orig_seqstart) - 1;
      extract.start = link->orig_startpos < left_extend ?
        0 : link->orig_startpos - left_extend;
      if (urange.start < link->unique_offset) {
        shift = link->unique_offset - urange.start;
        extract.start = extract.start < shift ?
          0 : extract.start - shift;
      }
      else {
        shift = urange.start - link->unique_offset;
        extract.start += shift;
      }
      extract.start = extract.start < orig_seqstart ?
        orig_seqstart : extract.start;
      /* see heuristic note above */
      extract.end = link->orig_startpos + right_extend + link->len;
      if (urange.end < link->unique_offset + link->len - 1) {
        shift = (link->unique_offset + link->len - 1) - urange.end;
        extract.end = extract.end < shift ?
          0 : extract.end - shift;
      }
      else {
        shift = urange.end - (link->unique_offset + link->len - 1);
        extract.end += shift;
      }
      extract.end = extract.end > orig_seqend ?
        orig_seqend : extract.end;
      gt_assert(extract.start <= extract.end);
      had_err = callback(callback_data, orig_seqnum, extract, err);
      num_ranges++;
    }
  }

  if (!had_err)
    return num_ranges;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x133a68
movq %rdi, %r13
cmpq %rsi, 0x98(%rdi)
jbe 0x133a6d
cmpq %rcx, %rdx
ja 0x133a72
movq %r9, %r15
movq %r8, %r12
leaq (%rsi,%rsi,4), %rbp
shlq $0x3, %rbp
addq 0x10(%r13), %rbp
cmpq $0x2, 0x80(%r13)
movq %rcx, 0x8(%rsp)
movq %rdx, (%rsp)
jb 0x13383c
movq 0x18(%rbp), %rsi
movq 0x28(%r13), %rdi
callq 0x15e36d
movq %rax, %rbx
jmp 0x13383e
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x133858
movq 0x28(%r13), %rdi
leaq -0x1(%rbx), %rsi
callq 0x15e2ef
movq %rax, %r14
incq %r14
jmp 0x13385b
xorl %r14d, %r14d
movq 0x80(%r13), %rax
decq %rax
cmpq %rbx, %rax
jbe 0x133878
movq 0x28(%r13), %rdi
movq %rbx, %rsi
callq 0x15e2ef
jmp 0x13387c
movq 0x78(%r13), %rax
movq 0x8(%rsp), %rdi
movq (%rsp), %rcx
decq %rax
movq 0x18(%rbp), %rsi
addq %rsi, %rcx
xorl %edx, %edx
subq %r12, %rcx
cmovaeq %rcx, %rdx
cmpq %r14, %rdx
cmovbeq %r14, %rdx
leaq (%r15,%rdi), %rcx
addq %rsi, %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
cmpq %rcx, %rdx
ja 0x133a77
movq 0x70(%rsp), %r8
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
jne 0x133a4e
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movl $0x1, %r8d
xorl %r12d, %r12d
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
cmpq 0x10(%rbp), %r12
jae 0x133a51
movq 0x8(%r13), %r15
movq (%rbp), %rax
movl (%rax,%r12,4), %edx
shlq $0x5, %rdx
movl 0x18(%r15,%rdx), %ecx
movb $0x1, %al
cmpq %rsi, %rcx
ja 0x133a43
addq %rdx, %r15
movl 0x10(%r15), %edx
addl %edx, %ecx
decl %ecx
cmpq %rdi, %rcx
jb 0x133a43
cmpq $0x2, 0x80(%r13)
movq %r8, 0x20(%rsp)
jb 0x13394d
movq 0x8(%r15), %rsi
movq 0x28(%r13), %rdi
callq 0x15e36d
movq %rax, %rbx
jmp 0x13394f
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x133969
movq 0x28(%r13), %rdi
leaq -0x1(%rbx), %rsi
callq 0x15e2ef
movq %rax, %r14
incq %r14
jmp 0x13396c
xorl %r14d, %r14d
movq 0x80(%r13), %rax
decq %rax
cmpq %rbx, %rax
jbe 0x13398c
movq 0x28(%r13), %rdi
movq %rbx, %rsi
callq 0x15e2ef
movq %rax, %rcx
jmp 0x133990
movq 0x78(%r13), %rcx
movq 0x8(%rsp), %r8
movq (%rsp), %r9
movq 0x8(%r15), %rax
movq %rax, %rdx
subq 0x10(%rsp), %rdx
movl $0x0, %esi
cmovaeq %rdx, %rsi
movl 0x18(%r15), %edx
movq %rdx, %rdi
subq %r9, %rdi
jbe 0x1339c8
subq %rdi, %rsi
movl $0x0, %edi
cmovaeq %rsi, %rdi
jmp 0x1339d1
addq %r9, %rsi
subq %rdx, %rsi
movq %rsi, %rdi
cmpq %r14, %rdi
cmovaq %rdi, %r14
addq 0x18(%rsp), %rax
movl 0x10(%r15), %esi
addq %rsi, %rax
addl %edx, %esi
decl %esi
movq %rsi, %rdx
subq %r8, %rdx
jbe 0x1339fe
subq %rdx, %rax
movl $0x0, %edx
cmovaeq %rax, %rdx
jmp 0x133a07
movq %r8, %rdx
subq %rsi, %rdx
addq %rax, %rdx
movq 0x68(%rsp), %rdi
decq %rcx
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
cmpq %rcx, %r14
ja 0x133a63
movq %rbx, %rsi
movq %r14, %rdx
movq 0x70(%rsp), %r8
movq 0x60(%rsp), %rax
callq *%rax
movq 0x20(%rsp), %r8
incq %r8
testl %eax, %eax
sete %al
movq 0x8(%rsp), %rsi
movq (%rsp), %rdi
incq %r12
testb %al, %al
jne 0x1338ee
xorl %r8d, %r8d
movq %r8, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3e2be
callq 0x3e369
callq 0x3e285
callq 0x3e330
callq 0x3e2f7