user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```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    L29
  mov    $0x0,%eax
  jmp    L44
L29:
  cmpq   $0x0,-0x40(%rbp)
  jne    L23
  lea    D1(%rip),%rax
  mov    %rax,-0x40(%rbp)
L23:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x24(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  jne    L52
  lea    D1(%rip),%rax
  mov    %rax,-0x48(%rbp)
L52:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L83
L14:
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  addl   $0x1,-0x28(%rbp)
L83:
  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    L14
  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    L49
  mov    $0x0,%eax
  jmp    L44
L73:
  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)
L49:
  mov    -0x28(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  test   %eax,%eax
  jne    L73
  mov    -0x38(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x8(%rbp),%rax
L44:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D1
type_infered: string

tool: 

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