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

```asm
<search>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x4(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x1,-0xc(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L124
L6:
  mov    -0xc(%rbp),%eax
  shl    $0x8,%eax
  cltd
  idivl  -0x34(%rbp)
  mov    %edx,-0xc(%rbp)
  addl   $0x1,-0x1c(%rbp)
L124:
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x1c(%rbp)
  jl     L6
  movl   $0x0,-0x1c(%rbp)
  jmp    L129
L76:
  mov    -0x14(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  cltd
  idivl  -0x34(%rbp)
  mov    %edx,-0x14(%rbp)
  mov    -0x10(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  cltd
  idivl  -0x34(%rbp)
  mov    %edx,-0x10(%rbp)
  addl   $0x1,-0x1c(%rbp)
L129:
  mov    -0x1c(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jl     L76
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  movl   $0x0,-0x1c(%rbp)
  jmp    L27
L126:
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D30(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jne    L25
  movl   $0x0,-0x18(%rbp)
  jmp    L2
L135:
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L106
  addl   $0x1,-0x18(%rbp)
L2:
  mov    -0x18(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jl     L135
  jmp    L109
L106:
  nop
L109:
  mov    -0x18(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jne    L25
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L25:
  mov    -0x4(%rbp),%eax
  sub    -0x8(%rbp),%eax
  cmp    %eax,-0x1c(%rbp)
  jge    L79
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  imul   -0xc(%rbp),%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%eax
  sub    %edx,%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x1c(%rbp),%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  cltd
  idivl  -0x34(%rbp)
  mov    %edx,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jns    L79
  mov    -0x34(%rbp),%eax
  add    %eax,-0x10(%rbp)
L79:
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x1c(%rbp)
L27:
  mov    -0x4(%rbp),%eax
  sub    -0x8(%rbp),%eax
  cmp    %eax,-0x1c(%rbp)
  jle    L126
  nop
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D23
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D30
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D46
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D11
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D37
type_guessed: string

tool: D23: t %d 


tool: D30: comeco %d 


tool: D46: Padrao encontrado na posicao %d 


tool: D11: fiz %d 


tool: D37: fim %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);
  }
}
```