// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r13
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edi, %ebp
testq %r9, %r9
je 0x1b1096
movq %r13, %rdi
callq 0xfcc32
testb %al, %al
jne 0x1b1515
movzbl %bpl, %edi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
jmp 0x1b10a4
movzbl %bpl, %edi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x1b151a
movq %rax, %rbx
testq %rax, %rax
je 0x1b13f3
movq %r14, %rdi
callq 0xff877
movq %rax, %r12
movl %ebp, 0x1c(%rsp)
testb %bpl, %bpl
je 0x1b10da
leaq 0x1a7ea6(%rip), %rdi    # 0x358f76
movq %r12, %rsi
xorl %eax, %eax
callq 0x17070
movq %r14, %rdi
movq %r13, %rsi
callq 0x114f10
movq %rax, %r15
xorl %ebp, %ebp
testq %rax, %rax
sete %bpl
movl 0x1c(%rsp), %eax
xorb $0x1, %al
orb %bpl, %al
jne 0x1b1112
movq %r15, %rdi
movq %r12, %rsi
callq 0x11435e
movq %rax, %rdi
movq %r12, %rsi
callq 0x10ba28
negl %ebp
xorl %r12d, %r12d
testq %r15, %r15
movq %rbx, 0x10(%rsp)
movq %r15, 0x38(%rsp)
je 0x1b13fd
cmpq $0x0, 0x8(%rsp)
movl $0x0, %eax
movq %rax, (%rsp)
je 0x1b141c
leaq -0x20(%rbx), %rax
movq %rax, 0x78(%rsp)
leaq 0x8(%rbx), %rax
movq %rax, 0x68(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, (%rsp)
xorl %r12d, %r12d
movq $0x0, 0x20(%rsp)
movq $0x0, 0x58(%rsp)
movq %r13, 0x70(%rsp)
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r13, %r8
callq 0x11433d
cmpl $0x1, %eax
jne 0x1b1407
movq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdi
movq %r13, %rdx
callq 0x1b0ae8
testq %rax, %rax
je 0x1b140b
movq %rax, %r14
movq 0x28(%rsp), %rdx
cmpq %rdx, 0x58(%rsp)
jae 0x1b11f3
incq %rdx
movq %r12, %rdi
movq %rdx, %rsi
leaq 0x1f5f66(%rip), %rdx    # 0x3a7142
movl $0x37b, %ecx            # imm = 0x37B
callq 0x104461
movq %rax, %r12
movq 0x28(%rsp), %rdx
movq %rdx, 0x58(%rsp)
testq %r12, %r12
je 0x1b1508
movq %r12, %rdi
movq %r14, %rsi
callq 0x17370
movq 0x28(%rsp), %rax
movb $0x0, (%r12,%rax)
movq 0x8(%rsp), %r13
movq %r13, %r15
shlq $0x5, %r15
addq 0x78(%rsp), %r15
cmpq %rbx, %r15
jb 0x1b13cd
movq %r15, %rax
subq %rbx, %rax
sarq %rax
andq $-0x20, %rax
leaq (%rbx,%rax), %rbp
movq (%rbx,%rax), %rsi
movq %r12, %rdi
callq 0x17a40
testl %eax, %eax
je 0x1b1257
js 0x1b1271
addq $0x20, %rbp
movq %rbp, %rbx
jmp 0x1b1278
movq %rbp, %r15
subq 0x10(%rsp), %r15
jbe 0x1b1282
movq -0x20(%rbp), %rsi
movq %r12, %rdi
callq 0x17a40
testl %eax, %eax
jne 0x1b1282
addq $-0x20, %rbp
movq %rbp, %r15
cmpq %r15, %rbx
jbe 0x1b122b
jmp 0x1b13cd
sarq $0x5, %r15
cmpq %r13, %r15
jae 0x1b13cd
movq %r15, %rbx
shlq $0x5, %rbx
movq 0x10(%rsp), %rax
movq (%rax,%rbx), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x17a40
testl %eax, %eax
jne 0x1b13cd
addq 0x68(%rsp), %rbx
incq %r15
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpb $0x1, 0x10(%rbx)
je 0x1b150d
movq 0x30(%rsp), %rdi
callq 0x172f0
movq %rax, %rbp
addq $0x81, %rbp
cmpq %rbp, 0x40(%rsp)
jae 0x1b130d
movq (%rsp), %rdi
movq %rbp, %rsi
leaq 0x1f5e48(%rip), %rdx    # 0x3a7142
movl $0x396, %ecx            # imm = 0x396
callq 0x104461
movq %rax, (%rsp)
movq %rbp, 0x40(%rsp)
movq (%rbx), %r11
movq 0x8(%rbx), %r13
cmpq $0x1, %r11
jne 0x1b1336
movq 0x30(%rsp), %r10
testq %r13, %r13
jne 0x1b133b
movq 0x60(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq %r10, %rdi
jmp 0x1b138a
movq 0x30(%rsp), %r10
movl 0x28(%rsp), %ecx
subq $0x8, %rsp
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq 0x48(%rsp), %rsi
leaq 0x1f600d(%rip), %rdx    # 0x3a7364
movl %ecx, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq %r10
pushq %r13
pushq %r11
callq 0x17c60
addq $0x20, %rsp
movq 0x60(%rsp), %rax
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
leaq (%rax,%rcx), %rsi
decq %rsi
subq %rcx, %rdx
incq %rdx
movq %rbp, %rdi
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %r8
callq 0xfe000
movb $0x1, 0x10(%rbx)
movq 0x8(%rsp), %r13
cmpq %r13, %r15
jae 0x1b13cd
movq 0x18(%rbx), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x17a40
addq $0x20, %rbx
incq %r15
movq 0x20(%rsp), %rcx
incq %rcx
testl %eax, %eax
je 0x1b12c2
movl $0x1, %ebp
testq %r14, %r14
je 0x1b1412
cmpq %r13, 0x20(%rsp)
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %r15
movq 0x70(%rsp), %r13
jb 0x1b117c
jmp 0x1b141c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1b14f4
movq $0x0, (%rsp)
jmp 0x1b141c
movl %eax, %ebp
jmp 0x1b141c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1b141c
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %r15
leaq 0x1f5d1f(%rip), %r14    # 0x3a7142
movq (%rsp), %rdi
movq %r14, %rsi
movl $0x3bc, %edx            # imm = 0x3BC
callq 0x1045eb
movq %r12, %rdi
movq %r14, %rsi
movl $0x3bd, %edx            # imm = 0x3BD
callq 0x1045eb
cmpb $0x0, 0x1c(%rsp)
je 0x1b14bc
callq 0x10bf8a
movq 0x8(%rsp), %r13
testq %r13, %r13
je 0x1b14c3
addq $0x18, %rbx
leaq 0x1f61b2(%rip), %r12    # 0x3a7617
movq %r13, %r14
xorl %r15d, %r15d
cmpb $0x0, (%rbx)
jne 0x1b14b1
movq -0x18(%rbx), %rsi
movq %r12, %rdi
xorl %eax, %eax
callq 0x17070
movq -0x10(%rbx), %rsi
movq -0x8(%rbx), %rdx
movq %rsi, %rax
xorq $0x1, %rax
orq %rdx, %rax
jne 0x1b14a0
leaq 0x1f618d(%rip), %rdi    # 0x3a7626
callq 0x17bd0
jmp 0x1b14ae
leaq 0x1d0945(%rip), %rdi    # 0x381dec
xorl %eax, %eax
callq 0x17070
incq %r15
addq $0x20, %rbx
decq %r14
jne 0x1b146b
jmp 0x1b14c6
movq 0x8(%rsp), %r13
jmp 0x1b14e1
xorl %r15d, %r15d
leaq 0x1f5f7c(%rip), %rdi    # 0x3a7449
movq %r15, %rsi
xorl %eax, %eax
callq 0x17070
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %r15
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1b17ff
movq %r15, %rdi
callq 0x11437f
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x65151
movq %rbp, %rdi
callq 0x6512d
callq 0x650f4