user: 请将以下的汇编代码转换成C语言代码：

```asm
<repl_str>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdi,%r14
  mov    %rsi,%rdi
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %r14,%rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x48,%rsp
  mov    %rdx,0x20(%rsp)
  call   <strlen@plt>
  mov    %r14,0x10(%rsp)
  mov    %rbx,%r14
  mov    %r15,%rbx
  cltq
  mov    %r13,%r15
  mov    %rax,0x8(%rsp)
  mov    $0x10,%eax
  mov    %rax,%r13
  jmp    L36
  nop
L91:
  mov    %rdx,%rax
  sub    0x10(%rsp),%rax
  mov    %rax,-0x8(%r12,%r14,8)
  mov    0x8(%rsp),%rax
  lea    (%rdx,%rax,1),%rbp
L36:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  mov    %rax,%rdx
  test   %rax,%rax
  je     L14
  add    $0x1,%r14
  cmp    %r14,%r15
  jae    L91
  add    %r13,%r15
  mov    %r12,%rdi
  mov    %rdx,0x18(%rsp)
  lea    0x0(,%r15,8),%esi
  call   <realloc@plt>
  mov    0x18(%rsp),%rdx
  test   %rax,%rax
  je     L90
  lea    0x0(%r13,%r13,2),%r13
  mov    $0x100000,%esi
  mov    %rax,%r12
  cmp    %rsi,%r13
  cmova  %rsi,%r13
  jmp    L91
  xchg   %ax,%ax
L14:
  mov    %r14,%rbx
  mov    %rbp,%rdi
  mov    0x10(%rsp),%r14
  mov    %rbp,%r13
  call   <strlen@plt>
  sub    %r14,%r13
  cltq
  add    %r13,%rax
  mov    %rax,0x30(%rsp)
  test   %rbx,%rbx
  jne    L27
  mov    %rax,%rdi
  add    $0x1,%rdi
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L113
  mov    %rax,%rdi
  mov    %r14,%rsi
  call   <strcpy@plt>
L113:
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L27:
  mov    0x20(%rsp),%rdi
  call   <strlen@plt>
  movslq %eax,%rbp
  mov    %rbp,%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     L90
  mov    (%r12),%rdx
  mov    %r14,%rsi
  mov    %rax,%rdi
  mov    %rax,%r13
  xor    %r15d,%r15d
  call   <memcpy@plt>
  lea    -0x1(%rbx),%rax
  add    (%r12),%r13
  mov    %rax,0x10(%rsp)
  mov    %rbx,%rax
  mov    %r15,%rbx
  mov    %rax,%r15
  nopl   (%rax)
L4:
  mov    0x20(%rsp),%rsi
  mov    %r13,%rdi
  mov    %rbp,%rdx
  add    %rbp,%r13
  call   <memcpy@plt>
  mov    0x8(%rsp),%rax
  add    (%r12,%rbx,8),%rax
  lea    (%r14,%rax,1),%rsi
  cmp    %rbx,0x10(%rsp)
  je     L126
  mov    0x8(%r12,%rbx,8),%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    %rbx,%r15
  jne    L4
  mov    0x28(%rsp),%rax
  mov    0x38(%rsp),%rcx
  movb   $0x0,(%rax,%rcx,1)
  jmp    L113
L126:
  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    %rbx,%r15
  jne    L4
  mov    0x28(%rsp),%rax
  mov    0x38(%rsp),%rcx
  movb   $0x0,(%rax,%rcx,1)
  jmp    L113
  nopl   0x0(%rax,%rax,1)
L90:
  movq   $0x0,0x28(%rsp)
  jmp    L113
```

assistant: ```c
char *repl_str(const char *str, const char *from, const char *to) {
  size_t cache_sz_inc = 16;
  const size_t cache_sz_inc_factor = 3;
  const size_t cache_sz_inc_max = 1048576;
  char *pret, *ret = NULL;
  const char *pstr2, *pstr = str;
  size_t i, count = 0;
  uintptr_t *pos_cache_tmp, *pos_cache = NULL;
  size_t cache_sz = 0;
  size_t cpylen, orglen, retlen, tolen, fromlen = strlen(from);
  while ((pstr2 = strstr(pstr, from)) != NULL) {
    count++;
    if (cache_sz < count) {
      cache_sz += cache_sz_inc;
      pos_cache_tmp = realloc(pos_cache, sizeof(*pos_cache) * cache_sz);
      if (pos_cache_tmp == NULL) {
        goto end_repl_str;
      } else
        pos_cache = pos_cache_tmp;
      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 + fromlen;
  }
  orglen = pstr - str + strlen(pstr);
  if (count > 0) {
    tolen = strlen(to);
    retlen = orglen + (tolen - fromlen) * 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, to, tolen);
      pret += tolen;
      pstr = str + pos_cache[i] + fromlen;
      cpylen = (i == count - 1 ? orglen : pos_cache[i + 1]) - pos_cache[i] - fromlen;
      memcpy(pret, pstr, cpylen);
      pret += cpylen;
    }
    ret[retlen] = '\0';
  }
end_repl_str:
  free(pos_cache);
  return ret;
}
```