// File: /workspace/github_c_makefile_star2_O1/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 $0x6058, %rsp           # imm = 0x6058
movq %rdx, 0x48(%rsp)
movq %rsi, %r15
movq %rdi, %r14
callq 0x167669
movq %rax, %rdi
movq %r14, %rsi
callq 0x165b75
testq %rax, %rax
je 0x16795d
movq %rax, %r14
movq 0x8(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x1678ae
movq %r15, 0x40(%rsp)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x17c20
cmpl $0x23, %eax
jne 0x167733
leaq 0x50(%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 0x167709
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
movl $0x1, %ebp
movq $-0x1, %rsi
movl $0x1, %edx
callq 0x17890
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r10
leaq 0x28(%rsp), %r11
leaq 0x30(%rsp), %r15
leaq 0x2050(%rsp), %r12
leaq 0x2290db(%rip), %rsi    # 0x390857
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdx
leaq 0x4050(%rsp), %rcx
leaq 0xf(%rsp), %r9
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r12
pushq %r10
callq 0x17ea0
addq $0x20, %rsp
cmpl $-0x1, %eax
je 0x167949
movb $0x1, %r15b
cmpl $0x8, %eax
je 0x1677e1
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x228caf(%rip), %rsi    # 0x390475
leaq 0x228cbe(%rip), %r8     # 0x39048b
xorl %r15d, %r15d
movq 0x48(%rsp), %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %r15b, %r15b
je 0x167839
leaq 0x228cad(%rip), %r12    # 0x39049a
leaq 0x228cc8(%rip), %r13    # 0x3904bc
xorl %ebp, %ebp
cmpq $0x0, 0x10(%rsp,%rbp,8)
jns 0x167824
movq 0x8(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rdx
leaq 0x1(%rbp), %r8
movq 0x48(%rsp), %rdi
movq %r12, %rsi
movq %r13, %r9
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %ebx, %ebx
sete %r15b
jne 0x167839
leaq 0x1(%rbp), %rax
cmpq $0x4, %rbp
movq %rax, %rbp
jb 0x1677f6
movl $0x2, %ebp
testb %r15b, %r15b
je 0x167949
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 0x4050(%rsp), %rdi
leaq 0x2050(%rsp), %rsi
pushq %rax
pushq 0x38(%rsp)
callq 0x16805a
addq $0x10, %rsp
movq 0x40(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
incq (%rax)
xorl %ebp, %ebp
jmp 0x167949
movq 0x8(%r14), %rax
incq (%rax)
xorl %ebx, %ebx
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
callq 0x103ca0
movb %al, 0x50(%rsp,%rbx)
cmpb $0xa, %al
je 0x1678d4
movzbl %al, %eax
cmpl $0xff, %eax
je 0x167944
incq %rbx
jmp 0x1678b0
incl %ebx
movb $0x0, 0x50(%rsp,%rbx)
cmpb $0x23, 0x50(%rsp)
je 0x1678a7
movq %r15, 0x40(%rsp)
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
leaq 0x28(%rsp), %r10
leaq 0x30(%rsp), %r11
subq $0x8, %rsp
leaq 0x2058(%rsp), %r15
leaq 0x228f74(%rip), %rsi    # 0x390882
xorl %ebx, %ebx
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rdx
leaq 0x4058(%rsp), %rcx
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r15
callq 0x177f0
addq $0x20, %rsp
movb $0x1, %r15b
cmpl $0x7, %eax
jne 0x1677b4
jmp 0x1677e1
movl $0x1, %ebp
movl %ebp, %eax
addq $0x6058, %rsp           # imm = 0x6058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4d44f