user: What would the C source look like for the assembly code provided here?

```asm
<replace_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8d,-0x64(%rbp)
  mov    -0x58(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L51
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  movl   $0x0,-0x34(%rbp)
  mov    -0x50(%rbp),%rdx
  mov    -0x48(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  jmp    L23
L15:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    %eax,%ebx
  jl     L96
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x58(%rbp),%rcx
  mov    -0x30(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L54
  addl   $0x1,-0x34(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x48(%rbp),%rax
  mov    %rax,%rcx
  mov    -0x50(%rbp),%rax
  sub    %rcx,%rax
  mov    %rax,%rdx
  mov    -0x60(%rbp),%rcx
  mov    -0x30(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x48(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x50(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,%rbx
  mov    -0x30(%rbp),%rax
  sub    -0x48(%rbp),%rax
  mov    %rax,%r13
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %r12d,%eax
  sub    %edx,%eax
  cltq
  mov    %r13,%rdx
  sub    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x30(%rbp),%rax
  mov    %rbx,%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x50(%rbp),%rdx
  mov    -0x48(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
L54:
  cmpl   $0x0,-0x64(%rbp)
  je     L9
  mov    -0x34(%rbp),%eax
  cmp    -0x64(%rbp),%eax
  jge    L43
L9:
  addq   $0x1,-0x30(%rbp)
L23:
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L15
  jmp    L81
L96:
  nop
  jmp    L81
L43:
  nop
L81:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L79
L51:
  nop
L79:
  add    $0x58,%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
```

assistant: ```c
void replace_string(char *string, size_t buffsize, char *search, char *replace, int max) {
  if (strstr(string, search) == NULL)
    return;
  char *tmp = malloc(buffsize);
  char *ptr;
  int i = 0;
  strncpy(tmp, string, buffsize);
  for (ptr = string; *ptr != 0; ptr++) {
    if (strlen(ptr) < strlen(search))
      break;
    if (strncmp(ptr, search, strlen(search)) == 0) {
      i++;
      strncpy(ptr, replace, buffsize - (ptr - string));
      ptr += strlen(replace);
      strncpy(ptr, tmp + (ptr - string) - (strlen(replace) - strlen(search)), buffsize - (ptr - string));
      strncpy(tmp, string, buffsize);
    }
    if (max != 0 && i >= max)
      break;
  }
  free(tmp);
}
```