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

```asm
<repl_str>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdi,%r14
  mov    %rsi,%rdi
  push   %r13
  mov    %r15,%r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %r12,%r15
  xor    %ebp,%ebp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x48,%rsp
  mov    %rdx,0x20(%rsp)
  call   <strlen@plt>
  mov    %r14,0x10(%rsp)
  movq   $0x10,0x18(%rsp)
  cltq
  mov    %rax,0x8(%rsp)
  jmp    L112
  nopl   0x0(%rax)
L0:
  mov    %r12,%rax
  sub    0x10(%rsp),%rax
  mov    %eax,-0x4(%rbx,%rbp,4)
  mov    0x8(%rsp),%rax
  lea    (%r12,%rax,1),%r14
L112:
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <strstr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L125
  add    $0x1,%rbp
  cmp    %rbp,%r15
  jae    L0
  mov    0x18(%rsp),%r14
  mov    %rbx,%rdi
  add    %r14,%r15
  lea    0x0(,%r15,4),%esi
  call   <realloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L113
  add    %r14,%r14
  mov    $0x100000,%eax
  cmp    %rax,%r14
  cmovbe %r14,%rax
  mov    %rax,0x18(%rsp)
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L125:
  mov    %r14,%r13
  mov    %rbx,%rax
  mov    0x10(%rsp),%r14
  mov    %rbp,%rbx
  mov    %r13,%rdi
  mov    %rax,%rbp
  mov    %r13,%r12
  call   <strlen@plt>
  sub    %r14,%r12
  cltq
  add    %r12,%rax
  mov    %rax,0x30(%rsp)
  test   %rbx,%rbx
  jne    L93
  mov    %rax,%rdi
  add    $0x1,%rdi
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L3
  mov    %rax,%rdi
  mov    %r14,%rsi
  call   <strcpy@plt>
L3:
  test   %rbp,%rbp
  je     L129
L148:
  mov    0x28(%rsp),%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L93:
  mov    0x20(%rsp),%rdi
  call   <strlen@plt>
  movslq %eax,%r12
  mov    %r12,%rax
  sub    0x8(%rsp),%rax
  imul   %rbx,%rax
  add    0x30(%rsp),%rax
  lea    0x1(%rax),%rdi
  mov    %rax,0x38(%rsp)
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L3
  movslq 0x0(%rbp),%rdx
  mov    %r14,%rsi
  mov    %rax,%rdi
  mov    %rax,%r15
  call   <memcpy@plt>
  movslq 0x0(%rbp),%rcx
  lea    -0x1(%rbx),%rax
  mov    %rax,0x10(%rsp)
  mov    %rbx,%rax
  lea    (%r15,%rcx,1),%r13
  xor    %r15d,%r15d
  mov    %r15,%rbx
  mov    %rax,%r15
  nopl   (%rax)
L31:
  mov    0x20(%rsp),%rsi
  mov    %r13,%rdi
  mov    %r12,%rdx
  add    %r12,%r13
  call   <memcpy@plt>
  movslq 0x0(%rbp,%rbx,4),%rax
  add    0x8(%rsp),%rax
  lea    (%r14,%rax,1),%rsi
  cmp    %rbx,0x10(%rsp)
  je     L111
  movslq 0x4(%rbp,%rbx,4),%rdx
  mov    %r13,%rdi
  add    $0x1,%rbx
  sub    %rax,%rdx
  mov    %rdx,0x18(%rsp)
  call   <memcpy@plt>
  mov    0x18(%rsp),%rdx
  add    %rdx,%r13
  cmp    %r15,%rbx
  jne    L31
  mov    0x28(%rsp),%rax
  mov    0x38(%rsp),%rcx
  movb   $0x0,(%rax,%rcx,1)
  jmp    L148
  nopl   0x0(%rax)
L111:
  mov    0x30(%rsp),%rbx
  mov    %r13,%rdi
  sub    %rax,%rbx
  mov    %rbx,%rdx
  add    %rbx,%r13
  call   <memcpy@plt>
  mov    0x10(%rsp),%rax
  lea    0x1(%rax),%rbx
  cmp    %r15,%rbx
  jne    L31
  mov    0x28(%rsp),%rax
  mov    0x38(%rsp),%rcx
  movb   $0x0,(%rax,%rcx,1)
  jmp    L148
  nopl   0x0(%rax,%rax,1)
L113:
  mov    %rax,%rbp
L6:
  xor    %edi,%edi
  call   <free@plt>
  mov    %rbp,0x28(%rsp)
  jmp    L148
L129:
  mov    0x28(%rsp),%rbp
  jmp    L6
```

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;
}
```