// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/tools/gt_condenseq_extract.c
// Function: gt_condenseq_extract_runner
static int gt_condenseq_extract_runner(GT_UNUSED int argc,
                                       const char **argv,
                                       int parsed_args,
                                       void *tool_arguments,
                                       GtError *err)
{
  int had_err = 0;
  GtCondenserExtractArguments *arguments = tool_arguments;
  GtCondenseq *condenseq = NULL;
  GtLogger *logger = NULL;
  GtTimer *timer = NULL;

  gt_error_check(err);
  gt_assert(arguments);

  if (gt_showtime_enabled()) {
    timer = gt_timer_new_with_progress_description("load condenseq");
    gt_timer_start(timer);
  }

  logger = gt_logger_new(arguments->verbose, GT_LOGGER_DEFLT_PREFIX, stderr);

  if (!had_err) {
    condenseq = gt_condenseq_new_from_file(argv[parsed_args], logger, err);
    if (condenseq == NULL) {
      had_err = -1;
    }
  }

  if (!had_err) {
    const char *buffer = NULL;
    const char *desc = NULL;
    GtUword desclen,
            seqlen,
            rend = gt_condenseq_total_length(condenseq),
            send = gt_condenseq_num_of_sequences(condenseq);
    bool concat = strcmp(gt_str_get(arguments->mode), "concat") == 0;
    /* single sequence to extract = range of length 1 */
    if (arguments->seq != GT_UNDEF_UWORD) {
      arguments->seqrange.start = arguments->seqrange.end = arguments->seq;
    }
    /* no range given at all: extract all seqs */
    if (arguments->range.start == GT_UNDEF_UWORD &&
        arguments->seqrange.start == GT_UNDEF_UWORD) {
      arguments->seqrange.start = 0;
      arguments->seqrange.end = send - 1;
    }
    /* if seqs are specified, and concat is given, switch to posrange */
    if (concat && arguments->seqrange.start != GT_UNDEF_UWORD) {
      if (arguments->seqrange.end >= send) {
        had_err = -1;
        gt_error_set(err, "range end " GT_WU " excedes number of sequences "
                     GT_WU " (ranges are zero based sequence ids)",
                     arguments->seqrange.end, send);
      }
      else {
        arguments->range.start =
          gt_condenseq_seqstartpos(condenseq, arguments->seqrange.start);
        arguments->range.end =
          gt_condenseq_seqstartpos(condenseq, arguments->seqrange.end) +
          gt_condenseq_seqlength(condenseq, arguments->seqrange.end) - 1;
      }
    }
    /* extract sequence region */
    if (!had_err && arguments->range.start != GT_UNDEF_UWORD) {
      const GtUword maxbuffsize = ((GtUword) 1) << 17; /* ~ 100000byte */
      GtUword clen,
              rstart,
              current_length = 0, i;
      const char sepchar = gt_str_get(arguments->sepchar)[0];

      if (timer)
        gt_timer_show_progress(timer, "extract sequence region(s)", stderr);

      if (arguments->range.end >= rend) {
        had_err = -1;
        gt_error_set(err, "range end " GT_WU " excedes length of sequence "
                     GT_WU " (ranges are zero based positions)",
                     arguments->range.end, rend);
      }
      if (!had_err) {
        rstart = arguments->range.start;
        rend = arguments->range.end;
        /* nextlength = gt_condenseq_seqlength(condenseq, seqnum); */
        /* seqstart = gt_condenseq_seqstartpos(condenseq, seqnum); */
        /* gt_assert(rstart >= seqstart); */
        /* nextlength -= rstart - seqstart; [> handle first seq <] */
        while (rstart <= rend) {
          GtRange cur_range;
          if (rend - rstart > maxbuffsize) {
            GtUword seqnum = gt_condenseq_pos2seqnum(condenseq,
                                                     rstart + maxbuffsize),
                    closest_sep = gt_condenseq_seqstartpos(condenseq,
                                                           seqnum) - 1;
            gt_assert(closest_sep > rstart);
            clen = closest_sep - rstart + 1;
          }
          else
            clen = rend - rstart + 1;

          cur_range.start = rstart;
          cur_range.end = rstart + clen - 1;
          buffer = gt_condenseq_extract_decoded_range(condenseq, cur_range,
                                                      sepchar);
          gt_assert(buffer != NULL);
          for (i = 0; i < clen; i++, current_length++) {
            if (arguments->width && current_length == arguments->width) {
              gt_file_xfputc('\n', arguments->outfp);
              current_length = 0;
            }
            gt_file_xfputc(buffer[i], arguments->outfp);
          }
          rstart += clen;
        }
        gt_file_xfputc('\n', arguments->outfp);
      }
    }
    else if (!had_err) { /* extract seqwise and always fasta */
      GtUword seqnum,
              sstart = arguments->seqrange.start;

      if (timer)
        gt_timer_show_progress(timer, "extract sequence(s)", stderr);
      if (arguments->seqrange.end >= send) {
        had_err = -1;
        gt_error_set(err, "range end " GT_WU " excedes number of sequences "
                     GT_WU " (ranges are zero based sequence ids)",
                     arguments->seqrange.end, send);
      }
      send = arguments->seqrange.end;
      for (seqnum = sstart;
           !had_err && seqnum <= send;
           ++seqnum) {
        buffer = gt_condenseq_extract_decoded(condenseq, &seqlen, seqnum);
        desc = gt_condenseq_description(condenseq, &desclen, seqnum);
        gt_fasta_show_entry_nt(desc, desclen,
                               buffer, seqlen,
                               arguments->width,
                               arguments->outfp);
      }
    }
  }
  if (timer)
    gt_timer_show_progress(timer, "cleanup", stderr);
  gt_condenseq_delete(condenseq);
  gt_logger_delete(logger);
  if (timer)
    gt_timer_show_progress_final(timer, stderr);
  gt_timer_delete(timer);
  return had_err;
}

