// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/extract_feature_sequence.c
// Function: extract_feature_sequence_generic
static int extract_feature_sequence_generic(GtStr *sequence, GtGenomeNode *gn,
                                            const char *type, bool join,
                                            GtStr *seqid,
                                            GtStrArray *target_ids,
                                            unsigned int *out_phase_offset,
                                            GtRegionMapping *region_mapping,
                                            GtError *err)
{
  GtFeatureNode *fn;
  GtRange range;
  unsigned int phase_offset = 0;
  char *outsequence;
  const char *target;
  int had_err = 0;

  gt_error_check(err);
  fn = gt_genome_node_cast(gt_feature_node_class(), gn);
  gt_assert(fn);

  if (seqid)
    gt_str_append_str(seqid, gt_genome_node_get_seqid(gn));
  if (target_ids &&
      (target = gt_feature_node_get_attribute(fn, GT_GFF_TARGET))) {
    had_err = gt_gff3_parser_parse_all_target_attributes(target, false,
                                                         target_ids, NULL,
                                                         NULL, "", 0, err);
  }
  if (!had_err) {
    if (join) {
      GtFeatureNodeIterator *fni;
      GtFeatureNode *child;
      bool reverse_strand = false,
           first_child = true,
           first_child_of_type_seen = false;
      GtPhase phase = GT_PHASE_UNDEFINED;
      /* in this case we have to traverse the children */
      fni = gt_feature_node_iterator_new_direct(gt_feature_node_cast(gn));
      while (!had_err && (child = gt_feature_node_iterator_next(fni))) {
        if (first_child) {
          if (target_ids &&
               (target = gt_feature_node_get_attribute(child, GT_GFF_TARGET))) {
            gt_str_array_reset(target_ids);
            had_err = gt_gff3_parser_parse_all_target_attributes(target, false,
                                                                 target_ids,
                                                                 NULL,
                                                                 NULL, "", 0,
                                                                 err);
          }
          first_child = false;
        }
        if (!had_err) {
          if (extract_join_feature((GtGenomeNode*) child, type, region_mapping,
                                   sequence, &reverse_strand,
                                   &first_child_of_type_seen,
                                   &phase, err)) {
            had_err = -1;
          }
          if (phase != GT_PHASE_UNDEFINED) {
            phase_offset = (int) phase;
          }
        }
      }
      gt_feature_node_iterator_delete(fni);
      gt_assert(phase_offset <= (unsigned int) GT_PHASE_UNDEFINED);
      if (!had_err && gt_str_length(sequence)) {
        if (reverse_strand) {
          had_err = gt_reverse_complement(gt_str_get(sequence),
                                          gt_str_length(sequence), err);
        }
      }
    }
    else if (gt_feature_node_get_type(fn) == type) {
      GtPhase phase = gt_feature_node_get_phase(fn);
      gt_assert(!had_err);
      if (phase != GT_PHASE_UNDEFINED)
        phase_offset = (unsigned int) phase;
      /* otherwise we only have to look at this feature */
      range = gt_genome_node_get_range(gn);
      gt_assert(range.start); /* 1-based coordinates */
      had_err = gt_region_mapping_get_sequence(region_mapping, &outsequence,
                                               gt_genome_node_get_seqid(gn),
                                               range.start, range.end, err);
      if (!had_err) {
        gt_str_append_cstr_nt(sequence, outsequence, gt_range_length(&range));
        gt_free(outsequence);
        if (gt_feature_node_get_strand(fn) == GT_STRAND_REVERSE) {
          had_err = gt_reverse_complement(gt_str_get(sequence),
                                          gt_str_length(sequence), err);
        }
      }
    }
  }
  if (out_phase_offset && phase_offset != GT_PHASE_UNDEFINED) {
    *out_phase_offset = phase_offset;
  }
  return had_err;
}

