// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/consensus_sa.c
// Function: compatible
static bool compatible(const ConsensusSA *csa,
                       GtUword sa_1, GtUword sa_2)
{
  GtArray *exons_sa_1, *exons_sa_2;
  GtRange range_sa_1, range_sa_2;
  GtUword i, j, num_of_exons_1, num_of_exons_2,
                start_1 = GT_UNDEF_UWORD, start_2 = GT_UNDEF_UWORD;
  bool start_values_set = false;
  const GtUword fuzzlength = 0; /* XXX */

  gt_assert(csa);

  /* check strands */
  if (extract_strand(csa, sa_1) != extract_strand(csa, sa_2)) return false;

  /* init */
  exons_sa_1 = gt_array_new(sizeof (GtRange));
  exons_sa_2 = gt_array_new(sizeof (GtRange));

  /* get ranges */
  range_sa_1 = extract_genomic_range(csa, sa_1);
  range_sa_2 = extract_genomic_range(csa, sa_2);

  if (!gt_range_overlap(&range_sa_1, &range_sa_2)) {
    gt_array_delete(exons_sa_1);
    gt_array_delete(exons_sa_2);
    return false;
  }

  /* get exons */
  extract_exons(csa, exons_sa_1, sa_1);
  extract_exons(csa, exons_sa_2, sa_2);

  /* determine the first overlapping exon pair */
  i = 0;
  j = 0;
  num_of_exons_1 = gt_array_size(exons_sa_1);
  num_of_exons_2 = gt_array_size(exons_sa_2);
  while (i < num_of_exons_1 && j < num_of_exons_2) {
    if (gt_range_overlap(gt_array_get(exons_sa_1, i),
                         gt_array_get(exons_sa_2, j))) {
      start_1 = i;
      start_2 = j;
      start_values_set = true;
      break;
    }
    if (((GtRange*) gt_array_get(exons_sa_1, i))->start <
        ((GtRange*) gt_array_get(exons_sa_2, j))->start) {
      i++;
    }
    else
      j++;
  }
  if (!start_values_set) {
    gt_array_delete(exons_sa_1);
    gt_array_delete(exons_sa_2);
    return false;
  }
  /* from now on the start values are set */

  gt_assert(start_1 != GT_UNDEF_UWORD && start_2 != GT_UNDEF_UWORD);
  if (!(start_1 == 0 || start_2 == 0)) {
    /* no first segment could be maped */
    gt_array_delete(exons_sa_1);
    gt_array_delete(exons_sa_2);
    return false;
  }

  while (start_1 < num_of_exons_1 && start_2 < num_of_exons_2) {
    range_sa_1 = *((GtRange*) gt_array_get(exons_sa_1, start_1));
    range_sa_2 = *((GtRange*) gt_array_get(exons_sa_2, start_2));

    if (gt_range_overlap(&range_sa_1, &range_sa_2)) {
      /* analyze acceptor sites */

      /* see if at least one exon has a acceptor site (on the left).
         in this case additional checks have to be performed.
         Otherwise, this exons are compatible (on the left side)
         because they overlap */
      if (has_acceptor_site(exons_sa_1, start_1) ||
          has_acceptor_site(exons_sa_2, start_2)) {
        if (has_acceptor_site(exons_sa_1, start_1) &&
            has_acceptor_site(exons_sa_2, start_2) &&
            range_sa_1.start!= range_sa_2.start) {
          /* the acceptor sites are different */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
        else if (has_acceptor_site(exons_sa_1, start_1) &&
                 range_sa_2.start + fuzzlength < range_sa_1.start) {
          /* not within fuzzlength */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
        else if (has_acceptor_site(exons_sa_2, start_2) &&
                 range_sa_1.start + fuzzlength < range_sa_2.start) {
          /* not within fuzzlength */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
      }
      /* analyze donor sites */

      /* see if at least one exon has a donor site (on the right).
         in this case additional checks have to be performed.
         Otherwise, this exons are compatible (on the right side)
         because they overlap */
      if (has_donor_site(exons_sa_1, start_1) ||
          has_donor_site(exons_sa_2, start_2)) {
        if (has_donor_site(exons_sa_1, start_1) &&
            has_donor_site(exons_sa_2, start_2) &&
            range_sa_1.end != range_sa_2.end) {
          /* the donor sites are different */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
        else if (has_donor_site(exons_sa_1, start_1) &&
                 range_sa_2.end - fuzzlength > range_sa_1.end) {
          /* not within fuzzlength */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
        else if (has_donor_site(exons_sa_2, start_2) &&
                 range_sa_1.end - fuzzlength > range_sa_2.end) {
          /* not within fuzzlength */
          gt_array_delete(exons_sa_1);
          gt_array_delete(exons_sa_2);
          return false;
        }
      }
    }
    else {
      /* no overlap: two ordered segments do not overlap each other */
      gt_array_delete(exons_sa_1);
      gt_array_delete(exons_sa_2);
      return false;
    }
    start_1++;
    start_2++;
  }

  /* passed all tests */
  gt_array_delete(exons_sa_1);
  gt_array_delete(exons_sa_2);
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
callq 0xe07ad
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0xe07ad
cmpl %eax, %ebx
jne 0xe05f9
movl $0x10, %edi
callq 0x6ef7c
movq %rax, %rbx
movl $0x10, %edi
callq 0x6ef7c
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0xe0492
leaq 0x10(%rsp), %rbp
movq %rax, (%rbp)
movq %rdx, 0x8(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0xe0492
movq %rsp, %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rbp, %rdi
callq 0x7e1b2
testb %al, %al
je 0xe078a
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xe07db
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xe07db
movq %rbx, %rdi
callq 0x6f310
movq %rax, %r15
movq %r14, %rdi
callq 0x6f310
movq %rax, %r12
movq %r15, 0x20(%rsp)
testq %r15, %r15
setne %al
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xe078a
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6f037
movq %rax, %rbp
movq %r14, %rdi
movq %r15, %rsi
callq 0x6f037
movq %rbp, %rdi
movq %rax, %rsi
callq 0x7e1b2
testb %al, %al
jne 0xe0600
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6f037
movq (%rax), %rbp
movq %r14, %rdi
movq %r15, %rsi
callq 0x6f037
movq (%rax), %rax
cmpq %rax, %rbp
sbbq $-0x1, %r15
cmpq %rax, %rbp
adcq $0x0, %r13
xorl %ebp, %ebp
cmpq 0x20(%rsp), %r13
jae 0xe078c
cmpq %r12, %r15
jb 0xe0590
jmp 0xe078c
xorl %ebp, %ebp
jmp 0xe079c
testq %r13, %r13
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xe078a
cmpq 0x20(%rsp), %r13
setb %al
cmpq %r12, %r15
setb %cl
andb %al, %cl
movb $0x1, %bpl
cmpb $0x1, %cl
jne 0xe078c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6f037
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6f037
movups (%rax), %xmm0
movaps %xmm0, (%rsp)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x7e1b2
testb %al, %al
je 0xe078a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe082d
testb %al, %al
jne 0xe068b
movq %r14, %rdi
movq %r15, %rsi
callq 0xe082d
testb %al, %al
je 0xe06f4
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe082d
testb %al, %al
je 0xe06b8
movq %r14, %rdi
movq %r15, %rsi
callq 0xe082d
testb %al, %al
je 0xe06b8
movq 0x10(%rsp), %rax
cmpq (%rsp), %rax
jne 0xe078a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe082d
testb %al, %al
je 0xe06d6
movq (%rsp), %rax
cmpq 0x10(%rsp), %rax
jb 0xe078a
movq %r14, %rdi
movq %r15, %rsi
callq 0xe082d
testb %al, %al
je 0xe06f4
movq 0x10(%rsp), %rax
cmpq (%rsp), %rax
jb 0xe078a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe0848
testb %al, %al
jne 0xe0712
movq %r14, %rdi
movq %r15, %rsi
callq 0xe0848
testb %al, %al
je 0xe0772
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe0848
testb %al, %al
je 0xe073c
movq %r14, %rdi
movq %r15, %rsi
callq 0xe0848
testb %al, %al
je 0xe073c
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0xe078a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe0848
testb %al, %al
je 0xe0757
movq 0x8(%rsp), %rax
cmpq 0x18(%rsp), %rax
ja 0xe078a
movq %r14, %rdi
movq %r15, %rsi
callq 0xe0848
testb %al, %al
je 0xe0772
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
ja 0xe078a
incq %r13
cmpq 0x20(%rsp), %r13
jae 0xe078c
incq %r15
cmpq %r12, %r15
jb 0xe0633
jmp 0xe078c
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x6f768
movq %r14, %rdi
callq 0x6f768
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq