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

```asm
<repl_str>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    %rdi,-0xa8(%rbp)
  mov    %rsi,-0xb0(%rbp)
  mov    %rdx,-0xb8(%rbp)
  movq   $0x10,-0x98(%rbp)
  movq   $0x3,-0x48(%rbp)
  movq   $0x100000,-0x40(%rbp)
  movq   $0x0,-0x88(%rbp)
  mov    -0xa8(%rbp),%rax
  mov    %rax,-0x80(%rbp)
  movq   $0x0,-0x70(%rbp)
  movq   $0x0,-0x68(%rbp)
  movq   $0x0,-0x60(%rbp)
  mov    -0xb0(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  mov    %rax,-0x38(%rbp)
  jmp    L50
L14:
  addq   $0x1,-0x70(%rbp)
  mov    -0x60(%rbp),%rax
  cmp    -0x70(%rbp),%rax
  jae    L23
  mov    -0x98(%rbp),%rax
  add    %rax,-0x60(%rbp)
  mov    -0x60(%rbp),%rax
  shl    $0x3,%eax
  mov    %eax,%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L136
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x68(%rbp)
  mov    -0x98(%rbp),%rax
  imul   -0x48(%rbp),%rax
  mov    %rax,-0x98(%rbp)
  mov    -0x98(%rbp),%rax
  cmp    -0x40(%rbp),%rax
  jbe    L23
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x98(%rbp)
L23:
  mov    -0x30(%rbp),%rax
  sub    -0xa8(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x70(%rbp),%rax
  shl    $0x3,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x68(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x80(%rbp)
L50:
  mov    -0xb0(%rbp),%rdx
  mov    -0x80(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  jne    L14
  mov    -0x80(%rbp),%rax
  sub    -0xa8(%rbp),%rax
  mov    %rax,%rbx
  mov    -0x80(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  add    %rbx,%rax
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x70(%rbp)
  je     L7
  mov    -0xb8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  mov    %rax,-0x50(%rbp)
  mov    -0x50(%rbp),%rax
  sub    -0x38(%rbp),%rax
  imul   -0x70(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x58(%rbp)
  jmp    L110
L7:
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x58(%rbp)
L110:
  mov    -0x58(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x88(%rbp)
  cmpq   $0x0,-0x88(%rbp)
  je     L106
  cmpq   $0x0,-0x70(%rbp)
  jne    L84
  mov    -0xa8(%rbp),%rdx
  mov    -0x88(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L122
L84:
  mov    -0x88(%rbp),%rax
  mov    %rax,-0x90(%rbp)
  mov    -0x68(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0xa8(%rbp),%rcx
  mov    -0x90(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x68(%rbp),%rax
  mov    (%rax),%rax
  add    %rax,-0x90(%rbp)
  movq   $0x0,-0x78(%rbp)
  jmp    L49
L123:
  mov    -0x50(%rbp),%rdx
  mov    -0xb8(%rbp),%rcx
  mov    -0x90(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x50(%rbp),%rax
  add    %rax,-0x90(%rbp)
  mov    -0x78(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0xa8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x80(%rbp)
  mov    -0x70(%rbp),%rax
  sub    $0x1,%rax
  cmp    %rax,-0x78(%rbp)
  je     L112
  mov    -0x78(%rbp),%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  jmp    L104
L112:
  mov    -0x28(%rbp),%rax
L104:
  mov    -0x78(%rbp),%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x68(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rdx
  sub    %rdx,%rax
  sub    -0x38(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x80(%rbp),%rcx
  mov    -0x90(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x20(%rbp),%rax
  add    %rax,-0x90(%rbp)
  addq   $0x1,-0x78(%rbp)
L49:
  mov    -0x78(%rbp),%rax
  cmp    -0x70(%rbp),%rax
  jb     L123
  mov    -0x88(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  jmp    L122
L136:
  nop
  jmp    L122
L106:
  nop
L122:
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x88(%rbp),%rax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

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