// File: /workspace/github_cpp_makefile_star2_O1/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 0x11c0(%rip), %rsi      # 0x409c
movq %r15, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2f2b
movq 0x3101(%rip), %r12      # 0x5ff0
leaq 0x123e(%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 0x28d6
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x2e3c
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x2f6f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2150
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
cmpl $0x0, 0x8(%r15)
jle 0x301b
xorl %r13d, %r13d
leaq 0xc(%rsp), %r12
xorl %ebp, %ebp
testl %ebp, %ebp
jle 0x2fb4
movq (%r15), %rax
movb (%rax,%r13), %al
movq (%r14), %rcx
movq 0x10(%rsp), %rdx
movl %ebp, %esi
cmpb (%rcx,%rsi), %al
je 0x2fb4
movl -0x4(%rdx,%rsi,4), %ebp
testl %ebp, %ebp
jg 0x2fa5
movq (%r15), %rax
movb (%rax,%r13), %al
movslq %ebp, %rbp
movq (%r14), %rcx
xorl %edx, %edx
cmpb (%rcx,%rbp), %al
sete %dl
addl %edx, %ebp
movl 0x8(%r14), %ecx
cmpl %ecx, %ebp
jne 0x300b
movl %r13d, %eax
subl %ecx, %eax
incl %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x2ff4
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x2fff
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3138
movq 0x10(%rsp), %rax
movslq %ebp, %rcx
movl -0x4(%rax,%rcx,4), %ebp
incq %r13
movslq 0x8(%r15), %rax
cmpq %rax, %r13
jl 0x2f92
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3032
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 0x3089
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x3084
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3072
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3089
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %r14, %rdi
callq 0x21b0
nop