// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movq %rsi, %rbx
movq %rdi, 0x50(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x8(%rdx), %rax
movq %rax, 0x70(%rsp)
testq %rcx, %rcx
je 0x155750
movq %rcx, %rdi
movq %rcx, %r14
callq 0x101a9a
movq %r14, %rcx
testb %al, %al
jne 0x155c9b
movq %rcx, 0x30(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x155c91
testq %rbx, %rbx
je 0x155c91
cmpq $0x0, 0x38(%rsp)
je 0x155c91
movq %rbx, %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x155c96
movq %rbx, %rdi
xorl %esi, %esi
callq 0xd47ba
movq (%rax), %r14
movq %r14, %rdi
callq 0x14b8df
movq %rax, 0x58(%rsp)
movq %rdx, 0x60(%rsp)
movq %r14, %rdi
callq 0x14970e
movl %eax, 0x14(%rsp)
movq %r14, 0x78(%rsp)
movq %r14, %rdi
callq 0x14b89b
movq %rax, 0x68(%rsp)
xorl %r15d, %r15d
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0xd4a9a
cmpq %rax, %r15
jae 0x155a56
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd47ba
movq (%rax), %r12
movq %r12, %rdi
leaq 0x226728(%rip), %rsi    # 0x37bf1d
callq 0x14918c
testq %rax, %rax
je 0x155999
movq %r15, 0x80(%rsp)
movq %r12, %rdi
callq 0x14b8df
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
movq %rbx, %rdi
callq 0xd4a9a
cmpq %rax, %r13
jae 0x1559a1
movq %rbx, %rdi
movq %r13, %rsi
callq 0xd47ba
movq (%rax), %rbp
movb $0x1, %r14b
cmpq %rbp, %r12
je 0x15588a
movq %rbp, %rdi
callq 0x14b8df
movq %rax, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq %rbp, %rdi
callq 0x149bb2
movq %rax, %rbx
leaq 0x235f68(%rip), %rdi    # 0x38b7dc
callq 0x12234f
xorl %r15d, %r15d
cmpq %rax, %rbx
je 0x1558a4
xorl %eax, %eax
movq 0x8(%rsp), %rbx
jmp 0x15588f
xorl %eax, %eax
xorl %r15d, %r15d
testb %al, %al
jne 0x1559a6
incq %r13
testb %r14b, %r14b
jne 0x155829
jmp 0x1559ab
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1178d5
testb %al, %al
je 0x15590e
movq 0x38(%rsp), %rax
movb 0x20(%rax), %r14b
movq %r12, %rdi
callq 0x14b88c
movl %eax, %r15d
movq %r12, %rdi
callq 0x14b86c
movq %rax, %rbx
movq %rbp, %rdi
callq 0x14b88c
cmpb $0x1, %r14b
jne 0x155931
movl %r15d, %esi
xorl %r15d, %r15d
leaq 0x235e2a(%rip), %rdi    # 0x38b71b
movq %rbx, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x125448
movb $0x1, %al
movb $0x1, %cl
movq %rcx, 0x18(%rsp)
movb $0x1, %r14b
jmp 0x155883
movq 0x48(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rax
cmpq %rax, %rcx
movq 0x8(%rsp), %rbx
jne 0x15595d
movq 0x28(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x155974
xorl %r14d, %r14d
movq 0x30(%rsp), %rdi
leaq 0x235ddb(%rip), %rsi    # 0x38b71b
movl %r15d, %edx
movq %rbx, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movb $0x1, %al
jmp 0x155883
movq 0x28(%rsp), %rcx
incq %rcx
xorl %r15d, %r15d
cmpq %rcx, 0x40(%rsp)
jne 0x155992
movq %rax, 0x40(%rsp)
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x14b940
movb $0x1, %al
movb $0x1, %cl
movq %rcx, 0x18(%rsp)
movb $0x1, %r14b
jmp 0x15588f
xorl %eax, %eax
jmp 0x15588f
xorl %r13d, %r13d
jmp 0x155a42
xorl %r13d, %r13d
jmp 0x1559b1
movl %r15d, %r13d
jmp 0x1559b1
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
testb $0x1, %al
movq 0x80(%rsp), %r15
je 0x1559da
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd4819
movq %r12, %rdi
callq 0x14c43a
movb $0x1, %bpl
jmp 0x155a3d
movb $0x1, %bpl
testl %r13d, %r13d
jne 0x155a3d
movq 0x38(%rsp), %rax
movb 0x20(%rax), %r14b
movq %r12, %rdi
callq 0x14b88c
movl %eax, %ebx
movq %r12, %rdi
callq 0x14b86c
cmpb $0x1, %r14b
jne 0x155a18
leaq 0x235d51(%rip), %rdi    # 0x38b75b
movl %ebx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x125448
jmp 0x155a38
xorl %ebp, %ebp
movq 0x30(%rsp), %rdi
leaq 0x235d7e(%rip), %rsi    # 0x38b7a4
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rbx
testb %bpl, %bpl
je 0x155a59
incq %r15
testl %r13d, %r13d
je 0x1557cc
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x155a59
xorl %r13d, %r13d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %r13d, %r13d
jne 0x155b9a
movq 0x8(%rsp), %rdi
callq 0xd4a9a
xorl %ebx, %ebx
cmpq $0x2, %rax
jb 0x155b9a
movl $0x1, %r15d
leaq 0x2211fa(%rip), %r13    # 0x376c84
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xd47ba
movq (%rax), %rbp
movq %rbp, %rdi
callq 0x14b8df
movq %rax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x117923
movq %rax, 0x58(%rsp)
movq %rdx, 0x60(%rsp)
movq %rbp, %rdi
callq 0x14970e
movl %eax, %r12d
movl 0x14(%rsp), %edi
cmpl %edi, %eax
jne 0x155b35
movl %r12d, %esi
callq 0x121f50
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
callq 0x14b89b
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x120dc8
testl %eax, %eax
je 0x155b91
movq 0x78(%rsp), %rdi
callq 0x14b88c
movl %eax, %r12d
movq %rbp, %rdi
callq 0x14b88c
xorl %ebp, %ebp
movq 0x30(%rsp), %rdi
leaq 0x235d06(%rip), %rsi    # 0x38b82d
movl %r12d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x1019cf
jmp 0x155b6c
movl %edi, %r14d
movq %rbp, %rdi
callq 0x14b88c
movl %r12d, %ecx
movsbl (%rcx,%r13), %r8d
movl %r14d, %ecx
movsbl (%rcx,%r13), %r9d
xorl %ebp, %ebp
movq 0x30(%rsp), %rdi
leaq 0x235c82(%rip), %rsi    # 0x38b7e0
movq 0x50(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x155b98
incq %r15
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xd4a9a
cmpq %rax, %r15
jb 0x155a8f
jmp 0x155b9a
xorl %eax, %eax
movb $0x1, %bpl
jmp 0x155b71
movl %eax, %ebx
testl %ebx, %ebx
jne 0x155c7d
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
leaq 0x22e143(%rip), %rsi    # 0x383cf6
movq 0x68(%rsp), %rdi
movl 0x14(%rsp), %r8d
callq 0x14952c
movq %rax, 0x20(%rsp)
leaq 0x28e19e(%rip), %rsi    # 0x3e3d6c
movq %rax, %rdi
movq 0x50(%rsp), %r14
movq %r14, %rdx
callq 0x14a4d2
movq 0x20(%rsp), %rdi
leaq 0x23599d(%rip), %rsi    # 0x38b587
movq %r14, %rdx
callq 0x14a4d2
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r14, %rsi
callq 0x105a11
testq %rax, %rax
je 0x155c21
cmpb $0x0, (%rax)
je 0x155c21
movq 0x20(%rsp), %rdi
leaq 0x255a35(%rip), %rsi    # 0x3ab64e
movq %rax, %rdx
callq 0x14a4d2
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x155c69
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0xd47ba
movq (%rax), %rdi
movq 0x20(%rsp), %r12
callq 0x14b5fc
movq %r12, %rdi
movq %rax, %rsi
callq 0x149997
incq %r15
movq %r14, %rdi
callq 0xd4a9a
cmpq %rax, %r15
jb 0x155c36
leaq 0x20(%rsp), %rsi
movl $0x8, %edx
movq 0x70(%rsp), %rdi
callq 0xd49ce
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x47bc3
callq 0x47bfc
callq 0x47b8a