// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdx, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2100
movq %rax, %rcx
movq -0x100(%rbp), %rax
movq %rcx, -0x20(%rbp)
testb $0x1, 0xe0(%rax)
je 0x3690
cmpq $0x0, -0x20(%rbp)
jne 0x3695
jmp 0x3b2e
movq -0x100(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0x37fd
movq -0x100(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21e0
movq -0x110(%rbp), %rdi
movsbq (%rax), %rsi
callq 0x69e0
movq (%rax), %rax
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jle 0x3711
movq -0x100(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x24(%rbp), %rsi
callq 0x6ab0
movq -0x108(%rbp), %rdi
movq %rax, %rsi
movslq -0x24(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x8480
movq -0x100(%rbp), %rax
movq 0x8(%rax), %rax
subq $0x1, %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x47a0
movq (%rax), %rax
movl %eax, -0x28(%rbp)
movq $0x1, -0x38(%rbp)
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jae 0x37fb
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
decq %rsi
callq 0x21e0
movb (%rax), %al
movb %al, -0x39(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x21e0
movq -0x108(%rbp), %rsi
movb (%rax), %al
movb %al, -0x3a(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x85e0
movq -0x100(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
movq -0x118(%rbp), %rcx
callq 0x84d0
jmp 0x37c7
leaq -0x60(%rbp), %rdi
callq 0x3b40
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x373f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3b40
jmp 0x3b37
jmp 0x37fd
movq -0x100(%rbp), %rax
movq 0x8(%rax), %rax
subq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x3b2e
movq -0x100(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0x38a9
movq -0x108(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x98(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x85e0
movq -0x100(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdx
movq -0x130(%rbp), %rcx
callq 0x84d0
jmp 0x387e
leaq -0x98(%rbp), %rdi
callq 0x3b40
jmp 0x38a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3b40
jmp 0x3b37
movq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x6a00
movq -0x100(%rbp), %rdi
movl %eax, -0x9c(%rbp)
addq $0x28, %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x69e0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x3aff
movq -0x100(%rbp), %rdi
movq $0x1, -0xa8(%rbp)
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
subq 0x8(%rdi), %rdx
addq $0x1, %rdx
callq 0x6ad0
movq -0x100(%rbp), %rdi
movl %eax, -0xac(%rbp)
addq $0x40, %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
callq 0x6b40
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x76b0
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x7530
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x8690
testb $0x1, %al
jne 0x3981
jmp 0x3afd
leaq -0xc0(%rbp), %rdi
callq 0x86d0
movq %rax, -0xd0(%rbp)
movl -0xac(%rbp), %eax
movq -0xd0(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x3aea
movq -0x100(%rbp), %rdi
movb $0x0, -0xd1(%rbp)
addq $0x58, %rdi
movq -0xd0(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x6ab0
movq -0x100(%rbp), %rcx
movq %rax, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0x78(%rbp), %rax
subq 0x8(%rcx), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
movq -0xe0(%rbp), %rdi
callq 0x2100
movq %rax, -0xf8(%rbp)
movq -0xe8(%rbp), %rcx
xorl %eax, %eax
cmpq -0xf8(%rbp), %rcx
movb %al, -0x141(%rbp)
jae 0x3a96
movq -0xf0(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x141(%rbp)
jae 0x3a96
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0xe8(%rbp)
callq 0x21e0
movsbl (%rax), %eax
movl %eax, -0x148(%rbp)
movq -0x10(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
callq 0x21e0
movq %rax, %rcx
movl -0x148(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x141(%rbp)
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x3aa2
jmp 0x3aa7
jmp 0x3a0a
movq -0xe8(%rbp), %rax
cmpq -0xf8(%rbp), %rax
jne 0x3ae8
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rax
movq -0xe0(%rbp), %rsi
movq -0xd0(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq -0x78(%rbp), %rcx
subq 0x8(%rax), %rcx
addq $0x1, %rcx
callq 0x8480
jmp 0x3aea
jmp 0x3aec
leaq -0xc0(%rbp), %rdi
callq 0x86f0
jmp 0x3965
jmp 0x3aff
movq -0x100(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0x3b1a
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x3b29
movq -0xa8(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x3810
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x2250