// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/esa-mmsearch.c
// Function: gt_querysubstringmatchiterator_next
int gt_querysubstringmatchiterator_next(GtQuerysubstringmatchiterator *qsmi,
                                        GtError *err)
{
  gt_assert(qsmi != NULL);
  while (true)
  {
    if (qsmi->query_seqlen < qsmi->userdefinedleastlength)
    {
      if (qsmi->seqit != NULL)
      {
        int retval = gt_seq_iterator_next(qsmi->seqit,
                                          &qsmi->query_for_seqit,
                                          &qsmi->query_seqlen,
                                          &qsmi->desc,
                                          err);
        if (retval < 0)
        {
          return -1; /* error */
        }
        if (retval == 0)
        {
          return 1; /* no more sequences */
        }
        gt_assert(qsmi->query_seqlen > 0 && qsmi->query_for_seqit != NULL);
        qsmi->queryrep.sequence = qsmi->query_for_seqit;
      } else
      {
        if (qsmi->queryunitnum == qsmi->query_encseq_numofsequences)
        {
          return 1;
        }
        qsmi->queryrep.startpos = gt_encseq_seqstartpos(qsmi->queryrep.encseq,
                                                        qsmi->queryunitnum);
        qsmi->query_seqlen = gt_encseq_seqlength(qsmi->queryrep.encseq,
                                                 qsmi->queryunitnum);
      }
      gt_assert(qsmi->query_seqlen > 0);
      qsmi->queryrep.seqlen = qsmi->query_seqlen;
      qsmi->querysubstring.currentoffset = 0;
    }
    if (qsmi->query_seqlen >= qsmi->userdefinedleastlength)
    {
      if (!qsmi->mmsi_defined)
      {
        gt_mmsearchiterator_reinit(qsmi->mmsi,
                                   qsmi->dbencseq,
                                   qsmi->suftabpart,
                                   0, /* l */
                                   qsmi->numberofsuffixes - 1, /* r */
                                   0, /* offset */
                                   qsmi->db_readmode,
                                   &qsmi->querysubstring,
                                   qsmi->userdefinedleastlength);
        qsmi->mmsi_defined = true;
      } else
      {
        if (gt_mmsearchiterator_next(&qsmi->dbstart,qsmi->mmsi))
        {
          GtUword extend;

          if (gt_mmsearch_isleftmaximal(qsmi->dbencseq,
                                        qsmi->db_readmode,
                                        qsmi->dbstart,
                                        &qsmi->querysubstring))
          {
            extend = gt_mmsearch_extendright(qsmi->dbencseq,
                                             qsmi->mmsi->esr,
                                             qsmi->db_readmode,
                                             qsmi->totallength,
                                             qsmi->dbstart +
                                               qsmi->userdefinedleastlength,
                                             &qsmi->querysubstring,
                                             qsmi->userdefinedleastlength);
            qsmi->matchlength = qsmi->userdefinedleastlength + extend;
            return 0;
          }
        } else
        {
          qsmi->mmsi_defined = false;
          if (qsmi->querysubstring.currentoffset +
              qsmi->userdefinedleastlength < qsmi->query_seqlen)
          {
            qsmi->querysubstring.currentoffset++;
          } else
          {
            qsmi->query_seqlen = 0;
            qsmi->queryunitnum++;
          }
        }
      }
    } else
    {
      qsmi->query_seqlen = 0;
      qsmi->queryunitnum++;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1ad412
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x78(%rdi), %r15
leaq 0x70(%rdi), %r12
leaq 0xa8(%rdi), %r13
leaq 0x60(%rdi), %rax
movq %rax, 0x8(%rsp)
leaq 0x88(%rdi), %rbp
movq %r12, 0x10(%rsp)
movq 0x78(%r14), %rax
cmpq 0x28(%r14), %rax
jae 0x1ad2c2
movq 0x80(%r14), %rdi
testq %rdi, %rdi
je 0x1ad257
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rbx, %r8
callq 0x119a11
testl %eax, %eax
js 0x1ad28e
je 0x1ad298
cmpq $0x0, (%r15)
je 0x1ad40d
movq (%r12), %rax
testq %rax, %rax
je 0x1ad40d
movq %rax, 0x38(%r14)
movb $0x1, %al
jmp 0x1ad2a2
movq 0x98(%r14), %rsi
cmpq 0xa0(%r14), %rsi
je 0x1ad3ed
movq 0x40(%r14), %rdi
callq 0xefce0
movq %rax, 0x50(%r14)
movq 0x40(%r14), %rdi
movq 0x98(%r14), %rsi
callq 0xeffd3
movq %rax, 0x78(%r14)
jmp 0x1ad2aa
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
jmp 0x1ad2a0
movl $0x1, 0x4(%rsp)
xorl %eax, %eax
testb %al, %al
je 0x1ad3f5
movq (%r15), %rax
testq %rax, %rax
je 0x1ad408
movq %rax, 0x58(%r14)
movq $0x0, 0x68(%r14)
movq 0x28(%r14), %rax
cmpq %rax, 0x78(%r14)
jae 0x1ad2e0
movq $0x0, 0x78(%r14)
incq 0x98(%r14)
jmp 0x1ad207
cmpb $0x0, 0xb0(%r14)
je 0x1ad388
movq 0x30(%r14), %rsi
movq %rbp, %rdi
callq 0x1ac8f9
testb %al, %al
je 0x1ad3c4
movq %rbp, %r12
movq %r13, %rbp
movq %rbx, %r13
movq (%r14), %rdi
movl 0x10(%r14), %esi
movq 0x88(%r14), %rdx
movq 0x8(%rsp), %rcx
callq 0x1ad9b7
movl %eax, %ebx
testb %al, %al
je 0x1ad370
movq (%r14), %rdi
movq 0x30(%r14), %rax
movq 0x28(%rax), %rsi
movl 0x10(%r14), %edx
movq 0x20(%r14), %rcx
movq 0x28(%r14), %rax
movq 0x88(%r14), %r8
addq %rax, %r8
subq $0x8, %rsp
movq 0x10(%rsp), %r9
pushq %rax
callq 0x1ad9fd
addq $0x10, %rsp
addq 0x28(%r14), %rax
movq %rax, 0x90(%r14)
movl $0x0, 0x4(%rsp)
testb %bl, %bl
movq %r13, %rbx
movq %rbp, %r13
movq %r12, %rbp
movq 0x10(%rsp), %r12
je 0x1ad207
jmp 0x1ad3f5
movq 0x30(%r14), %rdi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x18(%r14), %r8
decq %r8
movl 0x10(%r14), %r10d
subq $0x8, %rsp
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq %rax
pushq 0x18(%rsp)
pushq %r10
callq 0x1ad417
addq $0x20, %rsp
movb $0x1, 0xb0(%r14)
jmp 0x1ad207
movb $0x0, 0xb0(%r14)
movq 0x68(%r14), %rax
movq 0x28(%r14), %rcx
addq %rax, %rcx
cmpq 0x78(%r14), %rcx
jae 0x1ad2cc
incq %rax
movq %rax, 0x68(%r14)
jmp 0x1ad207
movl $0x1, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x63a49
callq 0x63a10
callq 0x63a82