// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/match_iterator_open.c
// Function: gt_match_iterator_open_next
static GtMatchIteratorStatus gt_match_iterator_open_next(GtMatchIterator *gmpi,
                                                         GtMatch **match,
                                                         GtError *err)
{
  GtUword columncount = 0;
  int readnums;
  GtWord storeinteger[GT_MATCHITER_READNUMS];
  int had_err = 0, i = 0;
  char buffer[BUFSIZ], seqid1[BUFSIZ], seqid2[BUFSIZ], matchtype;
  GtMatchIteratorOpen *mpi = gt_match_iterator_open_cast(gmpi);
  gt_assert(mpi);

  if (mpi->pvt->matchfilep) {
    while (true) {
      if (fgetc(mpi->pvt->matchfilep) == '#') {
        GT_UNUSED char *l = fgets(buffer, BUFSIZ, mpi->pvt->matchfilep);
        mpi->pvt->curpos++;
      } else break;
    }
    fseek(mpi->pvt->matchfilep, -1, SEEK_CUR);
    readnums = fscanf(mpi->pvt->matchfilep, " " GT_WD " %s " GT_WD " %c " GT_WD
                      " %s " GT_WD " %*d %*e " GT_WD " %*f\n",
                      &storeinteger[0],
                      seqid1,
                      &storeinteger[1],
                      &matchtype,
                      &storeinteger[2],
                      seqid2,
                      &storeinteger[3],
                      &storeinteger[4]);
    if (readnums == EOF)
      return GT_MATCHER_STATUS_END;
    if (readnums != GT_MATCHITER_READNUMS + 3)
    {
      GT_MATCHER_OPEN_CANNOTPARSELINE("invalid format");
      had_err = -1;
    }
  } else {
    while (true) {
      while ((buffer[i] = gt_file_xfgetc(mpi->pvt->gtmatchfilep)) != '\n') {
        if (buffer[i] == EOF)
          return GT_MATCHER_STATUS_END;
        i++;
      }
      buffer[i+1] = '\0';
      if (buffer[0] == '#') {
        mpi->pvt->curpos++;
        i = 0;
      } else break;
    }
    if (sscanf(buffer, " " GT_WD " %s " GT_WD " %*c " GT_WD " %s " GT_WD
               " %*d %*e " GT_WD " %*f\n",
               &storeinteger[0],
               seqid1,
               &storeinteger[1],
               &storeinteger[2],
               seqid2,
               &storeinteger[3],
               &storeinteger[4])
               != GT_MATCHITER_READNUMS + 2) {
      GT_MATCHER_OPEN_CANNOTPARSELINE("invalid format");
      had_err = -1;
    }
  }

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

  if (!had_err) {
    *match = gt_match_open_new(seqid1,
                               seqid2,
                               storeinteger[1],
                               storeinteger[1] + storeinteger[0] - 1,
                               storeinteger[3],
                               storeinteger[3] + storeinteger[2] - 1,
                               storeinteger[4],
                               matchtype == 'D' ? GT_MATCH_DIRECT :
                                                  GT_MATCH_REVERSE);
    mpi->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 $0x6048, %rsp           # imm = 0x6048
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x15f8e9
movq %rax, %rdi
movq %r15, %rsi
callq 0x15de4d
testq %rax, %rax
je 0x15fba2
movq %rax, %r15
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x15faa8
callq 0x17c20
cmpl $0x23, %eax
jne 0x15f9a6
leaq 0x40(%rsp), %r12
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdx
movq %r12, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x17c30
movq 0x8(%r15), %rax
incq (%rax)
movq 0x8(%rax), %rdi
callq 0x17c20
cmpl $0x23, %eax
je 0x15f97c
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdi
movl $0x1, %ebp
movq $-0x1, %rsi
movl $0x1, %edx
callq 0x17890
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdi
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r10
leaq 0x28(%rsp), %r11
leaq 0x30(%rsp), %r12
leaq 0x2040(%rsp), %r13
leaq 0x227a8f(%rip), %rsi    # 0x38747e
leaq 0x10(%rsp), %rdx
leaq 0x4040(%rsp), %rcx
leaq 0xf(%rsp), %r9
xorl %eax, %eax
pushq %r12
pushq %r11
pushq %r13
pushq %r10
callq 0x17ea0
addq $0x20, %rsp
cmpl $-0x1, %eax
je 0x15fb8e
cmpl $0x8, %eax
jne 0x15fb37
xorl %r8d, %r8d
movq 0x10(%rsp,%r8,8), %rax
testq %rax, %rax
js 0x15fb63
js 0x15fa46
leaq 0x1(%r8), %rax
cmpq $0x4, %r8
movq %rax, %r8
jb 0x15fa29
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
leaq (%rdx,%rax), %rcx
decq %rcx
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %rax
leaq (%r8,%rax), %r9
decq %r9
xorl %eax, %eax
cmpb $0x44, 0xf(%rsp)
setne %al
leaq 0x4040(%rsp), %rdi
leaq 0x2040(%rsp), %rsi
pushq %rax
pushq 0x38(%rsp)
callq 0x16029a
addq $0x10, %rsp
movq %rax, (%r14)
movq 0x8(%r15), %rax
incq (%rax)
xorl %ebp, %ebp
jmp 0x15fb8e
movq 0x8(%r15), %rax
incq (%rax)
xorl %r12d, %r12d
movq 0x10(%rax), %rdi
callq 0xfedd0
movb %al, 0x40(%rsp,%r12)
cmpb $0xa, %al
je 0x15fad4
movzbl %al, %eax
cmpl $0xff, %eax
je 0x15fb5c
incq %r12
movq 0x8(%r15), %rax
jmp 0x15faab
incl %r12d
movb $0x0, 0x40(%rsp,%r12)
cmpb $0x23, 0x40(%rsp)
je 0x15faa1
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
leaq 0x28(%rsp), %r10
leaq 0x30(%rsp), %r11
subq $0x8, %rsp
leaq 0x2048(%rsp), %r12
leaq 0x22799e(%rip), %rsi    # 0x3874a9
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rdx
leaq 0x4048(%rsp), %rcx
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r12
callq 0x177f0
addq $0x20, %rsp
cmpl $0x7, %eax
je 0x15fa26
movq 0x8(%r15), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x22754c(%rip), %rsi    # 0x387095
leaq 0x22755b(%rip), %r8     # 0x3870ab
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0x15fb89
movl $0x1, %ebp
jmp 0x15fb8e
movq 0x8(%r15), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
incq %r8
leaq 0x227542(%rip), %rsi    # 0x3870ba
leaq 0x22755d(%rip), %r9     # 0x3870dc
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfcb67
movl $0x2, %ebp
movl %ebp, %eax
addq $0x6048, %rsp           # imm = 0x6048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4c5cc