// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/tools/gt_extractseq.c
// Function: extractseq_pos
static int extractseq_pos(GtFile *outfp, GtBioseq *bs,
                          GtUword frompos, GtUword topos,
                          GtUword width, GtError *err)
{
  int had_err = 0;
  GtStr *buf;
  char *out = NULL;
  GtUword accupos = 0,
                newstartpos = 0,
                len = topos - frompos + 1,
                i = 0;
  gt_assert(bs);
  gt_error_check(err);

  if (frompos > gt_bioseq_get_total_length(bs)
        || topos > gt_bioseq_get_total_length(bs)) {
    gt_error_set(err, "invalid position pair "GT_WU"-"GT_WU" one value "
                      "is larger than "
                      "sequence length "GT_WU"", frompos, topos,
                      gt_bioseq_get_total_length(bs));
    return -1;
  }
  frompos--; topos--;
  buf = gt_str_new();

  /* look for beginning of sequence */
  while (accupos + gt_bioseq_get_sequence_length(bs, i) <= frompos
            && i < gt_bioseq_number_of_sequences(bs)) {
    accupos += gt_bioseq_get_sequence_length(bs, i);
    i++;
  }
  if (i == 0) {
    newstartpos = frompos;
    accupos = frompos;
  } else {
    gt_assert(accupos > 0);
    newstartpos = frompos - accupos;
  }

  /* do we need to cross a sequence boundary to print the full output? */
  if (len <= gt_bioseq_get_sequence_length(bs, i) - newstartpos) {
    /* no, just print */
    out = gt_bioseq_get_sequence_range(bs, i, newstartpos,
                                       newstartpos + len - 1);
    gt_str_append_cstr_nt(buf, out, len);
    gt_free(out);
  } else {
    /* yes, first output the part on this sequence... */
    GtUword restlen = gt_bioseq_get_sequence_length(bs, i) - newstartpos,
                  restfulllen = topos - accupos + 1;
    out = gt_bioseq_get_sequence_range(bs, i, newstartpos,
                                       newstartpos + restlen - 1);
    restfulllen -= restlen;
    gt_str_append_cstr_nt(buf, out, restlen);
    gt_free(out);

    i++;
    /* ...then determine whether we need to output full seqs in between... */
    while (restfulllen > gt_bioseq_get_sequence_length(bs, i)
             && i < gt_bioseq_number_of_sequences(bs) - 1) {
      GtUword thislen = gt_bioseq_get_sequence_length(bs, i);
      out = gt_bioseq_get_sequence_range(bs, i, 0, thislen - 1);
      gt_str_append_cstr_nt(buf, out, thislen);
      gt_free(out);
      restfulllen -= thislen;
      i++;
    }

    /* ...then output the last sequence */
    if (restfulllen > 0) {
      out = gt_bioseq_get_sequence_range(bs, i, 0, restfulllen - 1);
      gt_str_append_cstr_nt(buf, out, restfulllen);
      gt_free(out);
    }
  }

  gt_fasta_show_entry(NULL, gt_str_get(buf), gt_str_length(buf), width, outfp);
  gt_str_delete(buf);
  return had_err;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rdx, 0xd8(%rsp)
movq %rcx, 0xd0(%rsp)
movq %r8, 0xc8(%rsp)
movq %r9, 0xc0(%rsp)
movl $0x0, 0xbc(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0xa0(%rsp)
movq $0x0, 0x98(%rsp)
movq 0xd0(%rsp), %rax
subq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x88(%rsp)
cmpq $0x0, 0xe0(%rsp)
jne 0x356c1
movq 0x606910(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e0979(%rip), %rsi    # 0x516013
leaq 0x5343a4(%rip), %rdx    # 0x569a45
leaq 0x4e814d(%rip), %rcx    # 0x51d7f5
leaq 0x4e7eb1(%rip), %r8     # 0x51d560
movl $0x98, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x356c3
jmp 0x356c5
cmpq $0x0, 0xc0(%rsp)
je 0x3571b
movq 0xc0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x356e3
jmp 0x3571b
movq 0x6068b6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e091f(%rip), %rsi    # 0x516013
leaq 0x4e0ac4(%rip), %rdx    # 0x5161bf
leaq 0x4e80f3(%rip), %rcx    # 0x51d7f5
leaq 0x4e7e57(%rip), %r8     # 0x51d560
movl $0x99, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x3571d
movq 0xd8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x859d0
movq %rax, %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
ja 0x3576b
movq 0xd0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x859d0
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jbe 0x357cf
movq 0xc0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x859d0
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq %rax, %r8
leaq 0x4e804c(%rip), %rsi    # 0x51d804
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0xf4(%rsp) # imm = 0xFFFFFFFF
jmp 0x35c92
movq 0xd8(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xd8(%rsp)
movq 0xd0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xd0(%rsp)
callq 0x11d4a0
movq %rax, 0xb0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
movq 0x38(%rsp), %rcx
addq %rax, %rcx
xorl %eax, %eax
cmpq 0xd8(%rsp), %rcx
movb %al, 0x47(%rsp)
ja 0x3586a
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x85910
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x35874
jmp 0x358b2
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
addq 0xa0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x35804
cmpq $0x0, 0x88(%rsp)
jne 0x358df
movq 0xd8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0x3593e
jmp 0x358e1
cmpq $0x0, 0xa0(%rsp)
ja 0x35924
movq 0x6066ad(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4e0716(%rip), %rsi    # 0x516013
leaq 0x4e7f4b(%rip), %rdx    # 0x51d84f
leaq 0x4e7eea(%rip), %rcx    # 0x51d7f5
leaq 0x4e7c4e(%rip), %r8     # 0x51d560
movl $0xb0, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x35926
movq 0xd8(%rsp), %rax
subq 0xa0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq 0x98(%rsp), %rcx
cmpq %rcx, %rax
ja 0x359e9
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x98(%rsp), %rcx
addq 0x90(%rsp), %rcx
subq $0x1, %rcx
callq 0x851f0
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x11d830
movq 0xa8(%rsp), %rdi
leaq 0x4e7b86(%rip), %rsi    # 0x51d560
movl $0xba, %edx
callq 0xe88c0
jmp 0x35c37
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
subq 0x98(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xd0(%rsp), %rax
subq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x78(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x98(%rsp), %rcx
addq 0x80(%rsp), %rcx
subq $0x1, %rcx
callq 0x851f0
movq %rax, 0xa8(%rsp)
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x80(%rsp), %rdx
callq 0x11d830
movq 0xa8(%rsp), %rdi
leaq 0x4e7abf(%rip), %rsi    # 0x51d560
movl $0xc3, %edx
callq 0xe88c0
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
movq 0x18(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x27(%rsp)
jbe 0x35b21
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x85910
movq %rax, %rcx
movq 0x10(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
setb %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x35b2e
jmp 0x35bd0
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x84e30
movq %rax, 0x70(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x70(%rsp), %rcx
subq $0x1, %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x851f0
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x11d830
movq 0xa8(%rsp), %rdi
leaq 0x4e79c5(%rip), %rsi    # 0x51d560
movl $0xcc, %edx
callq 0xe88c0
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x35abf
cmpq $0x0, 0x78(%rsp)
jbe 0x35c35
movq 0xe0(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x78(%rsp), %rcx
subq $0x1, %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x851f0
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x78(%rsp), %rdx
callq 0x11d830
movq 0xa8(%rsp), %rdi
leaq 0x4e7935(%rip), %rsi    # 0x51d560
movl $0xd5, %edx
callq 0xe88c0
jmp 0x35c37
movq 0xb0(%rsp), %rdi
callq 0x11dee0
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x11dfa0
movq 0x8(%rsp), %rsi
movq %rax, %rdx
movq 0xc8(%rsp), %rcx
movq 0xe8(%rsp), %r8
xorl %eax, %eax
movl %eax, %edi
callq 0xdbd10
movq 0xb0(%rsp), %rdi
callq 0x11f560
movl 0xbc(%rsp), %eax
movl %eax, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
addq $0xf8, %rsp
retq
nopw %cs:(%rax,%rax)