user: Demonstrate the C code that generates the assembly output below:

```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,0x30(%rsp)
  call   <strlen@plt>
  mov    %r14,0x8(%rsp)
  movq   $0x10,0x10(%rsp)
  cltq
  mov    %rax,(%rsp)
  jmp    L117
  nopl   0x0(%rax,%rax,1)
L10:
  mov    %r12,%rax
  sub    0x8(%rsp),%rax
  mov    %eax,-0x4(%rbx,%rbp,4)
  mov    (%rsp),%rax
  lea    (%r12,%rax,1),%r14
L117:
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <strstr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L7
  add    $0x1,%rbp
  cmp    %rbp,%r15
  jae    L10
  mov    0x10(%rsp),%r14
  mov    %rbx,%rdi
  add    %r14,%r15
  lea    0x0(,%r15,4),%esi
  call   <realloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L118
  add    %r14,%r14
  mov    $0x100000,%eax
  cmp    %rax,%r14
  cmovbe %r14,%rax
  mov    %rax,0x10(%rsp)
  jmp    L10
  nopw   0x0(%rax,%rax,1)
L7:
  mov    %r14,%r13
  mov    %rbx,%rax
  mov    0x8(%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,0x8(%rsp)
  test   %rbx,%rbx
  jne    L16
  mov    0x8(%rsp),%rdi
  add    $0x1,%rdi
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L13
  mov    0x28(%rsp),%rdi
  mov    %r14,%rsi
  call   <strcpy@plt>
L13:
  test   %rbp,%rbp
  je     L95
L20:
  mov    0x28(%rsp),%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L16:
  mov    0x30(%rsp),%rdi
  call   <strlen@plt>
  movslq %eax,%r12
  mov    %r12,%rax
  sub    (%rsp),%rax
  imul   %rbx,%rax
  add    0x8(%rsp),%rax
  lea    0x1(%rax),%rdi
  mov    %rax,0x38(%rsp)
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L13
  mov    0x28(%rsp),%r15
  movslq 0x0(%rbp),%rdx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq 0x0(%rbp),%rcx
  lea    -0x1(%rbx),%rax
  mov    %rbx,0x18(%rsp)
  mov    %rax,0x10(%rsp)
  lea    (%r15,%rcx,1),%r13
  xor    %r15d,%r15d
  mov    %r14,0x20(%rsp)
  mov    %r13,%rbx
  mov    0x30(%rsp),%r13
  mov    %r15,%r14
  nopw   0x0(%rax,%rax,1)
L116:
  mov    %r12,%rdx
  mov    %r13,%rsi
  lea    (%rbx,%r12,1),%r15
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    0x20(%rsp),%rcx
  movslq 0x0(%rbp,%r14,4),%rax
  add    (%rsp),%rax
  mov    0x8(%rsp),%rdx
  lea    (%rcx,%rax,1),%rsi
  cmp    0x10(%rsp),%r14
  je     L110
  movslq 0x4(%rbp,%r14,4),%rdx
L110:
  sub    %rax,%rdx
  mov    %r15,%rdi
  add    $0x1,%r14
  mov    %rdx,%rbx
  call   <memcpy@plt>
  add    %r15,%rbx
  cmp    0x18(%rsp),%r14
  jne    L116
  mov    0x28(%rsp),%rax
  mov    0x38(%rsp),%rcx
  movb   $0x0,(%rax,%rcx,1)
  jmp    L20
  nopl   0x0(%rax)
L118:
  mov    %rax,%rbp
L88:
  xor    %edi,%edi
  call   <free@plt>
  mov    %rbp,0x28(%rsp)
  jmp    L20
L95:
  mov    0x28(%rsp),%rbp
  jmp    L88
```

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