// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/string_matching.c
// Function: gt_string_matching_kmp
GtUword gt_string_matching_kmp(const char *s, GtUword n,
                                     const char *p, GtUword m,
                                     GtProcessMatch process_match, void *data)
{
  GtUword *prefixtab,
                j = 0,   /* position in s corresponding to the first character
                            in p */
                cpl = 0; /* length of common prefix of s[j]..s[n-1] and p */
  char b, c;
  gt_assert(s && p);
  if (!m || !n) /* no match possible */
    return 0;
  prefixtab = compute_prefixtab(p, m);
  while (j + cpl < n) {
    if (cpl == m) {                     /* case (1)  */
      if (process_match) {
        if (process_match(j, data))
            break;
      }
      j = j + cpl - prefixtab[cpl];
      cpl = prefixtab[cpl];
    }
    else {                              /* case (2)  */
      b = s[j+cpl];
      c = p[cpl];
      if (b != c) {
        if (cpl > 0) {
          j = j + cpl - prefixtab[cpl]; /* case (2a) */
          cpl = prefixtab[cpl];
        }
        else
          j++;                          /* case (2b) */

      }
      else
        cpl++;                          /* case (2c) */
    }
  }
  /* do not miss match at the last possible position */
  if (cpl == m && process_match)
    process_match(j, data);
  gt_free(prefixtab);
  return cpl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1243ca
movq %rdx, %r12
testq %rdx, %rdx
je 0x1243ca
movq %rcx, %rbx
movq %rsi, %r13
testq %rcx, %rcx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x12431e
movq %rdi, %r10
movq %r9, 0x8(%rsp)
movq %r8, (%rsp)
leaq 0x8(,%rbx,8), %rdi
leaq 0x211884(%rip), %rsi    # 0x335b47
pushq $0x40
popq %rdx
movq %r10, 0x10(%rsp)
callq 0x93160
movq 0x10(%rsp), %r8
movq %rax, %r14
orq $-0x1, (%rax)
andq $0x0, 0x8(%rax)
pushq $0x2
popq %rax
xorl %ecx, %ecx
cmpq %rbx, %rax
ja 0x124326
movb -0x1(%r12,%rax), %dl
testq %rcx, %rcx
je 0x124301
cmpb %dl, (%r12,%rcx)
je 0x124307
movq (%r14,%rcx,8), %rcx
jmp 0x1242f0
movb (%r12), %sil
jmp 0x124309
movl %edx, %esi
xorl %edi, %edi
cmpb %dl, %sil
sete %dil
addq %rdi, %rcx
movq %rcx, (%r14,%rax,8)
incq %rax
jmp 0x1242e6
xorl %r15d, %r15d
jmp 0x1243b8
xorl %r15d, %r15d
xorl %ebp, %ebp
movq (%rsp), %rdx
leaq (%r8,%rbp), %rax
leaq (%r15,%rbp), %rcx
cmpq %r13, %rcx
jae 0x124392
cmpq %r15, %rbx
je 0x124350
movb (%rax,%r15), %cl
cmpb (%r12,%r15), %cl
jne 0x124373
incq %r15
jmp 0x124333
testq %rdx, %rdx
je 0x12436d
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq *(%rsp)
movq 0x10(%rsp), %r8
movq (%rsp), %rdx
testb %al, %al
jne 0x12438f
movq (%r14,%rbx,8), %rax
jmp 0x12437c
testq %r15, %r15
je 0x124387
movq (%r14,%r15,8), %rax
subq %rax, %rbp
addq %r15, %rbp
movq %rax, %r15
jmp 0x12432f
incq %rbp
xorl %r15d, %r15d
jmp 0x12432f
movq %rbx, %r15
testq %rdx, %rdx
je 0x1243a6
cmpq %rbx, %r15
jne 0x1243a6
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq *%rdx
leaq 0x21179a(%rip), %rsi    # 0x335b47
pushq $0x78
popq %rdx
movq %r14, %rdi
callq 0x936f9
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x313b97(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1c0c38(%rip), %rsi    # 0x2e5013
leaq 0x211747(%rip), %rdx    # 0x335b29
leaq 0x21177d(%rip), %rcx    # 0x335b66
leaq 0x211757(%rip), %r8     # 0x335b47
pushq $0x58
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390