// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/giextract.c
// Function: gt_extractkeysfromfastafile
int gt_extractkeysfromfastafile(bool verbose,
                                GtFile *outfp,
                                GtUword width,
                                const GtStr *fileofkeystoextract,
                                GtStrArray *referencefiletab,
                                GtError *err)
{
  GtSeqIterator *seqit;
  const GtUchar *sequence;
  char *desc, *headerbufferspace = NULL, *keyspace = NULL;
  const char *keyptr;
  GtUword allockeyspace = 0, len, keylen, numofqueries, keyposition,
                countmarkhit = 0;
  int had_err = 0;
  off_t totalsize;
  Fastakeyquery *fastakeyqueries;
  size_t headerbuffersize = 0, headerlength;

  gt_error_check(err);
  fastakeyqueries = readfileofkeystoextract(verbose,&numofqueries,
                                            fileofkeystoextract,err);
  if (fastakeyqueries == NULL)
  {
    return -1;
  }
  totalsize = gt_files_estimate_total_size(referencefiletab);
  if (verbose)
  {
    printf("# estimated total size is " Formatuint64_t "\n",
            PRINTuint64_tcast(totalsize));
  }
  seqit = gt_seq_iterator_sequence_buffer_new(referencefiletab, err);
  if (!seqit)
  {
    had_err = -1;
  }
  if (!had_err && verbose)
  {
    gt_progressbar_start(gt_seq_iterator_getcurrentcounter(seqit,
                                                          (GtUint64)
                                                          totalsize),
                                                          (GtUint64)
                                                          totalsize);
  }
  while (had_err != -1 && countmarkhit < numofqueries)
  {
    had_err = gt_seq_iterator_next(seqit, &sequence, &len, &desc, err);
    if (had_err != 1)
    {
      break;
    }
    keyptr = desc2key(&keylen,desc,err);
    if (keyptr == NULL)
    {
      had_err = -1;
    } else
    {
      if (allockeyspace < keylen)
      {
        keyspace = gt_realloc(keyspace,sizeof (*keyspace) * (keylen+1));
        allockeyspace = keylen;
      }
      gt_assert(keyspace != NULL);
      strncpy(keyspace,keyptr,(size_t) keylen);
      keyspace[keylen] = '\0';
      keyposition = searchdesinfastakeyqueries(keyspace,fastakeyqueries,
                                               numofqueries);
      if (keyposition < numofqueries)
      {
        while (keyposition < numofqueries &&
               strcmp(fastakeyqueries[keyposition].fastakey,keyspace) == 0)
        {
#ifndef NDEBUG
          if (fastakeyqueries[keyposition].markhit)
          {
            fprintf(stderr,"key %s was already found before\n",
                     fastakeyqueries[keyposition].fastakey);
            exit(GT_EXIT_PROGRAMMING_ERROR);
          }
#endif
          headerlength = strlen(desc);
          if (headerbuffersize < headerlength + EXTRABUF + 1)
          {
            headerbuffersize = headerlength + EXTRABUF + 1;
            headerbufferspace = gt_realloc(headerbufferspace,
                                           sizeof (*headerbufferspace)
                                           * headerbuffersize);
          }
          if (COMPLETE(fastakeyqueries + keyposition))
          {
            /*
            (void) snprintf(headerbufferspace,headerbuffersize,
                            "%*.*s complete %s",
                            (int) keylen,(int) keylen,keyspace,
                            desc);
            */
            gt_fasta_show_entry(desc, (const char *) sequence, len, width,
                                outfp);
          } else
          {
            (void) snprintf(headerbufferspace,headerbuffersize,
                            "%*.*s "GT_WU" "GT_WU" %s",
                            (int) keylen,(int) keylen,keyspace,
                            fastakeyqueries[keyposition].frompos,
                            fastakeyqueries[keyposition].topos,
                            desc);
            gt_fasta_show_entry(headerbufferspace,
                                (const char *)
                                (sequence+fastakeyqueries[keyposition].
                                                          frompos - 1),
                                fastakeyqueries[keyposition].topos -
                                fastakeyqueries[keyposition].frompos+1,
                                width, outfp);
          }
          fastakeyqueries[keyposition].markhit = true;
          countmarkhit++;
          keyposition++;
        }
      }
#ifdef SKDEBUG
      printf("%s 1 "GT_WU"\n",keyspace, len);
#endif
    }
  }
  gt_free(headerbufferspace);
  gt_free(keyspace);
  if (verbose)
  {
    gt_progressbar_stop();
  }
  if (verbose)
  {
    outputnonmarked(fastakeyqueries,numofqueries);
  }
  fastakeyqueries_delete(fastakeyqueries,numofqueries);
  gt_seq_iterator_delete(seqit);
  return had_err;
}

