// File: /workspace/github_c_makefile_star2_O1/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, %rbp
movq %r8, %r15
movq %rcx, %r14
movq %rdx, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movl %edi, %r12d
testq %r9, %r9
je 0x1b9c75
movq %rbp, %rdi
callq 0x101a9a
testb %al, %al
jne 0x1ba39a
testq %rbp, %rbp
je 0x1b9c75
movq %rbp, %rdi
callq 0x101a9a
testb %al, %al
jne 0x1ba39f
movq %r14, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x104263
movq %rax, %r13
movq %r14, %rdi
callq 0x120d23
testq %r13, %r13
movq %rbp, 0x18(%rsp)
movl %r12d, 0xc(%rsp)
je 0x1b9ed4
movq %r15, 0x10(%rsp)
leaq 0x1aa21a(%rip), %rsi    # 0x363ec9
leaq 0x1f6a48(%rip), %rdx    # 0x3b06fe
movq %rax, %rdi
movl $0xfd, %ecx
movq %rbp, %r8
callq 0x101c23
testq %rax, %rax
je 0x1b9eed
movq %rax, %r15
testb %r12b, %r12b
je 0x1b9cf0
movq %r14, %rdi
callq 0x120d23
leaq 0x1f6e7e(%rip), %rdi    # 0x3b0b64
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
movq %r13, %rdi
shlq $0x5, %rdi
leaq 0x1f6a00(%rip), %rsi    # 0x3b06fe
movq %rdi, 0x30(%rsp)
movl $0x106, %edx            # imm = 0x106
callq 0x1092b2
movq %rax, (%rsp)
callq 0x1208f8
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x120e88
cmpl $-0x1, %eax
je 0x1b9d6e
xorl %ebp, %ebp
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
movq 0x18(%rsp), %r9
callq 0x1ba400
testl %eax, %eax
jne 0x1b9f00
movq %r12, %rdi
callq 0x120db4
incq %rbp
movq %r12, %rdi
movq %r15, %rsi
callq 0x120e88
addq $0x20, %rbx
cmpl $-0x1, %eax
jne 0x1b9d2f
movq %r12, %rdi
callq 0x121b03
movq %r15, %rdi
callq 0x101e80
leaq 0x86d(%rip), %rcx       # 0x1ba5f2
movl $0x20, %edx
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x17f60
cmpb $0x0, 0xc(%rsp)
je 0x1b9db1
leaq 0x1f6dd4(%rip), %rdi    # 0x3b0b7b
movq %r13, %rsi
xorl %eax, %eax
callq 0x17070
movq 0x30(%rsp), %rax
leaq (%rbx,%rax), %r15
movq %rbx, %r12
movq %r13, 0x20(%rsp)
cmpq $0x2, %r13
jl 0x1b9e57
movq (%rsp), %rbp
leaq 0x20(%rbp), %r13
leaq 0x1f6923(%rip), %r14    # 0x3b06fe
movq (%rbp), %rdi
movq (%r13), %rbx
movq %rbx, %rsi
callq 0x17a40
testl %eax, %eax
jne 0x1b9e08
movq 0x8(%rbp), %rax
cmpq 0x8(%r13), %rax
jne 0x1b9e08
movq 0x10(%rbp), %rax
cmpq 0x10(%r13), %rax
jne 0x1b9e08
movq %rbp, %r12
jmp 0x1b9e4b
leaq -0x20(%r13), %rax
leaq 0x20(%rbp), %r12
cmpq %rbp, %rax
je 0x1b9e4b
movups 0x8(%r13), %xmm0
movups %xmm0, 0x28(%rbp)
movq %rbx, %rdi
callq 0x172f0
movq 0x20(%rbp), %rdi
leaq 0x1(%rax), %rsi
movq %r14, %rdx
movl $0x7d, %ecx
callq 0x1094e6
movq %rax, 0x20(%rbp)
movq (%r13), %rsi
movq %rax, %rdi
callq 0x17770
addq $0x20, %r13
movq %r12, %rbp
cmpq %r15, %r13
jb 0x1b9ddb
subq (%rsp), %r12
sarq $0x5, %r12
incq %r12
movq 0x20(%rsp), %rsi
subq %r12, %rsi
jbe 0x1b9ef2
cmpb $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rbp
je 0x1b9e8a
leaq 0x1f6d2f(%rip), %rdi    # 0x3b0bb2
xorl %eax, %eax
callq 0x17070
movq %r12, %rax
shlq $0x5, %rax
cmpq 0x30(%rsp), %rax
jge 0x1b9ec6
movq (%rsp), %r14
addq %rax, %r14
leaq 0x1f6858(%rip), %rbx    # 0x3b06fe
movq (%r14), %rdi
movq %rbx, %rsi
movl $0x8e, %edx
callq 0x109670
movq $0x0, (%r14)
addq $0x20, %r14
cmpq %r15, %r14
jb 0x1b9ea6
movq %r12, %r13
movl 0xc(%rsp), %r12d
movq (%rsp), %r14
jmp 0x1b9f29
leaq 0x1f6c6d(%rip), %rsi    # 0x3b0b48
xorl %r14d, %r14d
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
jmp 0x1b9f2e
xorl %r14d, %r14d
jmp 0x1b9f29
movq %r12, %r13
movl 0xc(%rsp), %r12d
movq (%rsp), %r14
jmp 0x1b9f24
movq %r12, %rdi
callq 0x121b03
movq %r15, %rdi
callq 0x101e80
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x1ba3a4
xorl %r14d, %r14d
movl 0xc(%rsp), %r12d
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r15
testq %r14, %r14
je 0x1ba078
movq %r15, %rdi
callq 0x104779
movq %rax, %rbx
testb %r12b, %r12b
je 0x1b9f58
leaq 0x1a8078(%rip), %rdi    # 0x361fc6
movq %rbx, %rsi
xorl %eax, %eax
callq 0x17070
movq %r15, %rdi
movq %rbp, %rsi
callq 0x11a648
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
sete %bpl
movl %r12d, %ecx
xorb $0x1, %cl
orb %bpl, %cl
jne 0x1b9f92
movq %r15, %rdi
movq %rbx, %rsi
callq 0x119a32
movq %rax, %rdi
movq %rbx, %rsi
callq 0x110c6c
xorl %eax, %eax
movq %r15, 0x28(%rsp)
testq %r15, %r15
sete %dl
testq %r13, %r13
sete %cl
orb %dl, %cl
movq %r13, 0x20(%rsp)
movq %r14, (%rsp)
je 0x1ba082
movb %bpl, %al
negl %eax
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x28(%rsp), %rbp
movl %eax, 0x10(%rsp)
leaq 0x1f6730(%rip), %r14    # 0x3b06fe
movq %r15, %rdi
movq %r14, %rsi
movl $0x3bc, %edx            # imm = 0x3BC
callq 0x109670
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3bd, %edx            # imm = 0x3BD
callq 0x109670
cmpb $0x0, 0xc(%rsp)
je 0x1ba363
callq 0x111189
testq %r13, %r13
movq (%rsp), %rax
je 0x1ba346
movq %r13, %rbp
leaq 0x18(%rax), %r13
leaq 0x1f6bba(%rip), %r14    # 0x3b0bd3
leaq 0x1f6bc2(%rip), %r15    # 0x3b0be2
leaq 0x1d1183(%rip), %r12    # 0x38b1aa
xorl %ebx, %ebx
cmpb $0x0, (%r13)
jne 0x1ba060
movq -0x18(%r13), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x17070
movq -0x10(%r13), %rsi
cmpq $0x1, %rsi
jne 0x1ba04f
cmpq $0x0, -0x8(%r13)
je 0x1ba06e
movq -0x8(%r13), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x17070
incq %rbx
addq $0x20, %r13
decq %rbp
jne 0x1ba029
jmp 0x1ba348
movq %r15, %rdi
callq 0x17bd0
jmp 0x1ba05d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1ba37b
movq %r13, %rax
shlq $0x5, %rax
addq %r14, %rax
addq $-0x20, %rax
movq %rax, 0x48(%rsp)
leaq 0x18(%r14), %rax
movq %rax, 0x70(%rsp)
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r12d, %r12d
movq $0x0, 0x50(%rsp)
movq 0x18(%rsp), %r14
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r14, %r8
callq 0x119a11
cmpl $0x1, %eax
jne 0x1b9fc3
movq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdi
movq %r14, %rdx
callq 0x1b963b
movq %rax, %rcx
testq %rax, %rax
je 0x1ba1d5
movq 0x38(%rsp), %rsi
cmpq %rsi, 0x50(%rsp)
jae 0x1ba13c
incq %rsi
movq %rbx, %rdi
leaq 0x1f65df(%rip), %rdx    # 0x3b06fe
movq %rcx, %rbx
movl $0x37b, %ecx            # imm = 0x37B
callq 0x1094e6
movq %rbx, %rcx
movq %rax, %rbx
movq 0x38(%rsp), %rax
movq %rax, 0x50(%rsp)
testq %rbx, %rbx
je 0x1ba395
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
movq %rcx, 0x30(%rsp)
movq %rcx, %rsi
callq 0x17370
movq 0x38(%rsp), %rax
movb $0x0, (%rbx,%rax)
movq %r13, %rbp
movq 0x48(%rsp), %rax
cmpq (%rsp), %rax
jb 0x1ba1e8
movq (%rsp), %r14
movq 0x48(%rsp), %rbp
movq %rbp, %rax
subq %r14, %rax
sarq %rax
andq $-0x20, %rax
leaq (%r14,%rax), %r13
movq (%r14,%rax), %rsi
movq %rbx, %rdi
callq 0x17a40
testl %eax, %eax
je 0x1ba1a6
js 0x1ba1bf
addq $0x20, %r13
movq %r13, %r14
jmp 0x1ba1c6
movq %r13, %rbp
subq (%rsp), %rbp
jbe 0x1ba1df
movq -0x20(%r13), %rsi
movq %rbx, %rdi
callq 0x17a40
testl %eax, %eax
jne 0x1ba1df
addq $-0x20, %r13
movq %r13, %rbp
cmpq %rbp, %r14
jbe 0x1ba17a
movq 0x20(%rsp), %r13
movq %r13, %rbp
jmp 0x1ba1e8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1ba32f
sarq $0x5, %rbp
movq 0x20(%rsp), %r13
movl $0x1, %eax
movq %r13, %rcx
subq %rbp, %r13
jbe 0x1ba302
leaq (%rcx,%r12), %rax
subq %rbp, %rax
movq %rax, 0x78(%rsp)
shlq $0x5, %rbp
addq 0x70(%rsp), %rbp
movq -0x18(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17a40
testl %eax, %eax
jne 0x1ba316
cmpb $0x1, (%rbp)
je 0x1ba38d
movq 0x40(%rsp), %rdi
callq 0x172f0
movq %rax, %r14
addq $0x81, %r14
movq 0x10(%rsp), %rsi
cmpq %r14, %rsi
jae 0x1ba26a
movq %r15, %rdi
movq %r14, %rsi
leaq 0x1f64a4(%rip), %rdx    # 0x3b06fe
movl $0x396, %ecx            # imm = 0x396
callq 0x1094e6
movq %rax, %r15
movq %r14, %rsi
movq -0x10(%rbp), %r10
cmpq $0x1, %r10
movq %rsi, 0x10(%rsp)
jne 0x1ba280
cmpq $0x0, -0x8(%rbp)
je 0x1ba2ee
movl 0x38(%rsp), %ecx
subq $0x8, %rsp
movq %r15, %rdi
leaq 0x1f668e(%rip), %rdx    # 0x3b0920
movl %ecx, %r8d
movq %rbx, %r9
xorl %eax, %eax
pushq 0x48(%rsp)
pushq -0x8(%rbp)
pushq %r10
callq 0x17c60
addq $0x20, %rsp
movq 0x68(%rsp), %rax
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rdx
leaq (%rax,%rcx), %rsi
decq %rsi
subq %rcx, %rdx
incq %rdx
movq %r15, %rdi
movq 0x60(%rsp), %rcx
movq 0x58(%rsp), %r8
callq 0x102ec0
movb $0x1, (%rbp)
incq %r12
addq $0x20, %rbp
decq %r13
jne 0x1ba20e
jmp 0x1ba311
movq 0x40(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x80(%rsp), %rdx
jmp 0x1ba2c9
movq %rcx, %r13
movq 0x18(%rsp), %r14
movq 0x28(%rsp), %rbp
jmp 0x1ba32a
movq 0x78(%rsp), %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %r14
movq 0x28(%rsp), %rbp
movl $0x1, %eax
movq 0x30(%rsp), %rcx
testq %rcx, %rcx
je 0x1b9fc3
cmpq %r13, %r12
jb 0x1ba0c2
jmp 0x1b9fc3
xorl %ebx, %ebx
leaq 0x1f66b6(%rip), %rdi    # 0x3b0a05
movq %rbx, %rsi
xorl %eax, %eax
callq 0x17070
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %rbp
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x1ba3a4
movq %rbp, %rdi
callq 0x119a53
movl 0x10(%rsp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x66925
callq 0x66949
callq 0x668ec
callq 0x668b3