// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x8(%rsi), %rbp
testq %rbp, %rbp
je 0x2e05
movq %rdi, %r15
cmpb $0x0, 0xe0(%rdi)
je 0x2e05
cmpb $0x1, 0x70(%r15)
jne 0x2c56
movq 0x8(%rsp), %rax
movq (%rax), %rax
movsbq (%rax), %rax
movq 0x80(%r15), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
js 0x2bf5
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0xb0(%r15), %rsi
movq %rax, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x10(%rsp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x2e14
shlq $0x5, %rax
addq %rax, %rsi
leaq 0x28(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *0x18(%rdi)
movq 0x8(%r15), %rax
decq %rax
cmpq %rax, %rbp
cmovbq %rbp, %rax
movslq %eax, %rbx
cmpq $0x2, %rbx
jb 0x2c56
movl $0x1, %r12d
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x3cda
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3c06
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x2c4e
movq %r13, %rdi
movq %r13, %rsi
movl $0x3, %edx
callq *%rax
incq %r12
cmpq %r12, %rbx
jne 0x2c17
movq 0x8(%r15), %r12
decq %r12
cmpq %rbp, %r12
jae 0x2e05
movb 0x70(%r15), %al
leaq 0x38(%rsp), %rbx
movl $0x1, %r14d
movq %r15, 0x18(%rsp)
testb $0x1, %al
je 0x2cb5
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x3cda
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x3c06
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x2cb5
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movsbl (%rsi,%r12), %eax
movzwl 0x18(%r15), %ecx
shll %cl, %eax
movsbl -0x1(%rsi,%r12), %edx
addl %eax, %edx
shll %cl, %edx
movsbl -0x2(%rsi,%r12), %eax
addl %edx, %eax
xorl %edx, %edx
divq 0x20(%r15)
movq 0x28(%r15), %rax
movq (%rax,%rdx,8), %r13
testq %r13, %r13
jne 0x2def
movq %r12, %rax
subq 0x8(%r15), %rax
movsbl 0x1(%rsi,%rax), %r14d
shll %cl, %r14d
movq 0x40(%r15), %rcx
leaq (%rdx,%rdx,2), %rdx
movq (%rcx,%rdx,8), %rbx
movq 0x8(%rcx,%rdx,8), %r15
movl $0x1, %r13d
cmpq %r15, %rbx
je 0x2ddf
movsbl 0x2(%rsi,%rax), %eax
addl %eax, %r14d
leaq 0x1(%r12), %rax
movq %rax, 0x30(%rsp)
cmpl (%rbx), %r14d
jne 0x2dd2
movq 0x8(%rbx), %rax
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %r9
movq 0x58(%rcx), %rdx
movq %rax, %rdi
shlq $0x5, %rdi
leaq (%rdx,%rdi), %rsi
movq %r12, %rcx
subq %r9, %rcx
movq 0x8(%rdx,%rdi), %rdx
movq 0x8(%rsp), %rdi
movq (%rdi), %rdi
addq %r12, %rdi
subq %r9, %rdi
incq %rdi
movq 0x30(%rsp), %r8
subq %r9, %r8
xorl %r9d, %r9d
cmpq %rdx, %r9
jae 0x2da4
leaq (%r8,%r9), %r10
cmpq %rbp, %r10
jae 0x2da4
leaq 0x1(%r9), %r10
movq (%rsi), %r11
movb (%r11,%r9), %r11b
cmpb (%rdi,%r9), %r11b
movq %r10, %r9
je 0x2d80
jmp 0x2da7
movq %r9, %r10
cmpq %rdx, %r10
jne 0x2dd2
incq %rcx
movq %rax, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq 0x10(%rsp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x2e14
leaq 0x28(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *0x18(%rdi)
addq $0x10, %rbx
cmpq %r15, %rbx
jne 0x2d34
movq 0x18(%rsp), %r15
leaq 0x38(%rsp), %rbx
movl $0x1, %r14d
movb 0x70(%r15), %al
testb %al, %al
cmovneq %r14, %r13
addq %r13, %r12
cmpq %rbp, %r12
jb 0x2c7a
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2060
jmp 0x2e61
jmp 0x2e61
movq %rax, %rbx
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0x2e59
leaq 0x38(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x2e59
jmp 0x2e61
movq %rax, %rbx
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x2e59
leaq 0x58(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2f3f
nop