// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
callq 0xe019a
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0xe019a
cmpl %eax, %ebx
jne 0xdffac
movl $0x10, %edi
callq 0x6e93c
movq %rax, %rbx
movl $0x10, %edi
callq 0x6e93c
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0xdfe0e
leaq 0x10(%rsp), %rbp
movq %rax, (%rbp)
movq %rdx, 0x8(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0xdfe0e
movq %rsp, %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rbp, %rdi
callq 0x7e06e
testb %al, %al
je 0xe0170
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xe01c8
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xe01c8
movq %rbx, %rdi
callq 0x6ecda
movq %rax, %r15
movq %r14, %rdi
callq 0x6ecda
movq %r15, 0x30(%rsp)
testq %r15, %r15
setne %cl
movq %rax, 0x28(%rsp)
testq %rax, %rax
setne %r12b
andb %cl, %r12b
cmpb $0x1, %r12b
jne 0xdffb4
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6e9fa
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
callq 0x6e9fa
movq %r15, %rdi
movq %rax, %rsi
callq 0x7e06e
movl $0x0, %ebp
testb %al, %al
jne 0xdffc2
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x6e9fa
movq (%rax), %r15
movq %r14, %rdi
movq %r13, %rsi
callq 0x6e9fa
movq (%rax), %rax
cmpq %rax, %r15
sbbq $-0x1, %r13
cmpq %rax, %r15
adcq $0x0, %rbp
cmpq 0x30(%rsp), %rbp
setb %al
cmpq 0x28(%rsp), %r13
setb %r12b
andb %al, %r12b
je 0xdffb4
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x6e9fa
movq %rax, %r15
movq %r14, %rdi
movq %r13, %rsi
callq 0x6e9fa
movq %r15, %rdi
movq %rax, %rsi
callq 0x7e06e
testb %al, %al
je 0xdff42
jmp 0xdffc2
xorl %r15d, %r15d
jmp 0xe0183
movq $-0x1, %r13
movq $-0x1, %rbp
testb %r12b, %r12b
je 0xe0170
cmpq $-0x1, %rbp
je 0xe0195
cmpq $-0x1, %r13
je 0xe0195
testq %rbp, %rbp
sete %al
testq %r13, %r13
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xe0170
cmpq 0x30(%rsp), %rbp
setb %al
cmpq 0x28(%rsp), %r13
setb %cl
andb %al, %cl
movb $0x1, %r15b
cmpb $0x1, %cl
jne 0xe0173
leaq 0x10(%rsp), %r12
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x6e9fa
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x6e9fa
movups (%rax), %xmm0
movaps %xmm0, (%rsp)
movq %r12, %rdi
movq %rsp, %rsi
callq 0x7e06e
testb %al, %al
je 0xe0170
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe021a
testb %al, %al
jne 0xe006f
movq %r14, %rdi
movq %r13, %rsi
callq 0xe021a
testb %al, %al
je 0xe00d8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe021a
testb %al, %al
je 0xe009c
movq %r14, %rdi
movq %r13, %rsi
callq 0xe021a
testb %al, %al
je 0xe009c
movq 0x10(%rsp), %rax
cmpq (%rsp), %rax
jne 0xe0170
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe021a
testb %al, %al
je 0xe00ba
movq (%rsp), %rax
cmpq 0x10(%rsp), %rax
jb 0xe0170
movq %r14, %rdi
movq %r13, %rsi
callq 0xe021a
testb %al, %al
je 0xe00d8
movq 0x10(%rsp), %rax
cmpq (%rsp), %rax
jb 0xe0170
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe0235
testb %al, %al
jne 0xe00f6
movq %r14, %rdi
movq %r13, %rsi
callq 0xe0235
testb %al, %al
je 0xe0156
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe0235
testb %al, %al
je 0xe0120
movq %r14, %rdi
movq %r13, %rsi
callq 0xe0235
testb %al, %al
je 0xe0120
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0xe0170
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe0235
testb %al, %al
je 0xe013b
movq 0x8(%rsp), %rax
cmpq 0x18(%rsp), %rax
ja 0xe0170
movq %r14, %rdi
movq %r13, %rsi
callq 0xe0235
testb %al, %al
je 0xe0156
movq 0x18(%rsp), %rax
cmpq 0x8(%rsp), %rax
ja 0xe0170
incq %rbp
cmpq 0x30(%rsp), %rbp
jae 0xe0173
incq %r13
cmpq 0x28(%rsp), %r13
jb 0xe0019
jmp 0xe0173
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x6f134
movq %r14, %rdi
callq 0x6f134
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x35028