// Assembly:
subq $0xd8, %rsp
movb %dil, %al
andb $0x1, %al
movb %al, 0xd3(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
movq %r9, 0xa8(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movq $0x0, 0x28(%rsp)
cmpq $0x0, 0xa8(%rsp)
je 0x2525ec
movq 0xa8(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x2525b4
jmp 0x2525ec
movq 0x3e99e5(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2c3a4e(%rip), %rsi    # 0x516013
leaq 0x2c3bf3(%rip), %rdx    # 0x5161bf
leaq 0x327574(%rip), %rcx    # 0x579b47
leaq 0x327399(%rip), %r8     # 0x579973
movl $0x352, %r9d            # imm = 0x352
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2525ee
movb 0xd3(%rsp), %al
movq 0xb8(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x58(%rsp), %rsi
andb $0x1, %al
movzbl %al, %edi
callq 0x252b50
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x252631
movl $0xffffffff, 0xd4(%rsp) # imm = 0xFFFFFFFF
jmp 0x252b3a
movq 0xb0(%rsp), %rdi
callq 0xdf4c0
movq %rax, 0x38(%rsp)
testb $0x1, 0xd3(%rsp)
je 0x252660
movq 0x38(%rsp), %rsi
leaq 0x2d79f1(%rip), %rdi    # 0x52a04a
movb $0x0, %al
callq 0x19070
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x113240
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x252690
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x44(%rsp)
jne 0x2526c0
testb $0x1, 0xd3(%rsp)
je 0x2526c0
movq 0xa0(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x111b70
movq %rax, %rdi
movq 0x38(%rsp), %rsi
callq 0xf9830
jmp 0x2526c2
xorl %eax, %eax
cmpl $-0x1, 0x44(%rsp)
movb %al, 0x1f(%rsp)
je 0x2526e0
movq 0x48(%rsp), %rax
cmpq 0x58(%rsp), %rax
setb %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x2526ed
jmp 0x252ab9
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %r8
leaq 0x98(%rsp), %rsi
leaq 0x68(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0x111ab0
movl %eax, 0x44(%rsp)
cmpl $0x1, 0x44(%rsp)
je 0x252727
jmp 0x252ab9
movq 0x90(%rsp), %rsi
movq 0xa8(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x251bb0
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x78(%rsp)
jne 0x25275b
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x252ab4
movq 0x70(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x25279f
movq 0x80(%rsp), %rdi
movq 0x60(%rsp), %rsi
addq $0x1, %rsi
shlq $0x0, %rsi
leaq 0x3271f0(%rip), %rdx    # 0x579973
movl $0x37b, %ecx            # imm = 0x37B
callq 0xe8540
movq %rax, 0x80(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x2527a1
cmpq $0x0, 0x80(%rsp)
jne 0x2527e4
movq 0x3e97ed(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2c3856(%rip), %rsi    # 0x516013
leaq 0x32739f(%rip), %rdx    # 0x579b63
leaq 0x32737c(%rip), %rcx    # 0x579b47
leaq 0x3271a1(%rip), %r8     # 0x579973
movl $0x37e, %r9d            # imm = 0x37E
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2527e6
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0x60(%rsp), %rdx
callq 0x19330
movq 0x80(%rsp), %rax
movq 0x60(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x80(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x252de0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x58(%rsp), %rax
jae 0x252ab2
jmp 0x25283c
movq 0x50(%rsp), %rcx
xorl %eax, %eax
cmpq 0x58(%rsp), %rcx
movb %al, 0x1e(%rsp)
jae 0x252879
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq 0x80(%rsp), %rsi
callq 0x19980
cmpl $0x0, %eax
sete %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
testb $0x1, %al
jne 0x252886
jmp 0x252ab0
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
testb $0x1, 0x18(%rax)
je 0x2528d3
movq 0x3e96fc(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
leaq 0x3272b2(%rip), %rsi    # 0x579b74
movb $0x0, %al
callq 0x199f0
movl $0x2, %edi
callq 0x19890
movq 0x90(%rsp), %rdi
callq 0x192b0
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
addq $0x80, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x25293d
movq 0x20(%rsp), %rax
addq $0x80, %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rdi
movq 0x28(%rsp), %rsi
shlq $0x0, %rsi
leaq 0x327048(%rip), %rdx    # 0x579973
movl $0x396, %ecx            # imm = 0x396
callq 0xe8540
movq %rax, 0x88(%rsp)
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x1, 0x8(%rax)
jne 0x25299c
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
jne 0x25299c
movq 0x90(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
callq 0xdbd10
jmp 0x252a7a
movq 0x88(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x60(%rsp), %rax
movl %eax, %ecx
movq 0x60(%rsp), %rax
movl %eax, %r8d
movq 0x80(%rsp), %r9
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x8(%rax), %r11
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x10(%rax), %r10
movq 0x90(%rsp), %rax
leaq 0x32719c(%rip), %rdx    # 0x579b95
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x19b90
movq 0x88(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
addq 0x8(%rax), %rsi
addq $-0x1, %rsi
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
subq 0x8(%rax), %rdx
addq $0x1, %rdx
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
callq 0xdbd10
movq 0x30(%rsp), %rax
movq 0x50(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movb $0x1, 0x18(%rax)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x25283c
jmp 0x252ab2
jmp 0x252ab4
jmp 0x2526c2
movq 0x88(%rsp), %rdi
leaq 0x326eab(%rip), %rsi    # 0x579973
movl $0x3bc, %edx            # imm = 0x3BC
callq 0xe88c0
movq 0x80(%rsp), %rdi
leaq 0x326e92(%rip), %rsi    # 0x579973
movl $0x3bd, %edx            # imm = 0x3BD
callq 0xe88c0
testb $0x1, 0xd3(%rsp)
je 0x252afa
callq 0xfa220
testb $0x1, 0xd3(%rsp)
je 0x252b13
movq 0x30(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x252f00
movq 0x30(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x253020
movq 0xa0(%rsp), %rdi
callq 0x111c10
movl 0x44(%rsp), %eax
movl %eax, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
addq $0xd8, %rsp
retq
nopl (%rax)