// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
testq %rdi, %rdi
je 0x1a49b3
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x78(%rdi), %r12
leaq 0x70(%rdi), %r13
leaq 0xa8(%rdi), %rbp
leaq 0x60(%rdi), %r14
leaq 0x88(%rdi), %rax
movq %rax, (%rsp)
movq 0x28(%rbx), %r10
movq 0x78(%rbx), %rax
cmpq %r10, %rax
jae 0x1a4898
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x1a484a
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x11433d
testl %eax, %eax
js 0x1a4955
je 0x1a494e
movq (%r12), %rax
testq %rax, %rax
je 0x1a49a9
movq (%r13), %rcx
testq %rcx, %rcx
je 0x1a49a9
movq %rcx, 0x38(%rbx)
jmp 0x1a4888
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0x1a494e
movq 0x40(%rbx), %rdi
callq 0xeb6ee
movq %rax, 0x50(%rbx)
movq 0x40(%rbx), %rdi
movq 0x98(%rbx), %rsi
callq 0xeb9d2
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0x1a49ae
movq %rax, 0x58(%rbx)
movq $0x0, 0x68(%rbx)
movq 0x28(%rbx), %r10
cmpq %r10, %rax
jae 0x1a48b1
movq $0x0, 0x78(%rbx)
incq 0x98(%rbx)
jmp 0x1a47ee
movq 0x30(%rbx), %rax
cmpb $0x0, 0xb0(%rbx)
je 0x1a48ed
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x1a3ee5
testb %al, %al
je 0x1a4926
movq (%rbx), %rdi
movl 0x10(%rbx), %esi
movq 0x88(%rbx), %rdx
movq %r14, %rcx
callq 0x1a4eda
testb %al, %al
je 0x1a47ee
jmp 0x1a495c
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %r8
decq %r8
movl 0x10(%rbx), %r11d
subq $0x8, %rsp
movq %rax, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq %r10
pushq %r14
pushq %r11
callq 0x1a49b8
addq $0x20, %rsp
movb $0x1, 0xb0(%rbx)
jmp 0x1a47ee
movb $0x0, 0xb0(%rbx)
movq 0x68(%rbx), %rax
movq 0x28(%rbx), %rcx
addq %rax, %rcx
cmpq 0x78(%rbx), %rcx
jae 0x1a489d
incq %rax
movq %rax, 0x68(%rbx)
jmp 0x1a47ee
movl $0x1, %eax
jmp 0x1a499a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x1a499a
movq (%rbx), %rdi
movq 0x30(%rbx), %rax
movq 0x28(%rax), %rsi
movl 0x10(%rbx), %edx
movq 0x20(%rbx), %rcx
movq 0x28(%rbx), %rax
movq 0x88(%rbx), %r8
addq %rax, %r8
subq $0x8, %rsp
movq %r14, %r9
pushq %rax
callq 0x1a4f20
addq $0x10, %rsp
addq 0x28(%rbx), %rax
movq %rax, 0x90(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6236a
callq 0x623a3
callq 0x623dc