// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/gtf_parser.c
// Function: construct_genes
static int construct_genes(GT_UNUSED void *key, void *value, void *data,
                           GtError *err)
{
  GtHashmap *transcript_id_hash = (GtHashmap*) value;
  ConstructionInfo *cinfo = (ConstructionInfo*) data;
  GtQueue *genome_nodes = cinfo->genome_nodes;
  const char *gname;
  GtArray *mRNAs = gt_array_new(sizeof (GtGenomeNode*));
  GtGenomeNode *gene_node, *gn;
  GtStrand gene_strand;
  GtRange gene_range;
  GtStr *gene_seqid;
  GtUword i;
  int had_err = 0;

  gt_error_check(err);
  gt_assert(key && value && data);
  cinfo->mRNAs = mRNAs;
  had_err = gt_hashmap_foreach(transcript_id_hash, construct_mRNAs, cinfo, err);
  if (!had_err) {
    gt_assert(gt_array_size(mRNAs)); /* at least one mRNA constructed */

    /* determine the range and the strand of the gene */
    gn = *(GtGenomeNode**) gt_array_get(mRNAs, 0);
    gene_range = gt_genome_node_get_range(gn);
    gene_strand = gt_feature_node_get_strand((GtFeatureNode*) gn);
    gene_seqid = gt_genome_node_get_seqid(gn);
    for (i = 1; i < gt_array_size(mRNAs); i++) {
      GtRange range;
      GtStrand strand;
      gn = *(GtGenomeNode**) gt_array_get(mRNAs, i);
      range = gt_genome_node_get_range(gn);
      gene_range = gt_range_join(&gene_range, &range);
      strand = gt_feature_node_get_strand((GtFeatureNode*) gn);
      if (strand != gene_strand) {
        GT_UNUSED const char *transcript_name =
                gt_feature_node_get_attribute((GtFeatureNode*) gn, GT_GFF_NAME);
        gt_error_set(err, "transcript on strand %c encountered, but the "
                          "parent gene %s has strand %c",
                     GT_STRAND_CHARS[strand],
                     (const char*) key,
                     GT_STRAND_CHARS[gene_strand]);
        had_err = -1;
      } else {
        gene_strand = gt_strand_join(gene_strand, strand);
      }
      gt_assert(had_err || gt_str_cmp(gene_seqid,
                                      gt_genome_node_get_seqid(gn)) == 0);
    }
  }

  if (!had_err) {
    gene_node = gt_feature_node_new(gene_seqid, gt_ft_gene, gene_range.start,
                                    gene_range.end, gene_strand);
    gt_feature_node_add_attribute((GtFeatureNode*) gene_node, "ID", key);
    gt_feature_node_add_attribute((GtFeatureNode*) gene_node, "gene_id", key);

    if ((gname = gt_hashmap_get(cinfo->gene_id_to_name_mapping,
                              (const char*) key)) && strlen(gname) > 0) {
      gt_feature_node_add_attribute((GtFeatureNode*) gene_node, GT_GFF_NAME,
                                      gname);
    }

    /* register children */
    for (i = 0; i < gt_array_size(mRNAs); i++) {
      gn = *(GtGenomeNode**) gt_array_get(mRNAs, i);
      gt_feature_node_add_child((GtFeatureNode*) gene_node,
                                (GtFeatureNode*) gn);
      gt_feature_node_add_attribute((GtFeatureNode*) gn, "Parent", key);
      gt_feature_node_add_attribute((GtFeatureNode*) gn, "gene_id", key);
    }

    /* store the gene */
    gt_queue_add(genome_nodes, gene_node);
  } else {
    for (i = 0; i < gt_array_size(mRNAs); i++) {
      gt_genome_node_delete(*(GtGenomeNode**) gt_array_get(mRNAs, i));
    }
  }

  /* free */
  gt_array_delete(mRNAs);

  return had_err;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rcx, 0xd8(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xc0(%rsp)
movl $0x8, %edi
callq 0x80990
movq %rax, 0xb0(%rsp)
movl $0x0, 0x74(%rsp)
cmpq $0x0, 0xd8(%rsp)
je 0x1843ba
movq 0xd8(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x184382
jmp 0x1843ba
movq 0x4b7c17(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x391c80(%rip), %rsi    # 0x516013
leaq 0x391e25(%rip), %rdx    # 0x5161bf
leaq 0x3d056e(%rip), %rcx    # 0x55490f
leaq 0x3d0308(%rip), %r8     # 0x5546b0
movl $0x12b, %r9d            # imm = 0x12B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1843bc
jmp 0x1843be
cmpq $0x0, 0xf0(%rsp)
je 0x1843df
cmpq $0x0, 0xe8(%rsp)
je 0x1843df
cmpq $0x0, 0xe0(%rsp)
jne 0x184417
movq 0x4b7bba(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x391c23(%rip), %rsi    # 0x516013
leaq 0x3b74e3(%rip), %rdx    # 0x53b8da
leaq 0x3d0511(%rip), %rcx    # 0x55490f
leaq 0x3d02ab(%rip), %r8     # 0x5546b0
movl $0x12c, %r9d            # imm = 0x12C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x184419
movq 0xb0(%rsp), %rcx
movq 0xc8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xd0(%rsp), %rdi
movq 0xc8(%rsp), %rdx
movq 0xd8(%rsp), %rcx
leaq 0x614(%rip), %rsi       # 0x184a60
callq 0xe11a0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
jne 0x1846f6
jmp 0x184462
movq 0xb0(%rsp), %rdi
callq 0x81370
cmpq $0x0, %rax
jne 0x1844ad
movq 0x4b7b24(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x391b8d(%rip), %rsi    # 0x516013
leaq 0x3d0492(%rip), %rdx    # 0x55491f
leaq 0x3d047b(%rip), %rcx    # 0x55490f
leaq 0x3d0215(%rip), %r8     # 0x5546b0
movl $0x130, %r9d            # imm = 0x130
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1844af
movq 0xb0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171cc0
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x16cc70
movl %eax, 0x9c(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171b70
movq %rax, 0x80(%rsp)
movq $0x1, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x1846f4
movq 0xb0(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171cc0
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x107730
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x16cc70
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x9c(%rsp), %eax
je 0x184659
movq 0xa0(%rsp), %rdi
leaq 0x3f00ad(%rip), %rsi    # 0x5746ae
callq 0x16c040
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rdi
movl 0x4c(%rsp), %eax
movl %eax, %ecx
leaq 0x3bb11c(%rip), %rax    # 0x53f73c
movsbl (%rax,%rcx), %edx
movq 0xf0(%rsp), %rcx
movl 0x9c(%rsp), %eax
movl %eax, %esi
leaq 0x3bb100(%rip), %rax    # 0x53f73c
movsbl (%rax,%rsi), %r8d
leaq 0x3d02ec(%rip), %rsi    # 0x554934
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x74(%rsp) # imm = 0xFFFFFFFF
jmp 0x184670
movl 0x9c(%rsp), %edi
movl 0x4c(%rsp), %esi
callq 0x11fee0
movl %eax, 0x9c(%rsp)
jmp 0x184672
cmpl $0x0, 0x74(%rsp)
jne 0x1846dd
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x171b70
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x11e170
cmpl $0x0, %eax
je 0x1846dd
movq 0x4b78f4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x39195d(%rip), %rsi    # 0x516013
leaq 0x3d02c1(%rip), %rdx    # 0x55497e
leaq 0x3d024b(%rip), %rcx    # 0x55490f
leaq 0x3cffe5(%rip), %r8     # 0x5546b0
movl $0x14b, %r9d            # imm = 0x14B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1846df
jmp 0x1846e1
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x18452e
jmp 0x1846f6
cmpl $0x0, 0x74(%rsp)
jne 0x184884
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rdx
movq 0x90(%rsp), %rcx
movl 0x9c(%rsp), %r8d
leaq 0x42e43e(%rip), %rsi    # 0x5b2b66
callq 0x16c7e0
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
movq 0xf0(%rsp), %rdx
leaq 0x42b361(%rip), %rsi    # 0x5afaad
callq 0x16edb0
movq 0xa8(%rsp), %rdi
movq 0xf0(%rsp), %rdx
leaq 0x3d00bb(%rip), %rsi    # 0x554823
callq 0x16edb0
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0xf0(%rsp), %rsi
callq 0xe0f20
movq %rax, 0xb8(%rsp)
cmpq $0x0, %rax
je 0x1847c3
movq 0xb8(%rsp), %rdi
callq 0x192b0
cmpq $0x0, %rax
jbe 0x1847c3
movq 0xa8(%rsp), %rdi
movq 0xb8(%rsp), %rdx
leaq 0x3efef0(%rip), %rsi    # 0x5746ae
callq 0x16edb0
movq $0x0, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x18486d
movq 0xb0(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x16d010
movq 0xa0(%rsp), %rdi
movq 0xf0(%rsp), %rdx
leaq 0x3ce97e(%rip), %rsi    # 0x5531b7
callq 0x16edb0
movq 0xa0(%rsp), %rdi
movq 0xf0(%rsp), %rdx
leaq 0x3cffce(%rip), %rsi    # 0x554823
callq 0x16edb0
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x1847cc
movq 0xc0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0xfd170
jmp 0x1848db
movq $0x0, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, (%rsp)
movq 0xb0(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0x1848d9
movq 0xb0(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x80b60
movq (%rax), %rdi
callq 0x173180
movq 0x78(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
jmp 0x18488d
jmp 0x1848db
movq 0xb0(%rsp), %rdi
callq 0x81f80
movl 0x74(%rsp), %eax
addq $0xf8, %rsp
retq
nopw %cs:(%rax,%rax)