// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/tools/gt_encseq_decode.c
// Function: output_sequence
static int output_sequence(GtEncseq *encseq, GtEncseqDecodeArguments *args,
                           const char *filename, GtError *err)
{
  GtUword i, j, sfrom, sto;
  int had_err = 0;
  bool has_desc;
  GtEncseqReader *esr;
  gt_assert(encseq);

  if (!(has_desc = gt_encseq_has_description_support(encseq)))
    gt_warning("Missing description support for file %s", filename);

  if (strcmp(gt_str_get(args->mode), "fasta") == 0) {
    /* specify a single sequence to extract */
    if (args->seq != GT_UNDEF_UWORD) {
      if (args->seq >= gt_encseq_num_of_sequences(encseq)) {
        gt_error_set(err,
                     "requested sequence "GT_WU" exceeds number of sequences "
                     "("GT_WU")", args->seq,
                     gt_encseq_num_of_sequences(encseq));
        return -1;
      }
      sfrom = args->seq;
      sto = args->seq + 1;
    } else if (args->seqrng.start != GT_UNDEF_UWORD
                 && args->seqrng.end != GT_UNDEF_UWORD) {
      /* specify a sequence range to extract */
      if (args->seqrng.start >= gt_encseq_num_of_sequences(encseq)
            || args->seqrng.end >= gt_encseq_num_of_sequences(encseq)) {
        gt_error_set(err,
                     "range "GT_WU"-"GT_WU" includes a sequence number "
                     "exceeding the total number of sequences ("GT_WU")",
                     args->seqrng.start,
                     args->seqrng.end,
                     gt_encseq_num_of_sequences(encseq));
        return -1;
      }
      sfrom = args->seqrng.start;
      sto = args->seqrng.end + 1;
    } else {
      /* extract all sequences */
      sfrom = 0;
      sto = gt_encseq_num_of_sequences(encseq);
    }
    for (i = sfrom; i < sto; i++) {
      GtUword desclen, startpos, len;
      char buf[BUFSIZ];
      const char *desc = NULL;
      /* XXX: maybe make this distinction in the functions via readmode? */
      if (!GT_ISDIRREVERSE(args->rm)) {
        startpos = gt_encseq_seqstartpos(encseq, i);
        len = gt_encseq_seqlength(encseq, i);
        if (has_desc) {
          desc = gt_encseq_description(encseq, &desclen, i);
        } else {
          (void) snprintf(buf, BUFSIZ, "sequence "GT_WU"", i);
          desclen = strlen(buf);
          desc = buf;
        }
      } else {
        startpos = gt_encseq_seqstartpos(encseq, i);
        len = gt_encseq_seqlength(encseq,
                                  gt_encseq_num_of_sequences(encseq)-1-i);
        startpos = gt_encseq_total_length(encseq)
                     - (gt_encseq_seqstartpos(encseq,
                                              gt_encseq_num_of_sequences(
                                                encseq)-1-i) + len);
        if (has_desc) {
          desc = gt_encseq_description(encseq,
                                       &desclen,
                                       gt_encseq_num_of_sequences(encseq)-1-i);
        } else {
          (void) snprintf(buf, BUFSIZ, "sequence "GT_WU"", i);
          desclen = strlen(buf);
          desc = buf;
        }
      }
      gt_assert(desc);
      /* output description */
      gt_xfputc(GT_FASTA_SEPARATOR, stdout);
      gt_xfwrite(desc, 1, desclen, stdout);
      gt_xfputc('\n', stdout);
      /* XXX: make this more efficient by writing in a buffer first and then
         showing the result */
      if (args->singlechars) {
        for (j = 0; j < len; j++) {
           gt_xfputc(gt_encseq_get_decoded_char(encseq,
                                                startpos + j,
                                                args->rm),
                     stdout);
        }
      } else {
        esr = gt_encseq_create_reader_with_readmode(encseq, args->rm, startpos);
        for (j = 0; j < len; j++) {
           gt_xfputc(gt_encseq_reader_next_decoded_char(esr), stdout);
        }
        gt_encseq_reader_delete(esr);
      }
      gt_xfputc('\n', stdout);
    }
  }

  if (strcmp(gt_str_get(args->mode), "concat") == 0) {
    GtUword from = 0,
                  to = gt_encseq_total_length(encseq) - 1;
    if (args->rng.start != GT_UNDEF_UWORD && args->rng.end != GT_UNDEF_UWORD) {
      if (args->rng.end > to) {
        had_err = -1;
        gt_error_set(err,
                     "end of range ("GT_WU") exceeds encoded sequence length "
                     "("GT_WU")", args->rng.end, to);
      }
      if (!had_err) {
        from = args->rng.start;
        to = args->rng.end;
      }
    }
    if (!had_err) {
      if (args->singlechars) {
        for (j = from; j <= to; j++) {
          char cc = gt_encseq_get_decoded_char(encseq, j, args->rm);
          if (cc == (char) GT_SEPARATOR)
            cc = gt_str_get(args->sepchar)[0];
          gt_xfputc(cc, stdout);
        }
      } else {
        esr = gt_encseq_create_reader_with_readmode(encseq, args->rm, from);
        if (esr) {
          for (j = from; j <= to; j++) {
            char cc = gt_encseq_reader_next_decoded_char(esr);
            if (cc == (char) GT_SEPARATOR)
              cc = gt_str_get(args->sepchar)[0];
            gt_xfputc(cc, stdout);
          }
          gt_encseq_reader_delete(esr);
        }
      }
      gt_xfputc('\n', stdout);
    }
  }
  return had_err;
}

