// File: /workspace/github_c_makefile_star2_O2/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 0xe8e8b
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0xe931c
testq %r15, %r15
je 0xe92c0
testq %r14, %r14
je 0xe92c0
movq %r12, 0x18(%rsp)
movq %r15, 0x48(%rsp)
movq %r14, %rdi
callq 0x586a4
testq %rax, %rax
je 0xe92ee
movq %rbx, 0x60(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x581aa
movq (%rax), %rbx
movq %rbx, %rdi
callq 0xdd1f4
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rbx, %rdi
callq 0xd9d99
movl %eax, (%rsp)
movq %rbx, 0x58(%rsp)
movq %rbx, %rdi
callq 0xdd14a
movq %rax, 0x50(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
testl %ebx, %ebx
sete %bl
jne 0xe90e3
movq %r14, %rdi
callq 0x586a4
cmpq %rax, %r12
jae 0xe90e3
movq %r14, %rdi
movq %r12, %rsi
callq 0x581aa
movq (%rax), %r15
movq %r15, %rdi
leaq 0x22a07b(%rip), %rsi    # 0x312fad
callq 0xd9628
xorl %ebx, %ebx
testq %rax, %rax
je 0xe909f
movq %r15, %rdi
callq 0xdd1f4
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x586a4
cmpq %rax, %r13
jae 0xe8fed
movq %r14, %rdi
movq %r13, %rsi
callq 0x581aa
movq (%rax), %rbp
cmpq %rbp, %r15
je 0xe8fe5
movq %rbp, %rdi
callq 0xdd1f4
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %rbp, %rdi
callq 0xda338
movq %rax, %rbx
leaq 0x239886(%rip), %rdi    # 0x322825
callq 0xaed4b
cmpq %rax, %rbx
jne 0xe8fe5
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa3345
testb %al, %al
jne 0xe9027
movq 0x28(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %rax
cmpq %rax, %rcx
je 0xe906c
movq 0x10(%rsp), %rcx
incq %rcx
cmpq %rcx, 0x20(%rsp)
je 0xe9078
incq %r13
jmp 0xe8f57
movq 0x30(%rsp), %rax
movb 0x20(%rax), %bl
movq %r15, %rdi
callq 0xdd108
movl %eax, %ebp
movq %r15, %rdi
callq 0xdd0b5
cmpb $0x1, %bl
jne 0xe90c9
xorl %ebx, %ebx
leaq 0x23978b(%rip), %rdi    # 0x3227a4
movl %ebp, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0xb2cd0
jmp 0xe909f
movq 0x30(%rsp), %rax
movb 0x20(%rax), %bl
movq %r15, %rdi
callq 0xdd108
movl %eax, 0x4(%rsp)
movq %r15, %rdi
callq 0xdd0b5
movq %rax, %r13
movq %rbp, %rdi
callq 0xdd108
cmpb $0x1, %bl
jne 0xe90a7
leaq 0x23970a(%rip), %rdi    # 0x322764
movl 0x4(%rsp), %esi
movq %r13, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xb2cd0
jmp 0xe908a
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0xe907d
movq %rax, 0x20(%rsp)
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0xdd2bb
movq %r14, %rdi
movq %r12, %rsi
callq 0x5829c
movq %r15, %rdi
callq 0xde013
xorl %ebx, %ebx
incq %r12
jmp 0xe8efe
movq 0x18(%rsp), %rdi
leaq 0x2396b1(%rip), %rsi    # 0x322764
movl 0x4(%rsp), %edx
movq %r13, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rbx
jmp 0xe909f
leaq 0x23971d(%rip), %rsi    # 0x3227ed
xorl %ebx, %ebx
movq 0x18(%rsp), %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x89dbb
pushq $0x1
popq %r15
leaq 0x38(%rsp), %r12
leaq 0x8(%rsp), %r13
testb $0x1, %bl
je 0xe92ae
movq %r14, %rdi
callq 0x586a4
cmpq %rax, %r15
jae 0xe9180
movq %r14, %rdi
movq %r15, %rsi
callq 0x581aa
movq (%rax), %rbp
movq %rbp, %rdi
callq 0xdd1f4
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xa33f9
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rbp, %rdi
callq 0xd9d99
movl (%rsp), %esi
cmpl %esi, %eax
jne 0xe9246
movl %esi, %edi
callq 0xae73c
movl %eax, (%rsp)
movq %rbp, %rdi
callq 0xdd14a
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0xad39b
testl %eax, %eax
jne 0xe9283
incq %r15
movb $0x1, %bl
jmp 0xe90f1
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
leaq 0x231b5e(%rip), %rsi    # 0x31acef
movq 0x50(%rsp), %rdi
movl (%rsp), %r8d
callq 0xd9acb
movq %rax, %rbx
movq %rax, 0x8(%rsp)
leaq 0x291889(%rip), %rsi    # 0x37aa37
movq %rax, %rdi
movq 0x48(%rsp), %r15
movq %r15, %rdx
callq 0xdb38d
leaq 0x23940b(%rip), %rsi    # 0x3225d0
movq %rbx, %rdi
movq %r15, %rdx
callq 0xdb38d
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r15, %rsi
callq 0x8f482
testq %rax, %rax
je 0xe91fd
cmpb $0x0, (%rax)
je 0xe91fd
leaq 0x2591ec(%rip), %rsi    # 0x3423de
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdb38d
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x586a4
cmpq %rax, %r15
jae 0xe9230
movq %r14, %rdi
movq %r15, %rsi
callq 0x581aa
movq (%rax), %rdi
callq 0xdccf8
movq %rbx, %rdi
movq %rax, %rsi
callq 0xda055
incq %r15
jmp 0xe9200
leaq 0x8(%rsp), %rsi
pushq $0x8
popq %rdx
movq 0x60(%rsp), %rdi
callq 0x5851d
xorl %eax, %eax
jmp 0xe92b1
movl %eax, %ebx
movq %rbp, %rdi
movl %esi, %ebp
callq 0xdd108
movl %ebx, %ecx
leaq 0x224af9(%rip), %rdx    # 0x30dd54
movsbl (%rcx,%rdx), %r8d
movl %ebp, %ecx
movsbl (%rcx,%rdx), %r9d
leaq 0x2395bb(%rip), %rsi    # 0x322829
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x89dbb
jmp 0xe92ae
movq 0x58(%rsp), %rdi
callq 0xdd108
movl %eax, %ebx
movq %rbp, %rdi
callq 0xdd108
leaq 0x2395d8(%rip), %rsi    # 0x322876
movq 0x18(%rsp), %rdi
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34eca1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1fbd42(%rip), %rsi    # 0x2e5013
leaq 0x221098(%rip), %rdx    # 0x30a370
leaq 0x239451(%rip), %rcx    # 0x322730
leaq 0x23913a(%rip), %r8     # 0x322420
movl $0x82, %r9d
jmp 0xe9348
movq 0x34ec73(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1fbd14(%rip), %rsi    # 0x2e5013
leaq 0x23943a(%rip), %rdx    # 0x322740
leaq 0x239423(%rip), %rcx    # 0x322730
leaq 0x23910c(%rip), %r8     # 0x322420
movl $0x84, %r9d
jmp 0xe9348
movq 0x34ec45(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1fbce6(%rip), %rsi    # 0x2e5013
leaq 0x1fbe8b(%rip), %rdx    # 0x2e51bf
leaq 0x2393f5(%rip), %rcx    # 0x322730
leaq 0x2390de(%rip), %r8     # 0x322420
movl $0x81, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390