// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/match_iterator_blast.c
// Function: gt_match_iterator_blast_next
static GtMatchIteratorStatus gt_match_iterator_blast_next(GtMatchIterator *mi,
                                                          GtMatch **match,
                                                          GtError *err)
{
  gt_assert(mi);
  GtUword columncount = 0;
  GtWord storeinteger[GT_BLASTITER_READNUMS], tmp;
  double e_value;
  float bitscore, identity;
  bool reverse = false;
  char query_seq[BUFSIZ], db_seq[BUFSIZ], buffer[BUFSIZ];
  int had_err = 0, i = 0, readvalues = 0;
  GtMatchIteratorBlast *mib = gt_match_iterator_blast_cast(mi);

  if (mib->pvt->matchfilep) {
    if (!mib->pvt->process) {
      while (true) {
        if (fgetc(mib->pvt->matchfilep) == '#') {
          GT_UNUSED char *l = fgets(buffer, BUFSIZ, mib->pvt->matchfilep);
          mib->pvt->curpos++;
        } else break;
      }
    }
    if (!mib->pvt->process)
      fseek(mib->pvt->matchfilep, -1, SEEK_CUR);
    readvalues = fscanf(mib->pvt->matchfilep,
                        "%s %s %f " GT_WD " " GT_WD " " GT_WD " " GT_WD " "
                        GT_WD " " GT_WD " " GT_WD " %lg %f\n",
                        query_seq, db_seq, &identity,
                        &storeinteger[0], &storeinteger[5], &storeinteger[6],
                        &storeinteger[1], &storeinteger[2], &storeinteger[3],
                        &storeinteger[4], &e_value, &bitscore);
    if (readvalues == EOF)
      return GT_MATCHER_STATUS_END;
    if (readvalues != GT_BLASTITER_READVALUES)
    {
      GT_MATCHER_BLAST_CANNOTPARSELINE("invalid format");
      had_err = -1;
    }
  } else {
    while (true) {
      while ((buffer[i] = gt_file_xfgetc(mib->pvt->gtmatchfilep)) != '\n') {
        if (buffer[i] == EOF)
          return GT_MATCHER_STATUS_END;
        i++;
      }
      buffer[i+1] = '\0';
      if (buffer[0] == '#') {
        mib->pvt->curpos++;
        i = 0;
      } else break;
    }
    if ((readvalues = sscanf(buffer, "%s %s %f " GT_WD " " GT_WD " " GT_WD " "
                             GT_WD " " GT_WD " " GT_WD " " GT_WD " %lg " "%f\n",
                             query_seq, db_seq, &identity, &storeinteger[0],
                             &storeinteger[5], &storeinteger[6],
                             &storeinteger[1], &storeinteger[2],
                             &storeinteger[3], &storeinteger[4], &e_value,
                             &bitscore)) != GT_BLASTITER_READVALUES) {
      GT_MATCHER_BLAST_CANNOTPARSELINE("invalid format");
      had_err = -1;
    }
  }

  for (columncount = 0; !had_err &&
                        columncount < (GtUword) (GT_BLASTITER_READNUMS);
       columncount++) {
    if (storeinteger[columncount] < 0) {
         GT_MATCHER_BLAST_CANNOTPARSECOLUMN("non-negative integer expected");
          had_err = -1;
     }
   }

  if (!had_err) {
    if (storeinteger[1] > storeinteger[2]) {
      tmp = storeinteger[1];
      gt_assert(!reverse);
      reverse = true;
      storeinteger[1] = storeinteger[2];
      storeinteger[2] = tmp;
    }
    if (storeinteger[3] > storeinteger[4]) {
      tmp = storeinteger[3];
      gt_assert(!reverse);
      reverse = true;
      storeinteger[3] = storeinteger[4];
      storeinteger[4] = tmp;
    }
    *match = gt_match_blast_new_extended(query_seq,
                                         db_seq,
                                         storeinteger[1],
                                         storeinteger[2],
                                         storeinteger[3],
                                         storeinteger[4],
                                         e_value,
                                         bitscore,
                                         storeinteger[0],
                                         identity,
                                         storeinteger[5],
                                         storeinteger[6],
                                         reverse ? GT_MATCH_REVERSE
                                                 : GT_MATCH_DIRECT);
    mib->pvt->curpos++;
    return GT_MATCHER_STATUS_OK;
  }
  else
  {
    return GT_MATCHER_STATUS_ERROR;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6068, %rsp           # imm = 0x6068
testq %rdi, %rdi
je 0x15e870
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
callq 0x15df92
movq %rax, %rdi
movq %r14, %rsi
callq 0x15de4d
movq %rax, %r14
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x15e6a0
cmpb $0x0, 0x20(%rax)
jne 0x15e5f2
callq 0x17c20
cmpl $0x23, %eax
jne 0x15e5f2
leaq 0x60(%rsp), %r12
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdx
movq %r12, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x17c30
movq 0x8(%r14), %rax
incq (%rax)
movq 0x8(%rax), %rdi
callq 0x17c20
cmpl $0x23, %eax
je 0x15e5c8
movq 0x8(%r14), %rax
cmpb $0x0, 0x20(%rax)
movq %rbx, 0x50(%rsp)
movq %r15, 0x8(%rsp)
jne 0x15e61f
movq 0x8(%rax), %rdi
movq $-0x1, %rsi
movl $0x1, %edx
callq 0x17890
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x40(%rsp), %r11
leaq 0x18(%rsp), %r12
leaq 0x20(%rsp), %r13
leaq 0x28(%rsp), %rbp
leaq 0x30(%rsp), %rbx
leaq 0x4(%rsp), %r15
leaq 0x58(%rsp), %r10
leaq 0x228a1b(%rip), %rsi    # 0x387068
leaq 0x4060(%rsp), %rdx
leaq 0x2060(%rsp), %rcx
movq %rsp, %r8
leaq 0x10(%rsp), %r9
movl $0x0, %eax
pushq %r15
pushq %r10
pushq %rbx
pushq %rbp
pushq %r13
pushq %r12
pushq %r11
leaq 0x70(%rsp), %r10
pushq %r10
callq 0x17ea0
addq $0x40, %rsp
cmpl $-0x1, %eax
jne 0x15e74a
movl $0x1, %eax
jmp 0x15e85e
movq 0x8(%r14), %rax
incq (%rax)
xorl %r12d, %r12d
movq 0x10(%rax), %rdi
callq 0xfedd0
movb %al, 0x60(%rsp,%r12)
cmpb $0xa, %al
je 0x15e6c8
movzbl %al, %eax
cmpl $0xff, %eax
je 0x15e68f
incq %r12
movq 0x8(%r14), %rax
jmp 0x15e6a3
incl %r12d
movb $0x0, 0x60(%rsp,%r12)
cmpb $0x23, 0x60(%rsp)
je 0x15e699
movq %r15, 0x8(%rsp)
movq %rbx, 0x50(%rsp)
leaq 0x40(%rsp), %r11
leaq 0x18(%rsp), %r12
leaq 0x20(%rsp), %rbx
leaq 0x28(%rsp), %r15
leaq 0x30(%rsp), %r13
leaq 0x4(%rsp), %rbp
leaq 0x58(%rsp), %r10
leaq 0x22895c(%rip), %rsi    # 0x387068
leaq 0x60(%rsp), %rdi
leaq 0x4060(%rsp), %rdx
leaq 0x2060(%rsp), %rcx
movq %rsp, %r8
leaq 0x10(%rsp), %r9
movl $0x0, %eax
pushq %rbp
pushq %r10
pushq %r13
pushq %r15
pushq %rbx
pushq %r12
pushq %r11
leaq 0x70(%rsp), %r10
pushq %r10
callq 0x177f0
addq $0x40, %rsp
cmpl $0xc, %eax
jne 0x15e798
xorl %r8d, %r8d
movq 0x50(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq 0x10(%rsp,%r8,8), %rax
testq %rax, %rax
js 0x15e7bf
js 0x15e775
leaq 0x1(%r8), %rax
cmpq $0x6, %r8
movq %rax, %r8
jb 0x15e75c
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rsi
cmpq %rsi, %rdx
jle 0x15e7e9
movq %rsi, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movb $0x1, %al
movq %rdx, %rcx
movq %rsi, %rdx
jmp 0x15e7ee
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x2288eb(%rip), %rsi    # 0x387095
leaq 0x2288fa(%rip), %r8     # 0x3870ab
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0x15e7e2
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
incq %r8
leaq 0x2288e6(%rip), %rsi    # 0x3870ba
leaq 0x228901(%rip), %r9     # 0x3870dc
xorl %eax, %eax
callq 0xfcb67
movl $0x2, %eax
jmp 0x15e85e
xorl %eax, %eax
movq %rsi, %rcx
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r8
cmpq %r8, %rsi
jle 0x15e812
testb %al, %al
jne 0x15e875
movq %r8, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movb $0x1, %al
movq %rsi, %r9
jmp 0x15e818
movq %r8, %r9
movq %rsi, %r8
movsd 0x58(%rsp), %xmm0
movss 0x4(%rsp), %xmm1
cvtss2sd (%rsp), %xmm2
movzbl %al, %eax
leaq 0x4060(%rsp), %rdi
leaq 0x2060(%rsp), %rsi
pushq %rax
pushq 0x48(%rsp)
pushq 0x48(%rsp)
pushq 0x28(%rsp)
callq 0x15dc5d
addq $0x20, %rsp
movq %rax, (%rbx)
movq 0x8(%r14), %rax
incq (%rax)
xorl %eax, %eax
addq $0x6068, %rsp           # imm = 0x6068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4c15e
callq 0x4c125