user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<search_and_replace_kw>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8d,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L30
L53:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    %eax,(%rdx)
  addl   $0x1,-0x20(%rbp)
L30:
  mov    -0x20(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L53
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L288
L27:
  cmpl   $0x0,-0x18(%rbp)
  je     L18
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x45,%al
  jne    L194
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  jne    L194
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  cmp    $0x44,%al
  jne    L194
  mov    -0x10(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L194
  movl   $0x0,-0x18(%rbp)
  jmp    L24
L194:
  movl   $0x0,-0x20(%rbp)
  jmp    L73
L8:
  movl   $0x1,-0x14(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L167
L173:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  jge    L235
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x10(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  je     L260
  movl   $0x0,-0x14(%rbp)
  jmp    L174
L235:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  je     L260
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L260
  movl   $0x0,-0x14(%rbp)
  jmp    L174
L260:
  addl   $0x1,-0x1c(%rbp)
L167:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  jle    L173
L174:
  cmpl   $0x0,-0x14(%rbp)
  je     L219
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <search_rep@plt>
L219:
  addl   $0x1,-0x20(%rbp)
L73:
  mov    -0x20(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L8
  jmp    L24
L18:
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x58,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x54,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  cmp    $0x45,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  movzbl (%rax),%eax
  cmp    $0x53,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x5,%rax
  movzbl (%rax),%eax
  cmp    $0x49,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x6,%rax
  movzbl (%rax),%eax
  cmp    $0x4f,%al
  jne    L24
  mov    -0x10(%rbp),%rax
  add    $0x7,%rax
  movzbl (%rax),%eax
  cmp    $0x4e,%al
  jne    L24
  movl   $0x1,-0x18(%rbp)
L24:
  addq   $0x50,-0x10(%rbp)
L288:
  mov    -0x10(%rbp),%rax
  sub    -0x28(%rbp),%rax
  lea    0x50(%rax),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  cmp    %rax,%rdx
  jl     L27
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int search_and_replace_kw(char *buf, int bufsize, char **key_in, char **key_out, int nk) {
  char *w;
  int i, j;
  int in_header;
  int match_flag;
  int *keysizes;
  keysizes = malloc(nk * sizeof(int));
  for (i = 0; i < nk; i++)
    keysizes[i] = (int)strlen(key_in[i]);
  w = buf;
  in_header = 1;
  while ((w - buf + 80) < bufsize) {
    if (in_header) {
      if (w[0] == 'E' && w[1] == 'N' && w[2] == 'D' && w[3] == ' ') {
        in_header = 0;
      } else {
        for (i = 0; i < nk; i++) {
          match_flag = 1;
          for (j = 0; j <= keysizes[i]; j++) {
            if (j < keysizes[i]) {
              if (key_in[i][j] != w[j]) {
                match_flag = 0;
                break;
              }
            } else {
              if ((w[j] != '=') && (w[j] != ' ')) {
                match_flag = 0;
                break;
              }
            }
          }
          if (match_flag) {
            search_rep(w, key_in[i], key_out[i]);
          }
        }
      }
    } else {
      if (w[0] == 'X' && w[1] == 'T' && w[2] == 'E' && w[3] == 'N' && w[4] == 'S' && w[5] == 'I' && w[6] == 'O' && w[7] == 'N') {
        in_header = 1;
      }
    }
    w += 80;
  }
  free(keysizes);
  return 0;
}
```