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

```asm
<repl_str>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%r12
  mov    %rdi,0x8(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %rsi,%rdi
  call   <strlen@plt>
  cltq
  mov    %rax,0x10(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%r15d
  mov    $0x0,%ebp
  mov    $0x10,%r14d
  jmp    L113
L16:
  mov    %rbx,%rax
  sub    0x8(%rsp),%rax
  mov    %eax,-0x4(%r15,%rbp,4)
  mov    0x10(%rsp),%rax
  lea    (%rbx,%rax,1),%r12
L113:
  mov    0x18(%rsp),%rsi
  mov    %r12,%rdi
  call   <strstr@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L91
  add    $0x1,%rbp
  cmp    %rbp,%r13
  jae    L16
  add    %r14,%r13
  lea    0x0(,%r13,4),%esi
  mov    %r15,%rdi
  call   <realloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L110
  add    %r14,%r14
  mov    $0x100000,%eax
  cmp    %rax,%r14
  cmova  %rax,%r14
  jmp    L16
L91:
  mov    %r12,%r14
  sub    0x8(%rsp),%r14
  mov    %r12,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%r14
  test   %rbp,%rbp
  jne    L95
  lea    0x1(%r14),%rdi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  test   %rax,%rax
  je     L121
  mov    0x8(%rsp),%rsi
  mov    0x30(%rsp),%rdi
  call   <strcpy@plt>
L121:
  test   %r15,%r15
  je     L9
L47:
  mov    0x30(%rsp),%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L95:
  mov    0x20(%rsp),%rdi
  call   <strlen@plt>
  cltq
  mov    %rax,0x28(%rsp)
  sub    0x10(%rsp),%rax
  imul   %rbp,%rax
  add    %r14,%rax
  mov    %rax,0x38(%rsp)
  lea    0x1(%rax),%rdi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  test   %rax,%rax
  je     L121
  movslq (%r15),%rdx
  mov    0x8(%rsp),%rsi
  mov    0x30(%rsp),%r12
  mov    %r12,%rdi
  call   <memcpy@plt>
  movslq (%r15),%rbx
  add    %r12,%rbx
  mov    $0x0,%r12d
  lea    -0x1(%rbp),%rax
  mov    %rax,0x18(%rsp)
  jmp    L103
L133:
  sub    %rax,%r13
  mov    %r13,%rdx
  mov    %rbx,%rdi
  call   <memcpy@plt>
  add    %r13,%rbx
  add    $0x1,%r12
  cmp    %r12,%rbp
  je     L136
L103:
  mov    0x28(%rsp),%r13
  mov    %r13,%rdx
  mov    0x20(%rsp),%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  add    %r13,%rbx
  movslq (%r15,%r12,4),%rax
  add    0x10(%rsp),%rax
  mov    0x8(%rsp),%rcx
  lea    (%rcx,%rax,1),%rsi
  mov    %r14,%r13
  cmp    %r12,0x18(%rsp)
  je     L133
  movslq 0x4(%r15,%r12,4),%r13
  jmp    L133
L136:
  mov    0x30(%rsp),%rax
  mov    0x38(%rsp),%rdx
  movb   $0x0,(%rax,%rdx,1)
  jmp    L47
L9:
  mov    0x30(%rsp),%r15
L110:
  mov    $0x0,%edi
  call   <free@plt>
  mov    %r15,0x30(%rsp)
  jmp    L47
```

assistant: ```c
char *repl_str(const char *str, const char *old, const char *new) {
  size_t cache_sz_inc = 16;
  const size_t cache_sz_inc_factor = 2;
  const size_t cache_sz_inc_max = 1048576;
  char *pret, *ret = NULL;
  const char *pstr2, *pstr = str;
  size_t i, count = 0;
  ptrdiff_t *pos_cache = NULL;
  size_t cache_sz = 0;
  size_t cpylen, orglen, retlen, newlen, oldlen = strlen(old);
  while ((pstr2 = strstr(pstr, old)) != NULL) {
    count++;
    if (cache_sz < count) {
      cache_sz += cache_sz_inc;
      pos_cache = realloc(pos_cache, sizeof(*pos_cache) * cache_sz);
      if (pos_cache == NULL) {
        goto end_repl_str;
      }
      cache_sz_inc *= cache_sz_inc_factor;
      if (cache_sz_inc > cache_sz_inc_max) {
        cache_sz_inc = cache_sz_inc_max;
      }
    }
    pos_cache[count - 1] = pstr2 - str;
    pstr = pstr2 + oldlen;
  }
  orglen = pstr - str + strlen(pstr);
  if (count > 0) {
    newlen = strlen(new);
    retlen = orglen + (newlen - oldlen) * count;
  } else
    retlen = orglen;
  ret = malloc(retlen + 1);
  if (ret == NULL) {
    goto end_repl_str;
  }
  if (count == 0) {
    strcpy(ret, str);
  } else {
    pret = ret;
    memcpy(pret, str, pos_cache[0]);
    pret += pos_cache[0];
    for (i = 0; i < count; i++) {
      memcpy(pret, new, newlen);
      pret += newlen;
      pstr = str + pos_cache[i] + oldlen;
      cpylen = (i == count - 1 ? orglen : pos_cache[i + 1]) - pos_cache[i] - oldlen;
      memcpy(pret, pstr, cpylen);
      pret += cpylen;
    }
    ret[retlen] = '\0';
  }
end_repl_str:
  if (!pos_cache)
    free(pos_cache);
  return ret;
}
```