// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/extract_feature_sequence.c
// Function: gt_extract_and_translate_feature_sequence
int gt_extract_and_translate_feature_sequence(GtFeatureNode *feature_node,
                                              const char *type,
                                              bool join,
                                              GtStr *seqid,
                                              GtStrArray *target_ids,
                                              GtRegionMapping *rm,
                                              GtTransTable *ttable,
                                              GtStr *translation_fr1,
                                              GtStr *translation_fr2,
                                              GtStr *translation_fr3,
                                              GtError *err)
{
  GtTranslator *tr = NULL;
  GtTranslatorStatus status;
  GtCodonIterator *ci = NULL;
  unsigned int frame, phase_offset = 0;
  char translated;
  int had_err = 0;
  GtStr *sequence = gt_str_new();
  gt_assert(feature_node && type);

  had_err = extract_feature_sequence_generic(sequence,
                                             (GtGenomeNode*) feature_node, type,
                                             join, seqid, target_ids,
                                             &phase_offset, rm, err);

  /* do translation if we have at least one codon */
  if (!had_err && gt_str_length(sequence) > phase_offset + 2) {
    ci = gt_codon_iterator_simple_new(gt_str_get(sequence) + phase_offset,
                                      gt_str_length(sequence) - phase_offset,
                                      NULL);
    tr = gt_translator_new(ci);
    if (ttable)
      gt_translator_set_translation_table(tr, ttable);
    status = gt_translator_next(tr, &translated, &frame, NULL);
    while (status == GT_TRANSLATOR_OK) {
      if (frame == 0 && translation_fr1)
        gt_str_append_char(translation_fr1, translated);
      else if (frame == 1 && translation_fr2)
        gt_str_append_char(translation_fr2, translated);
      else if (frame == 2 && translation_fr3)
        gt_str_append_char(translation_fr3, translated);
      status = gt_translator_next(tr, &translated, &frame, NULL);
    }
    if (status == GT_TRANSLATOR_ERROR)
      had_err = -1;
  }
  gt_translator_delete(tr);
  gt_codon_iterator_delete(ci);
  gt_str_delete(sequence);

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r12
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %rbp
movl $0x0, 0x8(%rsp)
callq 0x3b728
movq %rax, 0x10(%rsp)
testq %rbp, %rbp
je 0xa78c3
testq %r13, %r13
je 0xa78c3
subq $0x8, %rsp
leaq 0x10(%rsp), %rax
movzbl %bl, %ecx
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %r8
movq %r15, %r9
pushq 0x78(%rsp)
pushq %r14
pushq %rax
callq 0xa730c
addq $0x20, %rsp
xorl %r14d, %r14d
testl %eax, %eax
je 0xa7786
movl %eax, %ebp
jmp 0xa7887
movq %rbx, %rdi
callq 0x3bb86
movl 0x8(%rsp), %ecx
addl $0x2, %ecx
cmpq %rcx, %rax
jbe 0xa7885
movq 0x50(%rsp), %r12
movq %rbx, %rdi
callq 0x3bb5d
movq %rbx, %rdi
movl 0x8(%rsp), %ebx
addq %rax, %rbx
callq 0x3bb86
movl 0x8(%rsp), %ecx
subq %rcx, %rax
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xa393d
movq %rax, %r14
movq %rax, %rdi
callq 0xa64b3
movq %rax, %r15
testq %r12, %r12
je 0xa77ec
movq %r15, %rdi
movq %r12, %rsi
callq 0xa6503
movq 0x58(%rsp), %rbp
leaq 0x7(%rsp), %r12
leaq 0xc(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xa6812
movq 0x10(%rsp), %rbx
testl %eax, %eax
jne 0xa78b3
testq %rbp, %rbp
sete %cl
movl 0xc(%rsp), %eax
testl %eax, %eax
setne %dl
orb %cl, %dl
jne 0xa7835
movsbl 0x7(%rsp), %esi
movq %rbp, %rdi
jmp 0xa786e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
sete %cl
cmpl $0x1, %eax
setne %dl
orb %cl, %dl
jne 0xa7851
movsbl 0x7(%rsp), %esi
jmp 0xa786e
cmpq $0x0, 0x68(%rsp)
sete %cl
cmpl $0x2, %eax
setne %al
orb %cl, %al
jne 0xa7873
movsbl 0x7(%rsp), %esi
movq 0x68(%rsp), %rdi
callq 0x3b9df
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xa6812
jmp 0xa7810
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xa68f6
movq %r14, %rdi
callq 0xa374e
movq %rbx, %rdi
callq 0x3c87b
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x2, %eax
jne 0xa78bf
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xa788a
xorl %ebp, %ebp
jmp 0xa788a
callq 0x2374c