// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/myersapm.c
// Function: gt_edistmyersbitvectorAPM
void gt_edistmyersbitvectorAPM(Myersonlineresources *mor,
                               const GtUchar *pattern,
                               GtUword patternlength,
                               GtUword maxdistance)
{
  GtUword Pv = ~0UL,
                Mv = 0UL,
                Eq,
                Xv,
                Xh,
                Ph,
                Mh,
                score;
  const GtUword Ebit = 1UL << (patternlength-1);
  GtUchar cc;
  GtUword pos;
  const GtReadmode readmode = GT_READMODE_REVERSE;
  GtIdxMatch match;

  gt_initeqsvectorrev(mor->eqsvectorrev,
                   (GtUword) mor->alphasize,
                   pattern,patternlength);
  score = patternlength;
  gt_encseq_reader_reinit_with_readmode(mor->esr, mor->encseq, readmode, 0);
  match.dbabsolute = NULL;
  match.dbsubstring = NULL;
  match.querystartpos = 0;
  match.querylen = patternlength;
  match.alignment = NULL;
  for (pos = 0; pos < mor->totallength; pos++)
  {
    cc = gt_encseq_reader_next_encoded_char(mor->esr);
    if (cc == (GtUchar) GT_SEPARATOR)
    {
      Pv = ~0UL;
      Mv = 0UL;
      score = patternlength;
    } else
    {
      if (cc == (GtUchar) GT_WILDCARD)
      {
        Eq = 0;
      } else
      {
        Eq = mor->eqsvectorrev[(GtUword) cc];   /*  6 */
      }
      Xv = Eq | Mv;                                   /*  7 */
      Xh = (((Eq & Pv) + Pv) ^ Pv) | Eq;              /*  8 */

      Ph = Mv | ~ (Xh | Pv);                          /*  9 */
      Mh = Pv & Xh;                                   /* 10 */

      if (Ph & Ebit)
      {
        score++;
      } else
      {
        if (Mh & Ebit)
        {
          gt_assert(score > 0);
          score--;
        }
      }

      Ph <<= 1;                                       /* 15 */
      Pv = (Mh << 1) | ~ (Xv | Ph);                   /* 17 */
      Mv = Ph & Xv;                                   /* 18 */
      if (score <= maxdistance)
      {
        GtUword dbstartpos = GT_REVERSEPOS(mor->totallength,pos);
        Definedunsignedlong matchlength;

        if (maxdistance > 0)
        {
          matchlength = gt_forwardprefixmatch(mor->encseq,
                                           mor->alphasize,
                                           dbstartpos,
                                           mor->nowildcards,
                                           mor->eqsvector,
                                           pattern,
                                           patternlength,
                                           maxdistance);
        } else
        {
          matchlength.defined = true;
          matchlength.valueunsignedlong = patternlength;
        }
        gt_assert(matchlength.defined || mor->nowildcards);
        if (matchlength.defined)
        {
          match.dbstartpos = dbstartpos;
          match.dblen = (GtUword) matchlength.valueunsignedlong;
          match.distance = score;
          mor->processmatch(mor->processmatchinfo,&match);
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %rbx
leal -0x1(%rdx), %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, 0x28(%rsp)
movq %rsi, %rdx
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movl 0x28(%r14), %esi
movq %rdx, 0x18(%rsp)
movq %rbx, %rcx
callq 0x329c08
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xed48e
movb $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rsp)
movq %rbx, 0x8(%rsp)
movq %rbx, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
cmpq $0x0, 0x10(%r14)
je 0x32aa1d
movq %r14, %rdi
movq $-0x1, 0x10(%rsp)
xorl %ebp, %ebp
movq $-0x1, %r12
xorl %r13d, %r13d
movq 0x8(%rsp), %rbx
movq %r14, (%rsp)
movq (%rdi), %rdi
callq 0xec7be
cmpb $-0x2, %al
je 0x32a913
movzbl %al, %eax
movq 0x8(%rsp), %rsi
movl $0x0, %r14d
movq $-0x1, %r15
cmpl $0xff, %eax
movq (%rsp), %rdi
je 0x32aa02
movq 0x18(%rdi), %rcx
movq (%rcx,%rax,8), %rax
jmp 0x32a919
xorl %eax, %eax
movq (%rsp), %rdi
movq %rax, %rcx
andq %r12, %rcx
addq %r12, %rcx
xorq %r12, %rcx
orq %rax, %rcx
movq %rcx, %r14
orq %r12, %r14
notq %r14
orq %rbp, %r14
andq %r12, %rcx
movq 0x28(%rsp), %rdx
testq %rdx, %r14
je 0x32a946
incq %rbx
jmp 0x32a957
testq %rdx, %rcx
je 0x32a957
testq %rbx, %rbx
je 0x32aa31
decq %rbx
movq %rbx, %rsi
orq %rbp, %rax
addq %r14, %r14
addq %rcx, %rcx
movq %r14, %r15
orq %rax, %r15
notq %r15
orq %rcx, %r15
andq %rax, %r14
movq 0x20(%rsp), %rax
cmpq %rax, %rbx
ja 0x32aa02
movq 0x10(%rdi), %rbp
addq 0x10(%rsp), %rbp
testq %rax, %rax
je 0x32a9c4
movq %rsi, %rbx
movl 0x28(%rdi), %esi
movzbl 0x2c(%rdi), %ecx
movq 0x8(%rdi), %rdi
movq (%rsp), %rdx
movq 0x20(%rdx), %r8
movq %rbp, %rdx
movq 0x18(%rsp), %r9
pushq %rax
pushq 0x10(%rsp)
callq 0x312533
movq %rbx, %rsi
movq 0x10(%rsp), %rdi
addq $0x10, %rsp
jmp 0x32a9cb
movb $0x1, %al
movq 0x8(%rsp), %rdx
testb $0x1, %al
jne 0x32a9d9
cmpb $0x0, 0x2c(%rdi)
je 0x32aa2c
testb $0x1, %al
je 0x32aa02
movq %rbp, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x38(%rdi), %rdi
movq %rsi, %rbx
leaq 0x30(%rsp), %rsi
movq (%rsp), %rax
callq *0x30(%rax)
movq %rbx, %rsi
movq (%rsp), %rdi
incq %r13
decq 0x10(%rsp)
movq %r15, %r12
movq %r14, %rbp
movq %rsi, %rbx
cmpq 0x10(%rdi), %r13
jb 0x32a8d9
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x960a1
callq 0x96068
nop