// File: /workspace/github_c_makefile_star2_O1/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
movq %rdx, 0x50(%rsp)
testq %rdi, %rdi
je 0x1665c2
movq %rsi, %r15
movq %rdi, %r14
callq 0x165cbf
movq %rax, %rdi
movq %r14, %rsi
callq 0x165b75
movq %rax, %r14
movq 0x8(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x1663d5
cmpb $0x0, 0x20(%rax)
jne 0x166327
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x17c20
cmpl $0x23, %eax
jne 0x166327
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 0x1662fd
movq %r15, 0x48(%rsp)
movq 0x8(%r14), %rax
cmpb $0x0, 0x20(%rax)
jne 0x16634b
movq 0x8(%rax), %rdi
movq $-0x1, %rsi
movl $0x1, %edx
callq 0x17890
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x18(%rsp), %rbx
leaq 0x20(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0xc(%rsp), %r10
leaq 0x58(%rsp), %r11
leaq 0x22a0d0(%rip), %rsi    # 0x390448
xorl %ebp, %ebp
leaq 0x4060(%rsp), %rdx
leaq 0x2060(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
movl $0x0, %eax
pushq %r10
pushq %r11
pushq %r13
pushq %r12
pushq %r15
pushq %rbx
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
callq 0x17ea0
addq $0x40, %rsp
cmpl $-0x1, %eax
jne 0x16647b
movl $0x1, %eax
jmp 0x1665b0
movq 0x8(%r14), %rax
incq (%rax)
xorl %ebx, %ebx
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
callq 0x103ca0
movb %al, 0x60(%rsp,%rbx)
cmpb $0xa, %al
je 0x1663fb
movzbl %al, %eax
cmpl $0xff, %eax
je 0x1663c4
incq %rbx
jmp 0x1663d7
incl %ebx
movb $0x0, 0x60(%rsp,%rbx)
cmpb $0x23, 0x60(%rsp)
je 0x1663ce
movq %r15, 0x48(%rsp)
leaq 0x18(%rsp), %rbx
leaq 0x20(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0xc(%rsp), %r10
leaq 0x58(%rsp), %r11
leaq 0x22a015(%rip), %rsi    # 0x390448
xorl %ebp, %ebp
leaq 0x60(%rsp), %rdi
leaq 0x4060(%rsp), %rdx
leaq 0x2060(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x10(%rsp), %r9
movl $0x0, %eax
pushq %r10
pushq %r11
pushq %r13
pushq %r12
pushq %r15
pushq %rbx
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
callq 0x177f0
addq $0x40, %rsp
movb $0x1, %bl
cmpl $0xc, %eax
je 0x1664ae
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x229fe1(%rip), %rsi    # 0x390475
leaq 0x229ff0(%rip), %r8     # 0x39048b
xorl %ebx, %ebx
movq 0x50(%rsp), %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %bl, %bl
je 0x166505
leaq 0x229fe1(%rip), %r12    # 0x39049a
leaq 0x229ffc(%rip), %r13    # 0x3904bc
xorl %r15d, %r15d
cmpq $0x0, 0x10(%rsp,%r15,8)
jns 0x1664f1
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x1(%r15), %r8
movq 0x50(%rsp), %rdi
movq %r12, %rsi
movq %r13, %r9
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %ebp, %ebp
sete %bl
jne 0x166505
leaq 0x1(%r15), %rax
cmpq $0x6, %r15
movq %rax, %r15
jb 0x1664c3
movl $0x2, %eax
testb %bl, %bl
je 0x1665b0
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, %rax
jle 0x16652f
movq %rcx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x1, %al
jmp 0x166531
xorl %eax, %eax
movq 0x48(%rsp), %rbx
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rdx
cmpq %rdx, %rcx
jle 0x166555
testb %al, %al
jne 0x1665c7
movq %rdx, 0x28(%rsp)
movq %rcx, 0x30(%rsp)
movb $0x1, %al
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
movq 0x30(%rsp), %r9
movsd 0x58(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
cvtss2sd 0x8(%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 0x165985
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 0x4cf71
callq 0x4cf38