// Assembly:
subq $0x20f8, %rsp           # imm = 0x20F8
movq %rdi, 0x20e8(%rsp)
movq %rsi, 0x20e0(%rsp)
movq %rdx, 0x20d8(%rsp)
movq %rcx, 0x20d0(%rsp)
movl $0x0, 0x20ac(%rsp)
cmpq $0x0, 0x20e8(%rsp)
jne 0x300d5
movq 0x60befc(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e5f65(%rip), %rsi    # 0x516013
leaq 0x5298c1(%rip), %rdx    # 0x559976
leaq 0x4ec560(%rip), %rcx    # 0x51c61c
leaq 0x4ec3c7(%rip), %r8     # 0x51c48a
movl $0xb9, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x300d7
movq 0x20e8(%rsp), %rdi
callq 0xb24d0
movb %al, %cl
andb $0x1, %cl
movb %cl, 0x20ab(%rsp)
testb $0x1, %al
jne 0x3010a
movq 0x20d8(%rsp), %rsi
leaq 0x4ec529(%rip), %rdi    # 0x51c62c
movb $0x0, %al
callq 0x1267d0
movq 0x20e0(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x51bd53(%rip), %rsi    # 0x54be78
callq 0x19980
cmpl $0x0, %eax
jne 0x30743
movq 0x20e0(%rsp), %rax
cmpq $-0x1, 0x50(%rax)
je 0x301f8
movq 0x20e0(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jb 0x301c7
movq 0x20d0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq %rax, %rcx
leaq 0x4ec4a4(%rip), %rsi    # 0x51c654
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x20f4(%rsp) # imm = 0xFFFFFFFF
jmp 0x309ae
movq 0x20e0(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x20b8(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x50(%rax), %rax
addq $0x1, %rax
movq %rax, 0x20b0(%rsp)
jmp 0x30331
movq 0x20e0(%rsp), %rax
cmpq $-0x1, 0x28(%rax)
je 0x3030e
movq 0x20e0(%rsp), %rax
cmpq $-0x1, 0x30(%rax)
je 0x3030e
movq 0x20e0(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x30274
movq 0x20e0(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jb 0x302e0
movq 0x20d0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %rax, %r8
leaq 0x4ec3c4(%rip), %rsi    # 0x51c68d
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x20f4(%rsp) # imm = 0xFFFFFFFF
jmp 0x309ae
movq 0x20e0(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x20b8(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x30(%rax), %rax
addq $0x1, %rax
movq %rax, 0x20b0(%rsp)
jmp 0x3032f
movq $0x0, 0x20b8(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq %rax, 0x20b0(%rsp)
jmp 0x30331
movq 0x20b8(%rsp), %rax
movq %rax, 0x20c8(%rsp)
movq 0x20c8(%rsp), %rax
cmpq 0x20b0(%rsp), %rax
jae 0x30741
movq $0x0, 0x78(%rsp)
movq 0x20e0(%rsp), %rax
cmpl $0x1, 0x40(%rax)
je 0x30436
movq 0x20e0(%rsp), %rax
cmpl $0x3, 0x40(%rax)
je 0x30436
movq 0x20e8(%rsp), %rdi
movq 0x20c8(%rsp), %rsi
callq 0xb0530
movq %rax, 0x2090(%rsp)
movq 0x20e8(%rsp), %rdi
movq 0x20c8(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x2088(%rsp)
testb $0x1, 0x20ab(%rsp)
je 0x303ec
movq 0x20e8(%rsp), %rdi
movq 0x20c8(%rsp), %rdx
leaq 0x2098(%rsp), %rsi
callq 0xb1b40
movq %rax, 0x78(%rsp)
jmp 0x30431
leaq 0x80(%rsp), %rdi
movq 0x20c8(%rsp), %rcx
movl $0x2000, %esi           # imm = 0x2000
leaq 0x563e32(%rip), %rdx    # 0x59423a
movb $0x0, %al
callq 0x19b90
leaq 0x80(%rsp), %rdi
callq 0x192b0
movq %rax, 0x2098(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x3057f
movq 0x20e8(%rsp), %rdi
movq 0x20c8(%rsp), %rsi
callq 0xb0530
movq %rax, 0x2090(%rsp)
movq 0x20e8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq 0x8(%rsp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
subq 0x20c8(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x2088(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d00
movq %rax, 0x18(%rsp)
movq 0x20e8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq 0x10(%rsp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
subq 0x20c8(%rsp), %rsi
callq 0xb0530
movq %rax, %rcx
movq 0x18(%rsp), %rax
addq 0x2088(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x2090(%rsp)
testb $0x1, 0x20ab(%rsp)
je 0x30538
movq 0x20e8(%rsp), %rax
movq %rax, (%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d50
movq (%rsp), %rdi
movq %rax, %rdx
subq $0x1, %rdx
subq 0x20c8(%rsp), %rdx
leaq 0x2098(%rsp), %rsi
callq 0xb1b40
movq %rax, 0x78(%rsp)
jmp 0x3057d
leaq 0x80(%rsp), %rdi
movq 0x20c8(%rsp), %rcx
movl $0x2000, %esi           # imm = 0x2000
leaq 0x563ce6(%rip), %rdx    # 0x59423a
movb $0x0, %al
callq 0x19b90
leaq 0x80(%rsp), %rdi
callq 0x192b0
movq %rax, 0x2098(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x3057f
jmp 0x30581
cmpq $0x0, 0x78(%rsp)
jne 0x305c1
movq 0x60ba10(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e5a79(%rip), %rsi    # 0x516013
leaq 0x512034(%rip), %rdx    # 0x5425d5
leaq 0x4ec074(%rip), %rcx    # 0x51c61c
leaq 0x4ebedb(%rip), %r8     # 0x51c48a
movl $0xff, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x305c3
movq 0x60b96e(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
movl $0x3e, %edi
callq 0x126b70
movq 0x78(%rsp), %rdi
movq 0x2098(%rsp), %rdx
movq 0x60b94d(%rip), %rax    # 0x63bf38
movq (%rax), %rcx
movl $0x1, %esi
callq 0x126d30
movq 0x60b939(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
movl $0xa, %edi
callq 0x126b70
movq 0x20e0(%rsp), %rax
testb $0x1, (%rax)
je 0x3068c
movq $0x0, 0x20c0(%rsp)
movq 0x20c0(%rsp), %rax
cmpq 0x2088(%rsp), %rax
jae 0x30687
movq 0x20e8(%rsp), %rdi
movq 0x2090(%rsp), %rsi
addq 0x20c0(%rsp), %rsi
movq 0x20e0(%rsp), %rax
movl 0x40(%rax), %edx
callq 0xaa4b0
movsbl %al, %edi
movq 0x60b8cf(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
callq 0x126b70
movq 0x20c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20c0(%rsp)
jmp 0x30625
jmp 0x30714
movq 0x20e8(%rsp), %rdi
movq 0x20e0(%rsp), %rax
movl 0x40(%rax), %esi
movq 0x2090(%rsp), %rdx
callq 0xac380
movq %rax, 0x20a0(%rsp)
movq $0x0, 0x20c0(%rsp)
movq 0x20c0(%rsp), %rax
cmpq 0x2088(%rsp), %rax
jae 0x30707
movq 0x20a0(%rsp), %rdi
callq 0xab500
movsbl %al, %edi
movq 0x60b84f(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
callq 0x126b70
movq 0x20c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20c0(%rsp)
jmp 0x306c0
movq 0x20a0(%rsp), %rdi
callq 0xac3f0
movq 0x60b81d(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
movl $0xa, %edi
callq 0x126b70
movq 0x20c8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20c8(%rsp)
jmp 0x30341
jmp 0x30743
movq 0x20e0(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x4e9954(%rip), %rsi    # 0x51a0b2
callq 0x19980
cmpl $0x0, %eax
jne 0x309a0
movq $0x0, 0x70(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0xa9d00
subq $0x1, %rax
movq %rax, 0x68(%rsp)
movq 0x20e0(%rsp), %rax
cmpq $-0x1, 0x18(%rax)
je 0x30820
movq 0x20e0(%rsp), %rax
cmpq $-0x1, 0x20(%rax)
je 0x30820
movq 0x20e0(%rsp), %rax
movq 0x20(%rax), %rax
cmpq 0x68(%rsp), %rax
jbe 0x307f2
movl $0xffffffff, 0x20ac(%rsp) # imm = 0xFFFFFFFF
movq 0x20d0(%rsp), %rdi
movq 0x20e0(%rsp), %rax
movq 0x20(%rax), %rdx
movq 0x68(%rsp), %rcx
leaq 0x4ebef9(%rip), %rsi    # 0x51c6e4
movb $0x0, %al
callq 0xd88c0
cmpl $0x0, 0x20ac(%rsp)
jne 0x3081e
movq 0x20e0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x20e0(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x68(%rsp)
jmp 0x30820
cmpl $0x0, 0x20ac(%rsp)
jne 0x3099e
movq 0x20e0(%rsp), %rax
testb $0x1, (%rax)
je 0x308cf
movq 0x70(%rsp), %rax
movq %rax, 0x20c0(%rsp)
movq 0x20c0(%rsp), %rax
cmpq 0x68(%rsp), %rax
ja 0x308ca
movq 0x20e8(%rsp), %rdi
movq 0x20c0(%rsp), %rsi
movq 0x20e0(%rsp), %rax
movl 0x40(%rax), %edx
callq 0xaa4b0
movb %al, 0x67(%rsp)
movsbl 0x67(%rsp), %eax
cmpl $-0x1, %eax
jne 0x308a0
movq 0x20e0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movb (%rax), %al
movb %al, 0x67(%rsp)
movsbl 0x67(%rsp), %edi
movq 0x60b68c(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
callq 0x126b70
movq 0x20c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20c0(%rsp)
jmp 0x3084c
jmp 0x3098a
movq 0x20e8(%rsp), %rdi
movq 0x20e0(%rsp), %rax
movl 0x40(%rax), %esi
movq 0x70(%rsp), %rdx
callq 0xac380
movq %rax, 0x20a0(%rsp)
cmpq $0x0, 0x20a0(%rsp)
je 0x30988
movq 0x70(%rsp), %rax
movq %rax, 0x20c0(%rsp)
movq 0x20c0(%rsp), %rax
cmpq 0x68(%rsp), %rax
ja 0x3097b
movq 0x20a0(%rsp), %rdi
callq 0xab500
movb %al, 0x66(%rsp)
movsbl 0x66(%rsp), %eax
cmpl $-0x1, %eax
jne 0x30951
movq 0x20e0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movb (%rax), %al
movb %al, 0x66(%rsp)
movsbl 0x66(%rsp), %edi
movq 0x60b5db(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
callq 0x126b70
movq 0x20c0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20c0(%rsp)
jmp 0x30910
movq 0x20a0(%rsp), %rdi
callq 0xac3f0
jmp 0x3098a
movq 0x60b5a7(%rip), %rax    # 0x63bf38
movq (%rax), %rsi
movl $0xa, %edi
callq 0x126b70
jmp 0x309a0
movl 0x20ac(%rsp), %eax
movl %eax, 0x20f4(%rsp)
movl 0x20f4(%rsp), %eax
addq $0x20f8, %rsp           # imm = 0x20F8
retq
nopl (%rax)