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

```asm
<string_replace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L126
  cmpq   $0x0,-0x30(%rbp)
  je     L126
  cmpq   $0x0,-0x38(%rbp)
  jne    L68
L126:
  mov    $0x0,%eax
  jmp    L36
L68:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x18(%rbp)
  movl   $0x0,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L111
L6:
  addl   $0x1,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    %rax,-0x10(%rbp)
L111:
  cmpq   $0x0,-0x10(%rbp)
  je     L29
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L29
  mov    -0x30(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L6
L29:
  cmpl   $0x0,-0x20(%rbp)
  jne    L160
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  jmp    L36
L160:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x20(%rbp),%edx
  imul   -0x1c(%rbp),%edx
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x20(%rbp),%eax
  imul   -0x18(%rbp),%eax
  add    %ecx,%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L98
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  jmp    L36
L98:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L66
L10:
  mov    -0x30(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L155
  mov    -0x10(%rbp),%rax
  sub    -0x28(%rbp),%rax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncat@plt>
  mov    -0x38(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x1c(%rbp),%eax
  cltq
  add    %rax,-0x10(%rbp)
  jmp    L118
L155:
  mov    -0x28(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L118:
  mov    -0x10(%rbp),%rax
  mov    %rax,-0x28(%rbp)
L66:
  cmpq   $0x0,-0x28(%rbp)
  je     L109
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L10
L109:
  mov    -0x8(%rbp),%rax
L36:
  leave
  ret
```

assistant: ```c
char *string_replace(const char *string, const char *search, const char *replace) {
  const char *pos;
  char *new_string;
  int length1, length2, length_new, count;
  if (!string || !search || !replace)
    return NULL;
  length1 = strlen(search);
  length2 = strlen(replace);
  count = 0;
  pos = string;
  while (pos && pos[0] && (pos = strstr(pos, search))) {
    count++;
    pos += length1;
  }
  if (count == 0)
    return strdup(string);
  length_new = strlen(string) - (count * length1) + (count * length2) + 1;
  new_string = malloc(length_new);
  if (!new_string)
    return strdup(string);
  new_string[0] = '\0';
  while (string && string[0]) {
    pos = strstr(string, search);
    if (pos) {
      strncat(new_string, string, pos - string);
      strcat(new_string, replace);
      pos += length1;
    } else
      strcat(new_string, string);
    string = pos;
  }
  return new_string;
}
```