// File: /workspace/github_cpp_makefile_star2_O3/maxgodfrey2004[P]gss/src/kmp.cc
// Function: gss::kmp::FindMatches(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::vector<int> FindMatches(std::string search, std::string pattern) {
  if (search == "") {
    std::cerr << "ERROR: text to search must not be blank" << std::endl;
  }

  std::vector<int> prefix_vals = ComputePrefix(search);
  std::vector<int> occurrences;

  int max_length_prefix = 0;
  for (int i = 0; i < static_cast<int>(search.length()); ++i) {
    // Jump by prefix values to try smaller prefixes. Keep jumping until we
    // either find a match, or reach zero.
    while (max_length_prefix > 0 && search[i] != pattern[max_length_prefix]) {
      max_length_prefix = prefix_vals[max_length_prefix - 1];
    }
    if (search[i] == pattern[max_length_prefix]) {
      ++max_length_prefix;
    }
    if (max_length_prefix == static_cast<int>(pattern.length())) {
      // We have found an occurrence of pattern in our search string!
      occurrences.push_back(i - pattern.length() + 1);
      max_length_prefix = prefix_vals[max_length_prefix - 1];
    }
  }

  return occurrences;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x117d(%rip), %rsi      # 0x409c
movq %r15, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2f6e
movq 0x30be(%rip), %r12      # 0x5ff0
leaq 0x11fb(%rip), %rsi      # 0x4134
movl $0x27, %edx
movq %r12, %rdi
callq 0x2160
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0x28ce
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x2e88
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x2fb2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2150
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x8(%r15), %rax
testl %eax, %eax
jle 0x3053
xorl %r13d, %r13d
leaq 0xc(%rsp), %r12
xorl %ebp, %ebp
movq (%r15), %rcx
movb (%rcx,%r13), %cl
movq (%r14), %rdx
testl %ebp, %ebp
jle 0x2ff8
movq 0x10(%rsp), %rsi
movl %ebp, %edi
cmpb (%rdx,%rdi), %cl
je 0x2ff8
movl -0x4(%rsi,%rdi,4), %ebp
testl %ebp, %ebp
jg 0x2fe9
movslq %ebp, %rbp
xorl %esi, %esi
cmpb (%rdx,%rbp), %cl
sete %sil
addl %esi, %ebp
cmpl 0x8(%r14), %ebp
jne 0x3048
movl %r13d, %ecx
subl %ebp, %ecx
incl %ecx
movl %ecx, 0xc(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x302d
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x303c
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3172
movq 0x8(%r15), %rax
movq 0x10(%rsp), %rcx
movslq %ebp, %rdx
movl -0x4(%rcx,%rdx,4), %ebp
incq %r13
movslq %eax, %rcx
cmpq %rcx, %r13
jl 0x2fd6
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x306a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x30c1
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x30bc
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x30aa
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x30c1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %r14, %rdi
callq 0x21b0
nop