// File: ruippeixotog[P]algo-lib/knuth-morris-pratt.cpp
// Function: kmp(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, std::allocator<int>>&)
void kmp(string str, string pattern, vector<int>& res) {
  res.clear();

  pi[0] = 0;
  for(int i = 1; i < pattern.size(); i++) {
    pi[i] = pi[i - 1];
    while(pi[i] > 0 && pattern[i] != pattern[pi[i]])
      pi[i] = pi[pi[i] - 1];
    if(pattern[i] == pattern[pi[i]]) pi[i]++;
  }

  int k = 0;
  for(int i = 0; i < str.size(); i++) {
    while(k > 0 && str[i] != pattern[k])
      k = pi[k - 1];
    if(str[i] == pattern[k]) k++;
    if(k == pattern.size()) {
      res.push_back(i - k + 1);
      k = pi[k - 1];
    }
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x17e0
movl $0x0, 0x3dff(%rip)      # 0x50e0
movl $0x1, 0x5c(%rsp)
movq 0x48(%rsp), %rdi
movslq 0x5c(%rsp), %rax
movq %rax, 0x38(%rsp)
callq 0x1080
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x1435
movl 0x5c(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3dc1(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %edx
movslq 0x5c(%rsp), %rcx
leaq 0x3db2(%rip), %rax      # 0x50e0
movl %edx, (%rax,%rcx,4)
movslq 0x5c(%rsp), %rdx
xorl %eax, %eax
leaq 0x3da1(%rip), %rcx      # 0x50e0
cmpl $0x0, (%rcx,%rdx,4)
movb %al, 0x37(%rsp)
jle 0x138c
movq 0x48(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0x1160
movq 0x48(%rsp), %rdi
movsbl (%rax), %eax
movl %eax, 0x30(%rsp)
movslq 0x5c(%rsp), %rcx
leaq 0x3d70(%rip), %rax      # 0x50e0
movslq (%rax,%rcx,4), %rsi
callq 0x1160
movq %rax, %rcx
movl 0x30(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x1396
jmp 0x13c9
movslq 0x5c(%rsp), %rcx
leaq 0x3d3e(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3d2e(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %edx
movslq 0x5c(%rsp), %rcx
leaq 0x3d1f(%rip), %rax      # 0x50e0
movl %edx, (%rax,%rcx,4)
jmp 0x1331
movq 0x48(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0x1160
movq 0x48(%rsp), %rdi
movsbl (%rax), %eax
movl %eax, 0x2c(%rsp)
movslq 0x5c(%rsp), %rcx
leaq 0x3cf0(%rip), %rax      # 0x50e0
movslq (%rax,%rcx,4), %rsi
callq 0x1160
movq %rax, %rcx
movl 0x2c(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1423
movslq 0x5c(%rsp), %rcx
leaq 0x3ccd(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x3cc0(%rip), %rax      # 0x50e0
movl %edx, (%rax,%rcx,4)
jmp 0x1425
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x12e9
movl $0x0, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x54(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x1080
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x157c
jmp 0x146c
xorl %eax, %eax
cmpl $0x0, 0x58(%rsp)
movb %al, 0x1f(%rsp)
jle 0x14b1
movq 0x40(%rsp), %rdi
movslq 0x54(%rsp), %rsi
callq 0x1160
movq 0x48(%rsp), %rdi
movsbl (%rax), %eax
movl %eax, 0x18(%rsp)
movslq 0x58(%rsp), %rsi
callq 0x1160
movq %rax, %rcx
movl 0x18(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x14bb
jmp 0x14d5
movl 0x58(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3c14(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %eax
movl %eax, 0x58(%rsp)
jmp 0x146c
movq 0x40(%rsp), %rdi
movslq 0x54(%rsp), %rsi
callq 0x1160
movq 0x48(%rsp), %rdi
movsbl (%rax), %eax
movl %eax, 0x14(%rsp)
movslq 0x58(%rsp), %rsi
callq 0x1160
movq %rax, %rcx
movl 0x14(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1513
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
movq 0x48(%rsp), %rdi
movslq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
callq 0x1080
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jne 0x156a
movq 0x60(%rsp), %rdi
movl 0x54(%rsp), %eax
subl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
leaq 0x50(%rsp), %rsi
callq 0x1800
movl 0x58(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3b7d(%rip), %rax      # 0x50e0
movl (%rax,%rcx,4), %eax
movl %eax, 0x58(%rsp)
jmp 0x156c
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1445
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)