// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/csa_visitor.c
// Function: add_sa_to_exon_feature_array
static void add_sa_to_exon_feature_array(GtArray *exon_nodes,
                                         GtFeatureNode *sa,
                                         GtStr *seqid,
                                         GtStr *gt_csa_source_str,
                                         GtStrand gene_strand)
{
  GtArray *exons_from_sa;
  GtUword i,
                exon_feature_index = 0,
                exons_from_sa_index = 0;
  GtFeatureNode *exon_feature, *exons_from_sa_feature;
  GtGenomeNode *new_feature;
  GtRange exon_feature_range, exons_from_sa_range;

  gt_assert(exon_nodes && sa);
  gt_assert(gene_strand != GT_STRAND_BOTH); /* is defined */

  exons_from_sa = gt_array_new(sizeof (GtFeatureNode*));
  gt_feature_node_get_exons(sa, exons_from_sa);
  gt_genome_nodes_sort(exons_from_sa);

  while (exon_feature_index < gt_array_size(exon_nodes) &&
         exons_from_sa_index < gt_array_size(exons_from_sa)) {
    exon_feature = *(GtFeatureNode**)
                   gt_array_get(exon_nodes, exon_feature_index);
    exons_from_sa_feature = *(GtFeatureNode**)
                            gt_array_get(exons_from_sa, exons_from_sa_index);

    exon_feature_range = gt_genome_node_get_range((GtGenomeNode*)
                                                  exon_feature);
    exons_from_sa_range =
      gt_genome_node_get_range((GtGenomeNode*) exons_from_sa_feature);

    switch (gt_range_compare(&exon_feature_range, &exons_from_sa_range)) {
      case -1:
        if (gt_range_overlap(&exon_feature_range, &exons_from_sa_range)) {
          if (!gt_range_contains(&exon_feature_range, &exons_from_sa_range)) {
            gt_assert(gt_genome_node_get_start((GtGenomeNode*) exon_feature) <=
              gt_genome_node_get_start((GtGenomeNode*) exons_from_sa_feature));
            gt_assert(gt_genome_node_get_end((GtGenomeNode*) exon_feature) <
                gt_genome_node_get_end((GtGenomeNode*) exons_from_sa_feature));
            /* update right border and score */
            gt_feature_node_set_end(exon_feature,
                                   gt_genome_node_get_end((GtGenomeNode*)
                                                       exons_from_sa_feature));
            if (gt_feature_node_score_is_defined(exons_from_sa_feature)) {
              gt_feature_node_set_score(exon_feature,
                            gt_feature_node_get_score(exons_from_sa_feature));
            }
          }
          exons_from_sa_index++;
        }
        exon_feature_index++;
        break;
      case 0:
        gt_assert(gt_range_overlap(&exon_feature_range, &exons_from_sa_range));
        /* update score if necessary */
        if ((gt_feature_node_score_is_defined(exon_feature) &&
             gt_feature_node_score_is_defined(exons_from_sa_feature) &&
             gt_feature_node_get_score(exon_feature) <
             gt_feature_node_get_score(exons_from_sa_feature)) ||
            (!gt_feature_node_score_is_defined(exon_feature) &&
             gt_feature_node_score_is_defined(exons_from_sa_feature))) {
          gt_feature_node_set_score(exon_feature,
                            gt_feature_node_get_score(exons_from_sa_feature));
        }
        exon_feature_index++;
        exons_from_sa_index++;
        break;
      case 1:
        gt_assert(gt_range_overlap(&exon_feature_range, &exons_from_sa_range));
        gt_assert(gt_genome_node_get_start((GtGenomeNode*) exon_feature) <=
              gt_genome_node_get_start((GtGenomeNode*) exons_from_sa_feature));
        /* update right border and score, if necessary */
        if (gt_genome_node_get_end((GtGenomeNode*) exons_from_sa_feature) >
            gt_genome_node_get_end((GtGenomeNode*) exon_feature)) {
          gt_feature_node_set_end(exon_feature,
                                 gt_genome_node_get_end((GtGenomeNode*)
                                                     exons_from_sa_feature));
          if (gt_feature_node_score_is_defined(exons_from_sa_feature)) {
            gt_feature_node_set_score(exon_feature,
                            gt_feature_node_get_score(exons_from_sa_feature));
          }
        }
        exon_feature_index++;
        exons_from_sa_index++;
        break;
      default: gt_assert(0);
    }
  }

  /* add remaining exons */
  for (i = exons_from_sa_index; i < gt_array_size(exons_from_sa); i++) {
    GtRange range;
    exons_from_sa_feature = *(GtFeatureNode**)
                            gt_array_get(exons_from_sa, i);
    range = gt_genome_node_get_range((GtGenomeNode*) exons_from_sa_feature),
    new_feature = gt_feature_node_new(seqid, gt_ft_exon, range.start, range.end,
                                      gene_strand);
    if (gt_feature_node_score_is_defined(exons_from_sa_feature)) {
      gt_feature_node_set_score((GtFeatureNode*) new_feature,
                            gt_feature_node_get_score(exons_from_sa_feature));
    }
    gt_feature_node_set_source((GtFeatureNode*) new_feature, gt_csa_source_str);
    gt_array_add(exon_nodes, new_feature);
  }

  gt_array_delete(exons_from_sa);
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movq %rdx, 0x130(%rsp)
movq %rcx, 0x128(%rsp)
movl %r8d, 0x124(%rsp)
movq $0x0, 0x108(%rsp)
movq $0x0, 0x100(%rsp)
cmpq $0x0, 0x140(%rsp)
je 0x14ff9d
cmpq $0x0, 0x138(%rsp)
jne 0x14ffd5
movq 0x64034(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xe0b8(%rip), %rsi      # 0x15e066
leaq 0x3e4ac(%rip), %rdx     # 0x18e461
leaq 0x3e4b6(%rip), %rcx     # 0x18e472
leaq 0x3e228(%rip), %r8      # 0x18e1eb
movl $0xf8, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x14ffd7
jmp 0x14ffd9
cmpl $0x2, 0x124(%rsp)
jne 0x15001b
movq 0x63fee(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xe072(%rip), %rsi      # 0x15e066
leaq 0x3e494(%rip), %rdx     # 0x18e48f
leaq 0x3e470(%rip), %rcx     # 0x18e472
leaq 0x3e1e2(%rip), %r8      # 0x18e1eb
movl $0xf9, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x15001d
movl $0x8, %edi
callq 0x75ab0
movq %rax, 0x118(%rsp)
movq 0x138(%rsp), %rdi
movq 0x118(%rsp), %rsi
callq 0x21fc0
movq 0x118(%rsp), %rdi
callq 0x26020
movq 0x108(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x140(%rsp), %rdi
callq 0x76490
movq 0x70(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x7f(%rsp)
jae 0x1500aa
movq 0x100(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x118(%rsp), %rdi
callq 0x76490
movq %rax, %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x7f(%rsp)
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x1500b7
jmp 0x1505f8
movq 0x140(%rsp), %rdi
movq 0x108(%rsp), %rsi
callq 0x75c80
movq (%rax), %rax
movq %rax, 0xf8(%rsp)
movq 0x118(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x75c80
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x259f0
movq %rax, 0xb0(%rsp)
movq %rdx, 0xb8(%rsp)
movups 0xb0(%rsp), %xmm0
movaps %xmm0, 0xd0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x259f0
movq %rax, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
movups 0xa0(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x93850
movl %eax, %ecx
movl %ecx, 0x64(%rsp)
subl $-0x1, %eax
je 0x150193
jmp 0x150173
movl 0x64(%rsp), %eax
testl %eax, %eax
je 0x15032b
jmp 0x150181
movl 0x64(%rsp), %eax
subl $0x1, %eax
je 0x150446
jmp 0x1505b9
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x93c40
testb $0x1, %al
jne 0x1501b1
jmp 0x150312
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x93ea0
testb $0x1, %al
jne 0x1502fe
jmp 0x1501d0
movq 0xf8(%rsp), %rdi
callq 0x259c0
movq %rax, 0x58(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x259c0
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jbe 0x150234
movq 0x63dd5(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xde59(%rip), %rsi      # 0x15e066
leaq 0x3e299(%rip), %rdx     # 0x18e4ad
leaq 0x3e257(%rip), %rcx     # 0x18e472
leaq 0x3dfc9(%rip), %r8      # 0x18e1eb
movl $0x110, %r9d            # imm = 0x110
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x150236
jmp 0x150238
movq 0xf8(%rsp), %rdi
callq 0x25a80
movq %rax, 0x50(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x25a80
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jb 0x15029c
movq 0x63d6d(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xddf1(%rip), %rsi      # 0x15e066
leaq 0x3e2ab(%rip), %rdx     # 0x18e527
leaq 0x3e1ef(%rip), %rcx     # 0x18e472
leaq 0x3df61(%rip), %r8      # 0x18e1eb
movl $0x112, %r9d            # imm = 0x112
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x15029e
movq 0xf8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x25a80
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x228f0
movq 0xf0(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x1502d8
jmp 0x1502fc
movq 0xf8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x21d30
movq 0x40(%rsp), %rdi
callq 0x21330
jmp 0x1502fe
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
jmp 0x1505f3
jmp 0x15032d
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x93c40
testb $0x1, %al
jne 0x15037e
movq 0x63c8b(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xdd0f(%rip), %rsi      # 0x15e066
leaq 0x3e23e(%rip), %rdx     # 0x18e59c
leaq 0x3e10d(%rip), %rcx     # 0x18e472
leaq 0x3de7f(%rip), %r8      # 0x18e1eb
movl $0x121, %r9d            # imm = 0x121
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x150380
movq 0xf8(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x150393
jmp 0x1503d1
movq 0xf0(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x1503a6
jmp 0x1503d1
movq 0xf8(%rsp), %rdi
callq 0x21d30
movss %xmm0, 0x3c(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x21d30
movss 0x3c(%rsp), %xmm1
ucomiss %xmm1, %xmm0
ja 0x1503f5
movq 0xf8(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x150419
movq 0xf0(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x1503f5
jmp 0x150419
movq 0xf8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x21d30
movq 0x30(%rsp), %rdi
callq 0x21330
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x1505f3
jmp 0x150448
leaq 0xd0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x93c40
testb $0x1, %al
jne 0x150499
movq 0x63b70(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xdbf4(%rip), %rsi      # 0x15e066
leaq 0x3e123(%rip), %rdx     # 0x18e59c
leaq 0x3dff2(%rip), %rcx     # 0x18e472
leaq 0x3dd64(%rip), %r8      # 0x18e1eb
movl $0x130, %r9d            # imm = 0x130
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x15049b
jmp 0x15049d
movq 0xf8(%rsp), %rdi
callq 0x259c0
movq %rax, 0x28(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x259c0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jbe 0x150501
movq 0x63b08(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xdb8c(%rip), %rsi      # 0x15e066
leaq 0x3dfcc(%rip), %rdx     # 0x18e4ad
leaq 0x3df8a(%rip), %rcx     # 0x18e472
leaq 0x3dcfc(%rip), %r8      # 0x18e1eb
movl $0x132, %r9d            # imm = 0x132
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x150503
movq 0xf0(%rsp), %rdi
callq 0x25a80
movq %rax, 0x20(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x25a80
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jbe 0x15058f
movq 0xf8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x25a80
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x228f0
movq 0xf0(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x150569
jmp 0x15058d
movq 0xf8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x21d30
movq 0x10(%rsp), %rdi
callq 0x21330
jmp 0x15058f
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
movq 0x100(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x100(%rsp)
jmp 0x1505f3
jmp 0x1505bb
movq 0x63a16(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0xda9a(%rip), %rsi      # 0x15e066
leaq 0x1f8e8(%rip), %rdx     # 0x16febb
leaq 0x3de98(%rip), %rcx     # 0x18e472
leaq 0x3dc0a(%rip), %r8      # 0x18e1eb
movl $0x141, %r9d            # imm = 0x141
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0x150051
movq 0x100(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x118(%rsp), %rdi
callq 0x76490
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x150741
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %rsi
callq 0x75c80
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x259f0
movq %rax, 0x80(%rsp)
movq %rdx, 0x88(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x130(%rsp), %rdi
movq 0x90(%rsp), %rdx
movq 0x98(%rsp), %rcx
movl 0x124(%rsp), %r8d
leaq 0x2a6ff(%rip), %rsi     # 0x17adb6
callq 0x20580
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x212b0
testb $0x1, %al
jne 0x1506d7
jmp 0x1506f9
movq 0xe8(%rsp), %rax
movq %rax, (%rsp)
movq 0xf0(%rsp), %rdi
callq 0x21d30
movq (%rsp), %rdi
callq 0x21330
movq 0xe8(%rsp), %rdi
movq 0x128(%rsp), %rsi
callq 0x1ff10
movq 0x140(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
movl $0x8, %edx
callq 0x76220
movq 0x110(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x110(%rsp)
jmp 0x150608
movq 0x118(%rsp), %rdi
callq 0x770a0
addq $0x148, %rsp            # imm = 0x148
retq
nopw %cs:(%rax,%rax)