// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xe8, %rsp
movq 0x100(%rsp), %rax
movq 0xf8(%rsp), %rax
movq 0xf0(%rsp), %rax
movq %rdx, 0xd0(%rsp)
movq %rcx, 0xd8(%rsp)
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %r8, 0xb8(%rsp)
movq %r9, 0xb0(%rsp)
movl $0x0, 0xac(%rsp)
movq $0x1, 0xa0(%rsp)
cmpq $0x0, 0xc8(%rsp)
jne 0x1417b9
movq 0x4fa818(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3d4881(%rip), %rsi    # 0x516013
leaq 0x409780(%rip), %rdx    # 0x54af19
leaq 0x409dd7(%rip), %rcx    # 0x54b577
leaq 0x40979d(%rip), %r8     # 0x54af44
movl $0x3b7, %r9d            # imm = 0x3B7
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1417bb
jmp 0x1417bd
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
jb 0x14180e
movq 0x4fa7c3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3d482c(%rip), %rsi    # 0x516013
leaq 0x409b25(%rip), %rdx    # 0x54b313
leaq 0x409d82(%rip), %rcx    # 0x54b577
leaq 0x409748(%rip), %r8     # 0x54af44
movl $0x3b8, %r9d            # imm = 0x3B8
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x141810
jmp 0x141812
movq 0xd0(%rsp), %rax
cmpq 0xd8(%rsp), %rax
jbe 0x14185c
movq 0x4fa775(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3d47de(%rip), %rsi    # 0x516013
leaq 0x409d5d(%rip), %rdx    # 0x54b599
leaq 0x409d34(%rip), %rcx    # 0x54b577
leaq 0x4096fa(%rip), %r8     # 0x54af44
movl $0x3b9, %r9d            # imm = 0x3B9
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x14185e
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rax
imulq $0x28, 0xc0(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x13e420
movq %rax, 0x90(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x13e470
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x13e500
movq %rax, %rcx
movq 0x50(%rsp), %rax
addq %rcx, %rax
subq $0x1, %rax
movq %rax, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
addq 0xd0(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0xb8(%rsp), %rax
jae 0x141925
xorl %eax, %eax
movq %rax, 0x48(%rsp)
jmp 0x141937
movq 0x68(%rsp), %rax
subq 0xb8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x88(%rsp), %rax
jae 0x14195f
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x141969
movq 0x68(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
addq 0xd8(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x80(%rsp), %rax
jbe 0x1419af
movq 0x80(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x1419b9
movq 0x70(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x70(%rsp), %rax
jbe 0x141a07
movq 0x4fa5ca(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3d4633(%rip), %rsi    # 0x516013
leaq 0x409bcd(%rip), %rdx    # 0x54b5b4
leaq 0x409b89(%rip), %rcx    # 0x54b577
leaq 0x40954f(%rip), %r8     # 0x54af44
movl $0x3cb, %r9d            # imm = 0x3CB
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x141a09
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x100(%rsp), %r8
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rcx
callq *%rax
movl %eax, 0xac(%rsp)
movq $0x0, 0x98(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xac(%rsp)
movb %al, 0x37(%rsp)
jne 0x141a70
movq 0x98(%rsp), %rax
movq 0x78(%rsp), %rcx
cmpq 0x10(%rcx), %rax
setb %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x141a7d
jmp 0x141df2
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x78(%rsp), %rcx
movq (%rcx), %rcx
movq 0x98(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0xd8(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jb 0x141dd7
movq 0xd0(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
movq 0x60(%rsp), %rdx
addl 0x10(%rdx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
ja 0x141dd7
movq 0xc8(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x13e420
movq %rax, 0x90(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x13e470
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x13e500
movq %rax, %rcx
movq 0x28(%rsp), %rax
addq %rcx, %rax
subq $0x1, %rax
movq %rax, 0x80(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0xb8(%rsp), %rax
jae 0x141b7f
xorl %eax, %eax
movq %rax, 0x20(%rsp)
jmp 0x141b95
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
subq 0xb8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xd0(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jae 0x141bf9
movq 0x60(%rsp), %rax
movl 0x18(%rax), %eax
subq 0xd0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x58(%rsp), %rax
jae 0x141bde
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x141bed
movq 0x68(%rsp), %rax
subq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x141c20
movq 0xd0(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
subq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
addq 0x68(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x88(%rsp), %rax
jae 0x141c3e
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x141c48
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
addq 0xb0(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x10(%rcx), %ecx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0xd8(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
movq 0x60(%rsp), %rdx
addl 0x10(%rdx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x141ce7
movq 0x60(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x60(%rsp), %rcx
addl 0x10(%rcx), %eax
subl $0x1, %eax
movl %eax, %eax
subq 0xd8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x58(%rsp), %rax
jae 0x141ccc
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x141cdb
movq 0x70(%rsp), %rax
subq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x141d1b
movq 0xd8(%rsp), %rax
movq 0x60(%rsp), %rcx
movl 0x18(%rcx), %ecx
movq 0x60(%rsp), %rdx
addl 0x10(%rdx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x80(%rsp), %rax
jbe 0x141d38
movq 0x80(%rsp), %rax
movq %rax, (%rsp)
jmp 0x141d41
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x70(%rsp), %rax
jbe 0x141d8e
movq 0x4fa243(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3d42ac(%rip), %rsi    # 0x516013
leaq 0x409846(%rip), %rdx    # 0x54b5b4
leaq 0x409802(%rip), %rcx    # 0x54b577
leaq 0x4091c8(%rip), %r8     # 0x54af44
movl $0x3fa, %r9d            # imm = 0x3FA
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x141d90
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x100(%rsp), %r8
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rcx
callq *%rax
movl %eax, 0xac(%rsp)
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x141dd9
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x141a48
cmpl $0x0, 0xac(%rsp)
jne 0x141e0e
movq 0xa0(%rsp), %rax
movq %rax, 0xe0(%rsp)
jmp 0x141e1a
movq $0x0, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
addq $0xe8, %rsp
retq
nopw (%rax,%rax)