// Assembly:
subq $0xf8, %rsp
movl %edi, 0xf4(%rsp)
movq %rsi, 0xe8(%rsp)
movl %edx, 0xe4(%rsp)
movq %rcx, 0xd8(%rsp)
movq %r8, 0xd0(%rsp)
movl $0x0, 0xcc(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq $0x0, 0xb8(%rsp)
movq $0x0, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
cmpq $0x0, 0xd0(%rsp)
je 0x27102
movq 0xd0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x270ca
jmp 0x27102
movq 0x614ecf(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4eef38(%rip), %rsi    # 0x516013
leaq 0x4ef0dd(%rip), %rdx    # 0x5161bf
leaq 0x4f3108(%rip), %rcx    # 0x51a1f1
leaq 0x4f2de1(%rip), %r8     # 0x519ed1
movl $0xd7, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27104
jmp 0x27106
cmpq $0x0, 0xc0(%rsp)
jne 0x27149
movq 0x614e88(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4eeef1(%rip), %rsi    # 0x516013
leaq 0x553a36(%rip), %rdx    # 0x57ab5f
leaq 0x4f30c1(%rip), %rcx    # 0x51a1f1
leaq 0x4f2d9a(%rip), %r8     # 0x519ed1
movl $0xd8, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2714b
callq 0x11aa90
testb $0x1, %al
jne 0x27156
jmp 0x27177
leaq 0x4f30b0(%rip), %rdi    # 0x51a20d
callq 0x1213a0
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x1213f0
movq 0xc0(%rsp), %rax
movb 0x58(%rax), %al
movq 0x614e17(%rip), %rcx    # 0x63bfa0
movq (%rcx), %rdx
leaq 0x4f0759(%rip), %rsi    # 0x5178ec
andb $0x1, %al
movzbl %al, %edi
callq 0xe7870
movq %rax, 0xb0(%rsp)
cmpl $0x0, 0xcc(%rsp)
jne 0x271f8
movq 0xe8(%rsp), %rax
movslq 0xe4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xb0(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x13fd70
movq %rax, 0xb8(%rsp)
cmpq $0x0, 0xb8(%rsp)
jne 0x271f6
movl $0xffffffff, 0xcc(%rsp) # imm = 0xFFFFFFFF
jmp 0x271f8
cmpl $0x0, 0xcc(%rsp)
jne 0x2784c
movq $0x0, 0xa0(%rsp)
movq $0x0, 0x98(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x13f000
movq %rax, 0x80(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x13f010
movq %rax, 0x78(%rsp)
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x4f2e52(%rip), %rsi    # 0x51a0b2
callq 0x19980
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movb %al, 0x77(%rsp)
movq 0xc0(%rsp), %rax
cmpq $-0x1, 0x48(%rax)
je 0x272a4
movq 0xc0(%rsp), %rax
movq 0x48(%rax), %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0xc0(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0xc0(%rsp), %rax
cmpq $-0x1, 0x28(%rax)
jne 0x272e7
movq 0xc0(%rsp), %rax
cmpq $-0x1, 0x38(%rax)
jne 0x272e7
movq 0xc0(%rsp), %rax
movq $0x0, 0x38(%rax)
movq 0x78(%rsp), %rcx
subq $0x1, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x40(%rax)
testb $0x1, 0x77(%rsp)
je 0x273c5
movq 0xc0(%rsp), %rax
cmpq $-0x1, 0x38(%rax)
je 0x273c5
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
cmpq 0x78(%rsp), %rax
jb 0x2734c
movl $0xffffffff, 0xcc(%rsp) # imm = 0xFFFFFFFF
movq 0xd0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rdx
movq 0x78(%rsp), %rcx
leaq 0x4f2ed9(%rip), %rsi    # 0x51a21c
movb $0x0, %al
callq 0xd88c0
jmp 0x273c3
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x38(%rax), %rsi
callq 0x13e470
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rsi
callq 0x13e470
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rsi
callq 0x13e4c0
movq 0x8(%rsp), %rcx
addq %rax, %rcx
subq $0x1, %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x30(%rax)
jmp 0x273c5
cmpl $0x0, 0xcc(%rsp)
jne 0x276dd
movq 0xc0(%rsp), %rax
cmpq $-0x1, 0x28(%rax)
je 0x276dd
movq $0x20000, 0x68(%rsp)    # imm = 0x20000
movq $0x0, 0x50(%rsp)
movq 0xc0(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x11dee0
movb (%rax), %al
movb %al, 0x47(%rsp)
cmpq $0x0, 0xa8(%rsp)
je 0x27438
movq 0xa8(%rsp), %rdi
movq 0x614b77(%rip), %rax    # 0x63bfa0
movq (%rax), %rdx
leaq 0x4f2e3c(%rip), %rsi    # 0x51a26f
callq 0x121930
movq 0xc0(%rsp), %rax
movq 0x30(%rax), %rax
cmpq 0x80(%rsp), %rax
jb 0x27483
movl $0xffffffff, 0xcc(%rsp) # imm = 0xFFFFFFFF
movq 0xd0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x30(%rax), %rdx
movq 0x80(%rsp), %rcx
leaq 0x4f2e0e(%rip), %rsi    # 0x51a28a
movb $0x0, %al
callq 0xd88c0
cmpl $0x0, 0xcc(%rsp)
jne 0x276d8
movq 0xc0(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0xc0(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x80(%rsp)
movq 0x58(%rsp), %rax
cmpq 0x80(%rsp), %rax
ja 0x276c3
movq 0x80(%rsp), %rax
subq 0x58(%rsp), %rax
cmpq $0x20000, %rax          # imm = 0x20000
jbe 0x27576
movq 0xb8(%rsp), %rdi
movq 0x58(%rsp), %rsi
addq $0x20000, %rsi          # imm = 0x20000
callq 0x13e420
movq %rax, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x13e470
subq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x58(%rsp), %rax
ja 0x2755f
movq 0x614a72(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4eeadb(%rip), %rsi    # 0x516013
leaq 0x4f2d9a(%rip), %rdx    # 0x51a2d9
leaq 0x4f2cab(%rip), %rcx    # 0x51a1f1
leaq 0x4f2984(%rip), %r8     # 0x519ed1
movl $0x129, %r9d            # imm = 0x129
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27561
movq 0x20(%rsp), %rax
subq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
jmp 0x2758c
movq 0x80(%rsp), %rax
subq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rax
addq 0x60(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x38(%rsp)
movq 0xb8(%rsp), %rdi
movb 0x47(%rsp), %al
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movsbl %al, %ecx
callq 0x141340
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x27612
movq 0x6149bf(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4eea28(%rip), %rsi    # 0x516013
leaq 0x50dcab(%rip), %rdx    # 0x53529d
leaq 0x4f2bf8(%rip), %rcx    # 0x51a1f1
leaq 0x4f28d1(%rip), %r8     # 0x519ed1
movl $0x133, %r9d            # imm = 0x133
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27614
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x276af
movq 0xc0(%rsp), %rax
cmpq $0x0, 0x50(%rax)
je 0x2766d
movq 0x50(%rsp), %rax
movq 0xc0(%rsp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x2766d
movq 0xc0(%rsp), %rax
movq (%rax), %rsi
movl $0xa, %edi
callq 0xddf60
movq $0x0, 0x50(%rsp)
movq 0xa0(%rsp), %rax
movq 0x48(%rsp), %rcx
movsbl (%rax,%rcx), %edi
movq 0xc0(%rsp), %rax
movq (%rax), %rsi
callq 0xddf60
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x2761d
movq 0x60(%rsp), %rax
addq 0x58(%rsp), %rax
movq %rax, 0x58(%rsp)
jmp 0x274b6
movq 0xc0(%rsp), %rax
movq (%rax), %rsi
movl $0xa, %edi
callq 0xddf60
jmp 0x2784a
cmpl $0x0, 0xcc(%rsp)
jne 0x27848
movq 0xc0(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0xa8(%rsp)
je 0x27725
movq 0xa8(%rsp), %rdi
movq 0x61488a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdx
leaq 0x4f2bce(%rip), %rsi    # 0x51a2ee
callq 0x121930
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
cmpq 0x78(%rsp), %rax
jb 0x2776a
movl $0xffffffff, 0xcc(%rsp) # imm = 0xFFFFFFFF
movq 0xd0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rdx
movq 0x78(%rsp), %rcx
leaq 0x4f2ab9(%rip), %rsi    # 0x51a21c
movb $0x0, %al
callq 0xd88c0
movq 0xc0(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xcc(%rsp)
movb %al, 0x7(%rsp)
jne 0x277a6
movq 0x18(%rsp), %rax
cmpq 0x78(%rsp), %rax
setbe %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x277b3
jmp 0x27846
movq 0xb8(%rsp), %rdi
movq 0x18(%rsp), %rdx
leaq 0x88(%rsp), %rsi
callq 0x1414c0
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x18(%rsp), %rdx
leaq 0x90(%rsp), %rsi
callq 0x13e570
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0x88(%rsp), %rcx
movq 0xc0(%rsp), %rax
movq 0x50(%rax), %r8
movq 0xc0(%rsp), %rax
movq (%rax), %r9
callq 0xdbeb0
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x27785
jmp 0x27848
jmp 0x2784a
jmp 0x2784c
cmpq $0x0, 0xa8(%rsp)
je 0x27875
movq 0xa8(%rsp), %rdi
movq 0x61473a(%rip), %rax    # 0x63bfa0
movq (%rax), %rdx
leaq 0x4f2a92(%rip), %rsi    # 0x51a302
callq 0x121930
movq 0xb8(%rsp), %rdi
callq 0x13f640
movq 0xb0(%rsp), %rdi
callq 0xe7ed0
cmpq $0x0, 0xa8(%rsp)
je 0x278b1
movq 0xa8(%rsp), %rdi
movq 0x6146f7(%rip), %rax    # 0x63bfa0
movq (%rax), %rsi
callq 0x121d70
movq 0xa8(%rsp), %rdi
callq 0x121f00
movl 0xcc(%rsp), %eax
addq $0xf8, %rsp
retq
nopl (%rax)