// File: /workspace/github_cpp_makefile_star2_O2/bubiche[P]wu_manber/./wu_manber.hpp
// Function: wu_manber::WuManber<char, std::char_traits<char>>::scan(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long, unsigned long)>)
void scan(const StringType &text, std::function<void(const StringType&, std::size_t, std::size_t)> onMatch) {
      std::size_t textLength = text.size();
      if (!isInitialized_ || textLength == 0) {
        return;
      }

      if (isShortPatternExist_) {
        int firstCharacterMatchIndex = lengthOnePatternLookup_[static_cast<std::size_t>(text[0])];
        if (firstCharacterMatchIndex > -1) {
          onMatch(lengthOnePatterns_[firstCharacterMatchIndex], firstCharacterMatchIndex, 0);
        }
        const int PRE_WU_MANBER_LIMIT = std::min(m_ - 1, textLength);
        for (std::size_t idx = 1; idx < PRE_WU_MANBER_LIMIT; ++idx) {
          CharType preChar = text[idx - 1];
          CharType curChar = text[idx];
          checkShortPattern_(text, idx, onMatch);
        }
      }

      std::size_t idx = m_ - 1;
      while (idx < textLength) {
        if (isShortPatternExist_) {
          checkShortPattern_(text, idx, onMatch);
        }

        // hash value for HASH table
        unsigned int hashValue = getWuManberTableHashFromText_(text, idx);

        std::size_t shiftLength = shiftTable_[hashValue];
        if (shiftLength == 0) {
          // found a potential match, check values in HASH/PREDIX and will shift by 1 character
          shiftLength = 1;

          // hash value to match pattern
          unsigned int prefixHash = getPrefixHashFromText_(text, idx - m_ + 1);
          for (const auto &potentialMatch : hashPrefixTable_[hashValue]) {
            if (prefixHash == potentialMatch.prefixHash) {
              bool isMatched = false;
              const StringType &pattern = patternList_[potentialMatch.idx];
              std::size_t idxInPattern = 0;
              std::size_t idxInText = idx - m_ + 1;
              std::size_t patternLength = pattern.size();

              // prefix hash matched so we try to match character by character
              while(idxInPattern < patternLength && idxInText < textLength && pattern[idxInPattern++] == text[idxInText++]);

              // end of pattern reached => match found
              if (idxInPattern == patternLength) {
                onMatch(pattern, potentialMatch.idx, idx - m_ + 1);
              }
            }
          }
        }
        if (isShortPatternExist_) {
          ++idx;
        } else {
          idx += shiftLength;
        }
      }

    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsi), %rbp
testq %rbp, %rbp
je 0x2b75
movq %rdi, %r15
cmpb $0x0, 0xe0(%rdi)
je 0x2b75
cmpb $0x1, 0x70(%r15)
jne 0x2a1d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsbq (%rax), %rax
movq 0x80(%r15), %rcx
movq (%rcx,%rax,8), %rdx
testl %edx, %edx
js 0x29d1
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rdx, %rsi
shlq $0x5, %rsi
addq 0xb0(%r15), %rsi
movq 0x10(%rsp), %rdi
xorl %ecx, %ecx
callq 0x3a0e
movq 0x8(%r15), %rax
decq %rax
cmpq %rax, %rbp
cmovbq %rbp, %rax
movslq %eax, %rbx
pushq $0x1
popq %r13
leaq 0x48(%rsp), %r14
cmpq %rbx, %r13
jae 0x2a1d
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0x3ae4
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x3a3a
movq %r14, %rdi
callq 0x2ba0
incq %r13
jmp 0x29eb
pushq $0x1
popq %r14
movq 0x8(%r15), %r13
decq %r13
leaq 0x28(%rsp), %rbx
movq %rbx, 0x18(%rsp)
cmpq %rbp, %r13
jae 0x2b75
cmpb $0x1, 0x70(%r15)
jne 0x2a6a
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x3ae4
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x3a3a
movq %rbx, %rdi
callq 0x2ba0
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x346a
movl %eax, %eax
movq 0x28(%r15), %rcx
movq (%rcx,%rax,8), %rcx
testq %rcx, %rcx
jne 0x2b64
movq %r13, %rdx
subq 0x8(%r15), %rdx
movq 0x8(%rsp), %rcx
movq (%rcx), %rsi
movsbl 0x1(%rsi,%rdx), %edi
movb 0x18(%r15), %cl
shll %cl, %edi
movsbl 0x2(%rsi,%rdx), %r12d
addl %edi, %r12d
movq 0x40(%r15), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rbx
movq 0x8(%rcx,%rax), %r14
leaq 0x1(%r13), %rax
movq %rax, 0x20(%rsp)
cmpq %r14, %rbx
je 0x2b58
cmpl (%rbx), %r12d
jne 0x2b4f
movq 0x8(%rbx), %rdx
movq 0x8(%r15), %r9
movq 0x58(%r15), %rax
movq %rdx, %rdi
shlq $0x5, %rdi
leaq (%rax,%rdi), %rsi
movq %r13, %rcx
subq %r9, %rcx
movq 0x8(%rax,%rdi), %rax
movq 0x8(%rsp), %rdi
movq (%rdi), %rdi
addq %r13, %rdi
subq %r9, %rdi
incq %rdi
movq 0x20(%rsp), %r8
subq %r9, %r8
xorl %r9d, %r9d
cmpq %rax, %r9
jae 0x2b3a
leaq (%r8,%r9), %r10
cmpq %rbp, %r10
jae 0x2b3a
leaq 0x1(%r9), %r10
movq (%rsi), %r11
movb (%r11,%r9), %r11b
cmpb (%rdi,%r9), %r11b
movq %r10, %r9
je 0x2b16
jmp 0x2b3d
movq %r9, %r10
cmpq %rax, %r10
jne 0x2b4f
incq %rcx
movq 0x10(%rsp), %rdi
callq 0x3a0e
addq $0x10, %rbx
jmp 0x2aca
pushq $0x1
popq %r14
movq %r14, %rcx
leaq 0x28(%rsp), %rbx
cmpb $0x0, 0x70(%r15)
cmovneq %r14, %rcx
addq %rcx, %r13
jmp 0x2a32
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x18(%rsp)
jmp 0x2b8b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
callq 0x2ba0
movq %rbx, %rdi
callq 0x21a0