// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, %r14
leal -0x1(%rdx), %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
movq %rax, 0x30(%rsp)
movq %rsi, %rdx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movl 0x28(%rbx), %esi
movq %rdx, 0x20(%rsp)
movq %r14, %rcx
callq 0x2c09a6
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0x71f38
xorl %eax, %eax
movq %rbx, %r8
leaq 0x40(%rsp), %rcx
movb $0x0, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rcx)
movq %r14, 0x30(%rcx)
andq $0x0, 0x40(%rcx)
pushq $-0x1
popq %r12
movq %r12, 0x18(%rsp)
movq %r14, 0x10(%rsp)
xorl %ebp, %ebp
movq %rbx, 0x8(%rsp)
cmpq 0x10(%r8), %rax
jae 0x2c189e
movq %rax, 0x38(%rsp)
movq (%r8), %rdi
callq 0x70f55
cmpb $-0x2, %al
je 0x2c17a4
movzbl %al, %eax
movq 0x10(%rsp), %r15
movl $0x0, %ebx
pushq $-0x1
popq %r13
cmpl $0xff, %eax
movq 0x8(%rsp), %r8
je 0x2c1883
movq 0x18(%r8), %rcx
movq (%rcx,%rax,8), %rax
jmp 0x2c17ab
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 0x30(%rsp), %rdx
testq %rdx, %rbx
je 0x2c17d8
incq %r14
jmp 0x2c17e9
testq %rdx, %rcx
je 0x2c17e9
testq %r14, %r14
je 0x2c18b0
decq %r14
movq %r14, %r15
orq %rbp, %rax
addq %rbx, %rbx
addq %rcx, %rcx
movq %rbx, %r13
orq %rax, %r13
notq %r13
orq %rcx, %r13
andq %rax, %rbx
movq 0x28(%rsp), %rax
cmpq %rax, %r14
ja 0x2c1883
movq 0x10(%r8), %rbp
addq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rdx
testq %rax, %rax
je 0x2c1852
movl 0x28(%r8), %esi
movzbl 0x2c(%r8), %ecx
movq 0x8(%r8), %rdi
movq %r8, %r14
movq 0x20(%r8), %r8
movq %rbp, %rdx
movq 0x20(%rsp), %r9
pushq %rax
pushq 0x18(%rsp)
callq 0x2a717d
addq $0x10, %rsp
testb $0x1, %al
je 0x2c1879
movq %r14, %r8
movq %rbp, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq %r15, 0x78(%rsp)
movq 0x38(%r8), %rdi
leaq 0x40(%rsp), %rsi
movq 0x8(%rsp), %rax
callq *0x30(%rax)
movq 0x8(%rsp), %r8
jmp 0x2c1883
cmpb $0x0, 0x2c(%r14)
movq %r14, %r8
je 0x2c18de
movq 0x38(%rsp), %rax
incq %rax
decq 0x18(%rsp)
movq %r15, %r14
movq %rbx, %rbp
movq %r13, %r12
jmp 0x2c175e
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1766b1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23752(%rip), %rsi     # 0x2e5013
leaq 0x746cb(%rip), %rdx     # 0x335f93
leaq 0xc3029(%rip), %rcx     # 0x3848f8
leaq 0xc2ff2(%rip), %r8      # 0x3848c8
movl $0x86, %r9d
jmp 0x2c190a
movq 0x176683(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23724(%rip), %rsi     # 0x2e5013
leaq 0xc301c(%rip), %rdx     # 0x384912
leaq 0xc2ffb(%rip), %rcx     # 0x3848f8
leaq 0xc2fc4(%rip), %r8      # 0x3848c8
movl $0xa2, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop