// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/gtf_parser.c
// Function: construct_mRNAs
static int construct_mRNAs(GT_UNUSED void *key, void *value, void *data,
                           GtError *err)
{
  ConstructionInfo *cinfo = (ConstructionInfo*) data;
  GtArray *gt_genome_node_array = (GtArray*) value,
          *mRNAs = (GtArray*) cinfo->mRNAs;
  GtGenomeNode *mRNA_node, *first_node, *gn;
  const char *tname;
  GtStrand mRNA_strand;
  GtRange mRNA_range;
  GtStr *mRNA_seqid;
  GtUword i;
  int had_err = 0;

  gt_error_check(err);
  gt_assert(key && value && data);
   /* at least one node in array */
  gt_assert(gt_array_size(gt_genome_node_array));

  /* determine the range and the strand of the mRNA */
  first_node = *(GtGenomeNode**) gt_array_get(gt_genome_node_array, 0);
  mRNA_range = gt_genome_node_get_range(first_node);
  mRNA_strand = gt_feature_node_get_strand((GtFeatureNode*) first_node);
  mRNA_seqid = gt_genome_node_get_seqid(first_node);

  /* TODO: support discontinuous start/stop codons */
  for (i = 0; !had_err && i < gt_array_size(gt_genome_node_array); i++) {
    gn = *(GtGenomeNode**) gt_array_get(gt_genome_node_array, i);
    if (gt_feature_node_get_attribute((GtFeatureNode*) gn,
        GTF_PARSER_STOP_CODON_FLAG)) {
      GtUword j;
      GtRange stop_codon_rng = gt_genome_node_get_range(gn);
      bool found_cds = false;
      for (j = 0; !had_err && j < gt_array_size(gt_genome_node_array); j++) {
        GtGenomeNode* gn2;
        GtRange this_rng;
        const char *this_type;
        gn2 = *(GtGenomeNode**) gt_array_get(gt_genome_node_array, j);
        if (gn == gn2) continue;
        this_rng = gt_genome_node_get_range(gn2);
        this_type = gt_feature_node_get_type((GtFeatureNode*) gn2);
        if (this_type == gt_symbol(gt_ft_CDS)) {
          if (gt_range_contains(&this_rng, &stop_codon_rng)) {
            if (cinfo->tidy) {
              gt_warning("stop codon on line %u in file %s is contained in "
                         "CDS in line %u",
                         gt_genome_node_get_line_number(gn),
                         gt_genome_node_get_filename(gn),
                         gt_genome_node_get_line_number(gn2));
              found_cds = true;
            } else {
              gt_error_set(err, "stop codon on line %u in file %s is "
                                "contained in CDS in line %u",
                           gt_genome_node_get_line_number(gn),
                           gt_genome_node_get_filename(gn),
                           gt_genome_node_get_line_number(gn2));
              had_err = -1;
            }
            break;
          }
          if (this_rng.end + 1 == stop_codon_rng.start) {
            this_rng.end = stop_codon_rng.end;
            gt_genome_node_set_range(gn2, &this_rng);
            found_cds = true;
            break;
          }
          if (this_rng.start == stop_codon_rng.end + 1) {
            this_rng.start = stop_codon_rng.start;
            gt_genome_node_set_range(gn2, &this_rng);
            found_cds = true;
            break;
          }
        }
      }
      if (!found_cds) {
        if (!had_err) {
          if (cinfo->tidy) {
            gt_warning("found stop codon on line %u in file %s with no "
                       "flanking CDS, ignoring it",
                       gt_genome_node_get_line_number(gn),
                       gt_genome_node_get_filename(gn));
          } else {
            gt_error_set(err, "found stop codon on line %u in file %s with no "
                              "flanking CDS",
                         gt_genome_node_get_line_number(gn),
                         gt_genome_node_get_filename(gn));
            had_err = -1;
            break;
          }
        }
      } else {
        gt_array_rem(gt_genome_node_array, i);
        gt_genome_node_delete(gn);
      }
    }
  }

  for (i = 1; !had_err && i < gt_array_size(gt_genome_node_array); i++) {
    GtRange range;
    GtStrand strand;
    gn = *(GtGenomeNode**) gt_array_get(gt_genome_node_array, i);
    range = gt_genome_node_get_range(gn);
    mRNA_range = gt_range_join(&mRNA_range, &range);
    strand = gt_feature_node_get_strand((GtFeatureNode*) gn);
    if (strand != mRNA_strand) {
      gt_error_set(err, "feature %s on line %u has strand %c, but the "
                        "parent transcript has strand %c",
                   (const char*) key,
                   gt_genome_node_get_line_number(gn),
                   GT_STRAND_CHARS[strand],
                   GT_STRAND_CHARS[mRNA_strand]);
      had_err = -1;
      break;
    } else {
      mRNA_strand = gt_strand_join(mRNA_strand, strand);
    }
    if (!had_err && gt_str_cmp(mRNA_seqid, gt_genome_node_get_seqid(gn))) {
      gt_error_set(err, "The features on lines %u and %u refer to different "
                "genomic sequences (``seqname''), although they have the same "
                "gene IDs (``gene_id'') which must be globally unique",
                gt_genome_node_get_line_number(first_node),
                gt_genome_node_get_line_number(gn));
      had_err = -1;
      break;
    }
  }

  if (!had_err) {
    mRNA_node = gt_feature_node_new(mRNA_seqid, gt_ft_mRNA, mRNA_range.start,
                                    mRNA_range.end, mRNA_strand);
    gt_feature_node_add_attribute(((GtFeatureNode*) mRNA_node), "ID", key);
    gt_feature_node_add_attribute(((GtFeatureNode*) mRNA_node), "transcript_id",
                                  key);

    if ((tname = gt_hashmap_get(cinfo->transcript_id_to_name_mapping,
                              (const char*) key)) && strlen(tname) > 0) {
      gt_feature_node_add_attribute((GtFeatureNode*) mRNA_node, GT_GFF_NAME,
                                      tname);
    }

    /* register children */
    for (i = 0; i < gt_array_size(gt_genome_node_array); i++) {
      gn = *(GtGenomeNode**) gt_array_get(gt_genome_node_array, i);
      gt_feature_node_add_child((GtFeatureNode*) mRNA_node,
                                (GtFeatureNode*) gt_genome_node_ref(gn));
    }

    /* store the mRNA */
    gt_array_add(mRNAs, mRNA_node);
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r12
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, 0x30(%rsp)
movq 0x8(%rdx), %rbx
testq %rcx, %rcx
je 0x14dfa7
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0x14e400
testq %r15, %r15
je 0x14e3f6
testq %r14, %r14
je 0x14e3f6
movq %r12, 0x18(%rsp)
movq %r15, 0x48(%rsp)
movq %rbx, 0x60(%rsp)
movq %r14, %rdi
callq 0xd24e0
testq %rax, %rax
je 0x14e3fb
movq %r14, %rdi
xorl %esi, %esi
callq 0xd2207
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x144679
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rbx, %rdi
callq 0x1424d6
movl %eax, (%rsp)
movq %rbx, 0x58(%rsp)
movq %rbx, %rdi
callq 0x144635
movq %rax, 0x50(%rsp)
movq %r14, %rdi
callq 0xd24e0
testq %rax, %rax
je 0x14e1cb
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0xd2207
movq (%rax), %r13
movq %r13, %rdi
leaq 0x224c5c(%rip), %rsi    # 0x372c9d
callq 0x141f50
testq %rax, %rax
je 0x14e1b7
movq %r13, %rdi
callq 0x144679
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %r14, %rdi
callq 0xd24e0
testq %rax, %rax
je 0x14e105
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd2207
movq (%rax), %r12
cmpq %r12, %r13
je 0x14e0f1
movq %r12, %rdi
callq 0x144679
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %r12, %rdi
callq 0x142988
movq %rax, %rbx
leaq 0x23436e(%rip), %rdi    # 0x382419
callq 0x11c5ff
cmpq %rax, %rbx
jne 0x14e0f1
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1122f5
testb %al, %al
jne 0x14e13d
movq 0x28(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %rax
cmpq %rax, %rcx
je 0x14e186
movq 0x10(%rsp), %rcx
incq %rcx
cmpq %rcx, 0x20(%rsp)
je 0x14e192
incq %rbp
movq %r14, %rdi
callq 0xd24e0
cmpq %rax, %rbp
jb 0x14e074
movq 0x30(%rsp), %rax
movb 0x20(%rax), %bl
movq %r13, %rdi
callq 0x144626
movl %eax, %ebp
movq %r13, %rdi
callq 0x144606
cmpb $0x1, %bl
jne 0x14e341
leaq 0x234269(%rip), %rdi    # 0x382398
movl %ebp, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x11f68c
jmp 0x14e1b7
movq 0x30(%rsp), %rax
movb 0x20(%rax), %bl
movq %r13, %rdi
callq 0x144626
movl %eax, 0x4(%rsp)
movq %r13, %rdi
callq 0x144606
movq %rax, %rbp
movq %r12, %rdi
callq 0x144626
cmpb $0x1, %bl
jne 0x14e3d7
leaq 0x2341e4(%rip), %rdi    # 0x382358
movl 0x4(%rsp), %esi
movq %rbp, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x11f68c
jmp 0x14e1a4
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x14e197
movq %rax, 0x20(%rsp)
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1446da
movq %r14, %rdi
movq %r15, %rsi
callq 0xd2266
movq %r13, %rdi
callq 0x1451a0
incq %r15
movq %r14, %rdi
callq 0xd24e0
cmpq %rax, %r15
jb 0x14e029
movq %r14, %rdi
callq 0xd24e0
cmpq $0x2, %rax
jb 0x14e26b
movl $0x1, %ebx
leaq 0x38(%rsp), %r15
leaq 0x8(%rsp), %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd2207
movq (%rax), %r13
movq %r13, %rdi
callq 0x144679
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x112343
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %r13, %rdi
callq 0x1424d6
movl (%rsp), %esi
cmpl %esi, %eax
jne 0x14e35b
movl %esi, %edi
callq 0x11c208
movl %eax, (%rsp)
movq %r13, %rdi
callq 0x144635
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x11b146
testl %eax, %eax
jne 0x14e398
incq %rbx
movq %r14, %rdi
callq 0xd24e0
cmpq %rax, %rbx
jb 0x14e1ec
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
leaq 0x22c725(%rip), %rsi    # 0x37a9a1
movq 0x50(%rsp), %rdi
movl (%rsp), %r8d
callq 0x1422f4
movq %rax, %rbx
movq %rax, 0x8(%rsp)
leaq 0x28c37e(%rip), %rsi    # 0x3da617
movq %rax, %rdi
movq 0x48(%rsp), %r15
movq %r15, %rdx
callq 0x14329d
leaq 0x233f14(%rip), %rsi    # 0x3821c4
movq %rbx, %rdi
movq %r15, %rdx
callq 0x14329d
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r15, %rsi
callq 0x100add
testq %rax, %rax
je 0x14e2e8
cmpb $0x0, (%rax)
je 0x14e2e8
leaq 0x253e11(%rip), %rsi    # 0x3a20ee
movq %rbx, %rdi
movq %rax, %rdx
callq 0x14329d
movq %r14, %rdi
callq 0xd24e0
testq %rax, %rax
je 0x14e326
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0xd2207
movq (%rax), %rdi
callq 0x1443a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x14275f
incq %r15
movq %r14, %rdi
callq 0xd24e0
cmpq %rax, %r15
jb 0x14e2f8
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq 0x60(%rsp), %rdi
callq 0xd2410
xorl %eax, %eax
jmp 0x14e3c8
leaq 0x234099(%rip), %rsi    # 0x3823e1
movq 0x18(%rsp), %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xfcb67
jmp 0x14e3c3
movl %eax, %ebp
movq %r13, %rdi
movl %esi, %ebx
callq 0x144626
movl %ebp, %ecx
leaq 0x21f6c4(%rip), %rdx    # 0x36da34
movsbl (%rcx,%rdx), %r8d
movl %ebx, %ecx
movsbl (%rcx,%rdx), %r9d
leaq 0x23409a(%rip), %rsi    # 0x38241d
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xfcb67
jmp 0x14e3c3
movq 0x58(%rsp), %rdi
callq 0x144626
movl %eax, %ebx
movq %r13, %rdi
callq 0x144626
leaq 0x2340b7(%rip), %rsi    # 0x38246a
movq 0x18(%rsp), %rdi
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x233f7a(%rip), %rsi    # 0x382358
movq 0x18(%rsp), %rdi
movl 0x4(%rsp), %edx
movq %rbp, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0xfcb67
jmp 0x14e3c3
callq 0x46d88
callq 0x46dc1
callq 0x46d4f