// File: /workspace/github_c_makefile_star2_O3/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 0x31f970
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xe8eed
movb $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rsp)
movq %rbx, (%rsp)
movq %rbx, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
cmpq $0x0, 0x10(%r14)
je 0x3206dd
movq %r14, %r8
movq $-0x1, 0x10(%rsp)
xorl %ebp, %ebp
movq $-0x1, %r12
xorl %r13d, %r13d
movq (%rsp), %r14
movq %r8, 0x8(%rsp)
movq (%r8), %rdi
callq 0xe8186
cmpb $-0x2, %al
je 0x3205d1
movzbl %al, %eax
movq (%rsp), %rsi
movl $0x0, %ebx
movq $-0x1, %r15
cmpl $0xff, %eax
movq 0x8(%rsp), %r8
je 0x3206c2
movq 0x18(%r8), %rcx
movq (%rcx,%rax,8), %rax
jmp 0x3205d8
xorl %eax, %eax
movq 0x8(%rsp), %r8
movq %rax, %rcx
andq %r12, %rcx
addq %r12, %rcx
xorq %r12, %rcx
orq %rax, %rcx
movq %rcx, %rbx
orq %r12, %rbx
notq %rbx
orq %rbp, %rbx
andq %r12, %rcx
movq 0x28(%rsp), %rdx
testq %rdx, %rbx
je 0x320605
incq %r14
jmp 0x320616
testq %rdx, %rcx
je 0x320616
testq %r14, %r14
je 0x3206ec
decq %r14
movq %r14, %rsi
orq %rbp, %rax
addq %rbx, %rbx
addq %rcx, %rcx
movq %rbx, %r15
orq %rax, %r15
notq %r15
orq %rcx, %r15
andq %rax, %rbx
movq 0x20(%rsp), %rax
cmpq %rax, %r14
ja 0x3206c2
movq 0x10(%r8), %rbp
addq 0x10(%rsp), %rbp
movq (%rsp), %rdx
testq %rax, %rax
je 0x320688
movq %rsi, %r12
movl 0x28(%r8), %esi
movzbl 0x2c(%r8), %ecx
movq 0x8(%r8), %rdi
movq %r8, %r14
movq 0x20(%r8), %r8
movq %rbp, %rdx
movq 0x18(%rsp), %r9
pushq %rax
pushq 0x8(%rsp)
callq 0x3086e7
addq $0x10, %rsp
testb $0x1, %al
je 0x3206b5
movq %r14, %r8
movq %r12, %rsi
movq %rbp, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x38(%r8), %rdi
movq %rsi, %r14
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rax
callq *0x30(%rax)
movq %r14, %rsi
movq 0x8(%rsp), %r8
jmp 0x3206c2
cmpb $0x0, 0x2c(%r14)
movq %r14, %r8
movq %r12, %rsi
je 0x3206f1
incq %r13
decq 0x10(%rsp)
movq %r15, %r12
movq %rbx, %rbp
movq %rsi, %r14
cmpq 0x10(%r8), %r13
jb 0x320598
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x940aa
callq 0x940e3
nop