user: What is the c source code of the assembly code below?

```asm
<str_replace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L105
  mov    $0x0,%eax
  jmp    L117
L105:
  cmpq   $0x0,-0x40(%rbp)
  je     L62
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jne    L74
L62:
  mov    $0x0,%eax
  jmp    L117
L74:
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L122
  mov    $0x0,%eax
  jmp    L117
L122:
  cmpq   $0x0,-0x48(%rbp)
  jne    L79
  lea    D1(%rip),%rax
  mov    %rax,-0x48(%rbp)
L79:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L33
L95:
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  addl   $0x1,-0x28(%rbp)
L33:
  mov    -0x40(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L95
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  sub    -0x24(%rbp),%eax
  imul   -0x28(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L37
  mov    $0x0,%eax
  jmp    L117
L96:
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x38(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %rax,%rdx
  mov    -0x20(%rbp),%eax
  cltq
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  cltq
  add    %rax,-0x38(%rbp)
L37:
  mov    -0x28(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  test   %eax,%eax
  jne    L96
  mov    -0x38(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x8(%rbp),%rax
L117:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D1
type: string

tool: 

assistant: ```c
char *str_replace(char *orig, char *rep, char *with) {
  char *result;
  char *ins;
  char *tmp;
  int len_rep;
  int len_with;
  int len_front;
  int count;
  if (!orig)
    return NULL;
  if (!rep || !(len_rep = strlen(rep)))
    return NULL;
  if (!(ins = strstr(orig, rep)))
    return NULL;
  if (!with)
    with = "";
  len_with = strlen(with);
  for (count = 0; tmp = strstr(ins, rep); ++count) {
    ins = tmp + len_rep;
  }
  tmp = result = (char *)malloc(strlen(orig) + (len_with - len_rep) * count + 1);
  if (!result)
    return NULL;
  while (count--) {
    ins = strstr(orig, rep);
    len_front = ins - orig;
    tmp = strncpy(tmp, orig, len_front) + len_front;
    tmp = strcpy(tmp, with) + len_with;
    orig += len_front + len_rep;
  }
  strcpy(tmp, orig);
  return result;
}
```