user: Please show me the C implementation that matches the assembly code listed below:

```asm
<search>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  call   <strlen@plt>
  mov    %r14,%rdi
  mov    %eax,%ebx
  mov    %eax,0x10(%rsp)
  call   <strlen@plt>
  lea    -0x1(%rbx),%esi
  mov    %eax,%r15d
  test   %esi,%esi
  jle    L15
  mov    $0x1,%edx
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L172:
  mov    %edx,%eax
  add    $0x1,%ecx
  shl    $0x8,%eax
  cltd
  idiv   %ebp
  cmp    %esi,%ecx
  jne    L172
  mov    %edx,0x14(%rsp)
L126:
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L12
  mov    0x8(%rsp),%rdi
  movslq %eax,%rsi
  xor    %ecx,%ecx
  xor    %r12d,%r12d
  xor    %ebx,%ebx
  xchg   %ax,%ax
L62:
  movsbl 0x0(%r13,%rcx,1),%eax
  shl    $0x8,%ebx
  shl    $0x8,%r12d
  add    %ebx,%eax
  cltd
  idiv   %ebp
  movsbl (%rdi,%rcx,1),%eax
  add    %r12d,%eax
  add    $0x1,%rcx
  mov    %edx,%ebx
  cltd
  idiv   %ebp
  mov    %edx,%r12d
  cmp    %rsi,%rcx
  jne    L62
L40:
  mov    %r12d,%esi
  lea    D53(%rip),%rdi
  mov    %r15d,%r14d
  call   <printf@plt>
  mov    0x10(%rsp),%eax
  sub    %eax,%r14d
  js     L174
  add    $0x1,%eax
  mov    %ebx,0x4(%rsp)
  xor    %r15d,%r15d
  mov    %eax,0x1c(%rsp)
  mov    %ebp,0x18(%rsp)
  jmp    L151
  nopl   (%rax)
L29:
  mov    %ebp,%esi
  lea    D44(%rip),%rdi
  add    $0x1,%r15
  call   <printf@plt>
  cmp    %r15d,%r14d
  jl     L174
L151:
  mov    %r15d,%esi
  lea    D40(%rip),%rdi
  mov    %r15d,%ebx
  mov    %r15d,%ebp
  call   <printf@plt>
  mov    %r12d,%esi
  lea    D53(%rip),%rdi
  call   <printf@plt>
  cmp    %r12d,0x4(%rsp)
  je     L93
L20:
  cmp    %r15d,%r14d
  jle    L29
  lea    D56(%rip),%rdi
  mov    %ebp,%esi
  call   <printf@plt>
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%r15,1),%eax
  imul   0x14(%rsp),%eax
  sub    %eax,%r12d
  mov    0x10(%rsp),%eax
  shl    $0x8,%r12d
  lea    (%rax,%rbx,1),%edx
  mov    0x18(%rsp),%ebx
  movslq %edx,%rdx
  movsbl (%rdi,%rdx,1),%eax
  add    %r12d,%eax
  cltd
  idiv   %ebx
  lea    (%rdx,%rbx,1),%r12d
  test   %edx,%edx
  cmovns %edx,%r12d
  jmp    L29
  cs nopw 0x0(%rax,%rax,1)
L93:
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L138
  mov    0x8(%rsp),%rsi
  mov    0x1c(%rsp),%edi
  mov    $0x1,%eax
  add    %r15,%rsi
  nopl   0x0(%rax)
L154:
  movzbl -0x1(%r13,%rax,1),%ecx
  cmp    %cl,-0x1(%rax,%rsi,1)
  jne    L20
  mov    %eax,%r9d
  add    $0x1,%rax
  cmp    %rax,%rdi
  jne    L154
L54:
  cmp    %r9d,0x10(%rsp)
  jne    L20
  mov    %ebp,%esi
  lea    D22(%rip),%rdi
  call   <printf@plt>
  jmp    L20
  nopw   0x0(%rax,%rax,1)
L174:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L12:
  xor    %r12d,%r12d
  xor    %ebx,%ebx
  jmp    L40
L15:
  movl   $0x1,0x14(%rsp)
  jmp    L126
L138:
  xor    %r9d,%r9d
  jmp    L54
```

tool_calls: name: retrieve_data
arguments: data_label: D53
datatype: string
name: retrieve_data
arguments: data_label: D44
datatype: string
name: retrieve_data
arguments: data_label: D40
datatype: string
name: retrieve_data
arguments: data_label: D56
datatype: string
name: retrieve_data
arguments: data_label: D22
datatype: string

tool: D53: t %d 


tool: D44: fim %d 


tool: D40: comeco %d 


tool: D56: fiz %d 


tool: D22: Padrao encontrado na posicao %d 


assistant: ```c
void search(char *pad, char *txt, int q) {
  int M = strlen(pad);
  int N = strlen(txt);
  int i, j;
  int p = 0;
  int t = 0;
  int h = 1;
  for (i = 0; i < M - 1; i++)
    h = (h * 256) % q;
  for (i = 0; i < M; i++) {
    p = (256 * p + pad[i]) % q;
    t = (256 * t + txt[i]) % q;
  }
  printf("t %d \n", t);
  for (i = 0; i <= N - M; i++) {
    printf("comeco %d \n", i);
    printf("t %d \n", t);
    if (p == t) {
      for (j = 0; j < M; j++) {
        if (txt[i + j] != pad[j])
          break;
      }
      if (j == M)
        printf("Padrao encontrado na posicao %d \n", i);
    }
    if (i < N - M) {
      printf("fiz %d \n", i);
      t = (256 * (t - txt[i] * h) + txt[i + M]) % q;
      if (t < 0)
        t = (t + q);
    }
    printf("fim %d \n", i);
  }
}
```