// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0x8(%rsp)
callq 0x13d5c
movq %rax, 0x10(%rsp)
testq %rbp, %rbp
je 0x88565
testq %r13, %r13
je 0x88565
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 0x87e89
addq $0x20, %rsp
xorl %r14d, %r14d
testl %eax, %eax
je 0x8842a
movl %eax, %ebp
jmp 0x8852b
movq %rbx, %rdi
callq 0x14461
movl 0x8(%rsp), %ecx
addl $0x2, %ecx
cmpq %rcx, %rax
jbe 0x88529
movq 0x50(%rsp), %r12
movq %rbx, %rdi
callq 0x143d2
movq %rbx, %rdi
movl 0x8(%rsp), %ebx
addq %rax, %rbx
callq 0x14461
movl 0x8(%rsp), %ecx
subq %rcx, %rax
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x83627
movq %rax, %r14
movq %rax, %rdi
callq 0x86e46
movq %rax, %r15
testq %r12, %r12
je 0x88490
movq %r15, %rdi
movq %r12, %rsi
callq 0x86f29
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 0x87367
movq 0x10(%rsp), %rbx
testl %eax, %eax
jne 0x88557
testq %rbp, %rbp
sete %cl
movl 0xc(%rsp), %eax
testl %eax, %eax
setne %dl
orb %cl, %dl
jne 0x884d9
movsbl 0x7(%rsp), %esi
movq %rbp, %rdi
jmp 0x88512
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
sete %cl
cmpl $0x1, %eax
setne %dl
orb %cl, %dl
jne 0x884f5
movsbl 0x7(%rsp), %esi
jmp 0x88512
cmpq $0x0, 0x68(%rsp)
sete %cl
cmpl $0x2, %eax
setne %al
orb %cl, %al
jne 0x88517
movsbl 0x7(%rsp), %esi
movq 0x68(%rsp), %rdi
callq 0x140b1
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x87367
jmp 0x884b4
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x874ce
movq %r14, %rdi
callq 0x83360
movq %rbx, %rdi
callq 0x152db
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x2, %eax
jne 0x88561
pushq $-0x1
popq %rbp
jmp 0x8852e
xorl %ebp, %ebp
jmp 0x8852e
movq 0xa5a4c(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x41af0(%rip), %rsi     # 0xca066
leaq 0x5c3f0(%rip), %rdx     # 0xe496d
leaq 0x5c3fe(%rip), %rcx     # 0xe4982
leaq 0x5c421(%rip), %r8      # 0xe49ac
movl $0xc3, %r9d
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
nopl (%rax)