user: Converte this assembly snippet into its equivalent C code:

```asm
<kmp_search>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %ecx,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  movl   $0x0,-0x34(%rbp)
  movl   $0x0,-0x30(%rbp)
  mov    -0x50(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x28(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  movslq %eax,%rdx
  mov    %rdx,%r8
  mov    $0x0,%r9d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L7:
  cmp    %rdx,%rsp
  je     L133
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L7
L133:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L41
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L41:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L109
L61:
  mov    -0x20(%rbp),%rax
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  movl   $0x0,(%rax,%rdx,4)
  addl   $0x1,-0x30(%rbp)
L109:
  mov    -0x30(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L61
  mov    -0x2c(%rbp),%ecx
  mov    -0x20(%rbp),%rdx
  mov    -0x50(%rbp),%esi
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <kmp_table@plt>
  movl   $0x0,-0x30(%rbp)
  jmp    L9
L129:
  mov    -0x30(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x34(%rbp),%ecx
  mov    -0x30(%rbp),%eax
  add    %ecx,%eax
  movslq %eax,%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L124
  mov    -0x50(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x30(%rbp)
  jne    L102
  mov    -0x34(%rbp),%eax
  jmp    L17
L102:
  addl   $0x1,-0x30(%rbp)
  jmp    L9
L124:
  mov    -0x20(%rbp),%rax
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  test   %eax,%eax
  js     L56
  mov    -0x34(%rbp),%edx
  mov    -0x30(%rbp),%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x20(%rbp),%rax
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%edx
  mov    %ecx,%eax
  sub    %edx,%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x20(%rbp),%rax
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  mov    %eax,-0x30(%rbp)
  jmp    L9
L56:
  addl   $0x1,-0x34(%rbp)
  movl   $0x0,-0x30(%rbp)
L9:
  mov    -0x34(%rbp),%edx
  mov    -0x30(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x4c(%rbp)
  jg     L129
  mov    -0x4c(%rbp),%eax
L17:
  mov    %rbx,%rsp
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int kmp_search(char *S, int len_s, char *W, int len_w) {
  int m = 0;
  int i = 0;
  int len_t = len_w;
  int T[len_t];
  for (i = 0; i < len_t; i++) {
    T[i] = 0;
  }
  kmp_table(W, len_w, T, len_t);
  i = 0;
  while (m + i < len_s) {
    if (W[i] == S[m + i]) {
      if (i == (len_w - 1)) {
        return m;
      }
      i = i + 1;
    } else {
      if (T[i] > -1) {
        m = m + i - T[i];
        i = T[i];
      } else {
        m = m + 1;
        i = 0;
      }
    }
  }
  return len_s;
}
```