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

```asm
<strreplace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x4c(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L87
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L87
  cmpq   $0x0,-0x40(%rbp)
  je     L87
  cmpq   $0x0,-0x48(%rbp)
  je     L87
  mov    $0x1,%eax
  jmp    L2
L87:
  mov    $0x0,%eax
L2:
  mov    %eax,%edi
  call   <assert@plt>
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x8(%rbp)
  movq   $0x0,-0x20(%rbp)
  jmp    L59
L45:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x8(%rbp),%rax
  cmp    -0x10(%rbp),%rax
  jbe    L11
  mov    -0x28(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  sub    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <xrealloc@plt>
  mov    -0x38(%rbp),%rdx
  mov    %rax,(%rdx)
L11:
  mov    -0x28(%rbp),%rax
  sub    -0x20(%rbp),%rax
  sub    -0x10(%rbp),%rax
  mov    -0x38(%rbp),%rdx
  mov    (%rdx),%rdx
  mov    -0x20(%rbp),%rsi
  mov    -0x10(%rbp),%rcx
  add    %rsi,%rcx
  lea    (%rdx,%rcx,1),%rsi
  mov    -0x38(%rbp),%rdx
  mov    (%rdx),%rdx
  mov    -0x20(%rbp),%rdi
  mov    -0x8(%rbp),%rcx
  add    %rdi,%rcx
  add    %rdx,%rcx
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  sub    -0x10(%rbp),%rax
  add    %rax,-0x28(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  add    %rax,-0x20(%rbp)
L59:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <strstr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L0
  mov    -0x4c(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x4c(%rbp)
  test   %eax,%eax
  jne    L45
L0:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  leave
  ret
```

assistant: ```c
char *strreplace(char **s, const char *find, const char *replace, int n_replace) {
  char *found;
  size_t s_len, find_len, replace_len, offset;
  assert(s != NULL && *s != NULL && find != NULL && replace != NULL);
  found = NULL;
  s_len = strlen(*s);
  find_len = strlen(find);
  replace_len = strlen(replace);
  offset = 0;
  while ((found = strstr(*s + offset, find)) != NULL && n_replace-- != 0) {
    offset = found - *s;
    if (replace_len > find_len)
      *s = xrealloc(*s, s_len + replace_len - find_len + 1);
    memmove(*s + offset + replace_len, *s + offset + find_len, s_len - offset - find_len);
    memcpy(*s + offset, replace, replace_len);
    s_len += replace_len - find_len;
    *(*s + s_len) = 0;
    offset += replace_len;
  }
  return *s;
}
```