// File: /workspace/github_c_makefile_star2_O3/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
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
testq %rdi, %rdi
je 0x12d9f8
movq %rdi, %r13
cmpq %rsi, 0x98(%rdi)
jbe 0x12d9fd
movq %rcx, %r15
movq %rdx, %r12
cmpq %rcx, %rdx
ja 0x12da02
leaq (%rsi,%rsi,4), %r14
shlq $0x3, %r14
addq 0x10(%r13), %r14
cmpq $0x2, 0x80(%r13)
jb 0x12d801
movq 0x18(%r14), %rsi
movq 0x28(%r13), %rdi
callq 0x1567b9
testq %rax, %rax
je 0x12d801
movq %rax, %rbx
movq 0x28(%r13), %rdi
movq %rax, %rsi
decq %rsi
callq 0x15673b
movq %rax, %rbp
incq %rbp
jmp 0x12d805
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x80(%r13), %rax
decq %rax
cmpq %rbx, %rax
jbe 0x12d822
movq 0x28(%r13), %rdi
movq %rbx, %rsi
callq 0x15673b
jmp 0x12d826
movq 0x78(%r13), %rax
decq %rax
movq 0x18(%r14), %rsi
leaq (%rsi,%r12), %rcx
xorl %edx, %edx
subq 0x8(%rsp), %rcx
cmovaeq %rcx, %rdx
cmpq %rbp, %rdx
cmovbeq %rbp, %rdx
movq 0x10(%rsp), %rcx
addq %r15, %rcx
addq %rsi, %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
cmpq %rcx, %rdx
ja 0x12da07
movq 0x70(%rsp), %r8
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x12d87d
xorl %eax, %eax
jmp 0x12d9e9
movl $0x1, %r8d
xorl %ebx, %ebx
movq 0x10(%r14), %rax
cmpq %rax, %rbx
jae 0x12d9e6
movq 0x8(%r13), %rcx
movq (%r14), %rdx
movl (%rdx,%rbx,4), %ebp
shlq $0x5, %rbp
movl 0x18(%rcx,%rbp), %esi
cmpq %r15, %rsi
ja 0x12d8b8
addq %rcx, %rbp
movl 0x10(%rbp), %edi
addl %edi, %esi
decl %esi
cmpq %r12, %rsi
jae 0x12d8c5
incq %rbx
cmpq %rax, %rbx
jb 0x12d899
jmp 0x12d9e6
cmpq $0x2, 0x80(%r13)
movq %r8, 0x20(%rsp)
jb 0x12d905
movq 0x8(%rbp), %rsi
movq 0x28(%r13), %rdi
callq 0x1567b9
testq %rax, %rax
je 0x12d905
movq 0x28(%r13), %rdi
movq %rax, %rsi
decq %rsi
movq %rax, (%rsp)
callq 0x15673b
movq (%rsp), %rsi
movq %rax, %rdx
incq %rdx
jmp 0x12d909
xorl %esi, %esi
xorl %edx, %edx
movq 0x80(%r13), %rax
decq %rax
cmpq %rsi, %rax
jbe 0x12d938
movq 0x28(%r13), %rdi
movq %rsi, (%rsp)
movq %rdx, 0x18(%rsp)
callq 0x15673b
movq 0x18(%rsp), %rdx
movq (%rsp), %rsi
movq %rax, %rcx
jmp 0x12d93c
movq 0x78(%r13), %rcx
movq 0x8(%rbp), %rax
movq %rax, %rdi
subq 0x8(%rsp), %rdi
movl $0x0, %r8d
cmovaeq %rdi, %r8
movl 0x18(%rbp), %r9d
movq %r9, %rdi
subq %r12, %rdi
jbe 0x12d96c
subq %rdi, %r8
movl $0x0, %edi
cmovaeq %r8, %rdi
jmp 0x12d975
addq %r12, %r8
subq %r9, %r8
movq %r8, %rdi
cmpq %rdx, %rdi
cmovaq %rdi, %rdx
addq 0x10(%rsp), %rax
movl 0x10(%rbp), %edi
addq %rdi, %rax
addl %r9d, %edi
decl %edi
movq %rdi, %r8
subq %r15, %r8
jbe 0x12d9a3
subq %r8, %rax
movl $0x0, %r9d
cmovaeq %rax, %r9
jmp 0x12d9ac
movq %r15, %r9
subq %rdi, %r9
addq %rax, %r9
movq 0x70(%rsp), %r8
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rax
decq %rcx
cmpq %rcx, %r9
cmovbq %r9, %rcx
cmpq %rcx, %rdx
ja 0x12da0c
callq *%rax
movq 0x20(%rsp), %r8
incq %r8
incq %rbx
testl %eax, %eax
movl $0x0, %eax
je 0x12d885
jmp 0x12d9e9
movq %r8, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3d8eb
callq 0x3d807
callq 0x3d8b2
callq 0x3d879
callq 0x3d840