// Assembly:
subq $0xe8, %rsp
movb %cl, %al
movq 0x100(%rsp), %rcx
movq 0xf8(%rsp), %rcx
movq 0xf0(%rsp), %rcx
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movq %rdx, 0xd0(%rsp)
andb $0x1, %al
movb %al, 0xcf(%rsp)
movq %r8, 0xc0(%rsp)
movq %r9, 0xb8(%rsp)
movl $0x0, 0x9c(%rsp)
movl $0x0, 0x84(%rsp)
cmpq $0x0, 0x100(%rsp)
je 0xe726e
movq 0x100(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0xe7236
jmp 0xe726e
movq 0xccd9b(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x76e1f(%rip), %rsi     # 0x15e066
leaq 0x773fa(%rip), %rdx     # 0x15e648
leaq 0x928d7(%rip), %rcx     # 0x179b2c
leaq 0x928a8(%rip), %r8      # 0x179b04
movl $0x53, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xe7270
callq 0x201e0
movq %rax, %rdi
movq 0xd8(%rsp), %rsi
callq 0x256b0
movq %rax, 0xb0(%rsp)
cmpq $0x0, 0xb0(%rsp)
jne 0xe72d0
movq 0xccd39(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x76dbd(%rip), %rsi     # 0x15e066
leaq 0x8b2d1(%rip), %rdx     # 0x172581
leaq 0x92875(%rip), %rcx     # 0x179b2c
leaq 0x92846(%rip), %r8      # 0x179b04
movl $0x55, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xe72d2
cmpq $0x0, 0xc0(%rsp)
je 0xe7304
movq 0xc0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x258a0
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x191b0
cmpq $0x0, 0xb8(%rsp)
je 0xe7372
movq 0xb0(%rsp), %rdi
leaq 0x7d593(%rip), %rsi     # 0x1648b1
callq 0x1fde0
movq %rax, 0x88(%rsp)
cmpq $0x0, %rax
je 0xe7372
movq 0x88(%rsp), %rdi
movq 0xb8(%rsp), %rdx
movq 0x100(%rsp), %rax
xorl %esi, %esi
xorl %ecx, %ecx
movl %ecx, %r8d
leaq 0x84b8c(%rip), %r9      # 0x16bee3
movq %r8, %rcx
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x29470
movl %eax, 0x84(%rsp)
cmpl $0x0, 0x84(%rsp)
jne 0xe779e
testb $0x1, 0xcf(%rsp)
je 0xe75a3
movb $0x0, 0x6f(%rsp)
movb $0x1, 0x6e(%rsp)
movb $0x0, 0x6d(%rsp)
movl $0x3, 0x68(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x20750
movq %rax, %rdi
callq 0x24a80
movq %rax, 0x78(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x84(%rsp)
movb %al, 0x47(%rsp)
jne 0xe73e9
movq 0x78(%rsp), %rdi
callq 0x24bd0
movq %rax, 0x70(%rsp)
cmpq $0x0, %rax
setne %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0xe73f6
jmp 0xe74ef
testb $0x1, 0x6e(%rsp)
je 0xe747a
cmpq $0x0, 0xb8(%rsp)
je 0xe7475
movq 0x70(%rsp), %rdi
leaq 0x7d49d(%rip), %rsi     # 0x1648b1
callq 0x1fde0
movq %rax, 0x88(%rsp)
cmpq $0x0, %rax
je 0xe7475
movq 0xb8(%rsp), %rdi
callq 0x1b6c0
movq 0x88(%rsp), %rdi
movq 0xb8(%rsp), %rdx
movq 0x100(%rsp), %rax
xorl %esi, %esi
xorl %ecx, %ecx
movl %ecx, %r8d
leaq 0x84a89(%rip), %r9      # 0x16bee3
movq %r8, %rcx
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x29470
movl %eax, 0x84(%rsp)
movb $0x0, 0x6e(%rsp)
cmpl $0x0, 0x84(%rsp)
jne 0xe74ea
movq 0x70(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq 0xe0(%rsp), %rcx
movq 0x100(%rsp), %rax
leaq 0x6f(%rsp), %r8
leaq 0x6d(%rsp), %r9
leaq 0x68(%rsp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xe7a90
cmpl $0x0, %eax
je 0xe74d6
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
cmpl $0x3, 0x68(%rsp)
je 0xe74e8
movl 0x68(%rsp), %eax
movl %eax, 0x9c(%rsp)
jmp 0xe74ea
jmp 0xe73bf
movq 0x78(%rsp), %rdi
callq 0x24cf0
cmpl $0x3, 0x9c(%rsp)
jbe 0xe753b
movq 0xccace(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x76b52(%rip), %rsi     # 0x15e066
leaq 0x92632(%rip), %rdx     # 0x179b4d
leaq 0x9260a(%rip), %rcx     # 0x179b2c
leaq 0x925db(%rip), %r8      # 0x179b04
movl $0x83, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xe753d
cmpl $0x0, 0x84(%rsp)
jne 0xe759e
movq 0xe0(%rsp), %rdi
callq 0x19a00
cmpq $0x0, %rax
je 0xe759e
testb $0x1, 0x6f(%rsp)
je 0xe759c
movq 0xe0(%rsp), %rdi
callq 0x19940
movq %rax, 0x38(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x19a00
movq 0x38(%rsp), %rdi
movq %rax, %rsi
movq 0x100(%rsp), %rdx
callq 0xeaf70
movl %eax, 0x84(%rsp)
jmp 0xe759e
jmp 0xe779c
movq 0xb0(%rsp), %rdi
callq 0x211d0
cmpq 0xd0(%rsp), %rax
jne 0xe779a
movq 0xb0(%rsp), %rdi
callq 0x21f60
movl %eax, 0x64(%rsp)
cmpl $0x0, 0x84(%rsp)
je 0xe7611
movq 0xcc9f8(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x76a7c(%rip), %rsi     # 0x15e066
leaq 0x7f9cd(%rip), %rdx     # 0x166fbe
leaq 0x92534(%rip), %rcx     # 0x179b2c
leaq 0x92505(%rip), %r8      # 0x179b04
movl $0x8d, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xe7613
cmpl $0x3, 0x64(%rsp)
je 0xe7625
movl 0x64(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x259f0
movq %rax, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0xe7699
movq 0xcc970(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x769f4(%rip), %rsi     # 0x15e066
leaq 0x933a4(%rip), %rdx     # 0x17aa1d
leaq 0x924ac(%rip), %rcx     # 0x179b2c
leaq 0x9247d(%rip), %r8      # 0x179b04
movl $0x92, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xe769b
movq 0xf8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x258a0
movq 0x30(%rsp), %rdi
movq %rax, %rdx
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %r8
movq 0x100(%rsp), %r9
leaq 0x90(%rsp), %rsi
callq 0xe8c60
movl %eax, 0x84(%rsp)
cmpl $0x0, 0x84(%rsp)
jne 0xe7798
movq 0xe0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x93bd0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
callq 0x19290
movq 0x90(%rsp), %rdi
leaq 0x923c5(%rip), %rsi     # 0x179b04
movl $0x98, %edx
callq 0xdab0
movq 0xb0(%rsp), %rdi
callq 0x20a10
cmpl $0x1, %eax
jne 0xe7796
movq 0xe0(%rsp), %rdi
callq 0x19940
movq %rax, 0x18(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x19a00
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq 0x100(%rsp), %rdx
callq 0xeaf70
movl %eax, 0x84(%rsp)
jmp 0xe7798
jmp 0xe779a
jmp 0xe779c
jmp 0xe779e
cmpq $0x0, 0xf0(%rsp)
je 0xe77c4
cmpl $0x3, 0x9c(%rsp)
je 0xe77c4
movl 0x9c(%rsp), %ecx
movq 0xf0(%rsp), %rax
movl %ecx, (%rax)
movl 0x84(%rsp), %eax
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)