user: Please show me the C implementation that matches the assembly code listed below:

```asm
<__argz_replace>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rdi,0x28(%rsp)
  mov    %rsi,0x30(%rsp)
  mov    %r8,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  mov    $0x0,%r12d
  test   %rdx,%rdx
  je     L258
  mov    %rdx,%r15
  mov    %rcx,%rbp
  cmpb   $0x0,(%rdx)
  jne    L149
L258:
  mov    0x78(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L32
  mov    %r12,%rax
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L149:
  mov    (%rdi),%rax
  mov    %rax,(%rsp)
  mov    (%rsi),%rax
  mov    %rax,0x10(%rsp)
  movq   $0x0,0x58(%rsp)
  movq   $0x0,0x60(%rsp)
  mov    %rdx,%rdi
  call   <strlen@plt>
  cltq
  mov    %rax,0x38(%rsp)
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r14d
  movl   $0x1,0xc(%rsp)
  mov    $0x0,%ebx
  lea    0x60(%rsp),%rax
  mov    %rax,0x40(%rsp)
  lea    0x58(%rsp),%rax
  mov    %rax,0x48(%rsp)
  lea    0x68(%rsp),%r13
  jmp    L104
L39:
  mov    0x38(%rsp),%rcx
  lea    (%rax,%rcx,1),%r12
  sub    %rbx,%rax
  mov    %rax,%rsi
  mov    %rax,0x68(%rsp)
  mov    %rbx,%rdi
  call   <__strndup@plt>
  mov    %rax,0x70(%rsp)
L238:
  mov    0x70(%rsp),%rax
  test   %rax,%rax
  je     L178
  test   %r12,%r12
  je     L178
  lea    0x70(%rsp),%rdi
  mov    %r14d,%ecx
  mov    %rbp,%rdx
  mov    %r13,%rsi
  call   <str_append@plt>
  cmpq   $0x0,0x70(%rsp)
  je     L238
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <strstr@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L156
  lea    0x70(%rsp),%rdi
  mov    %eax,%ecx
  sub    %r12d,%ecx
  mov    %r12,%rdx
  mov    %r13,%rsi
  call   <str_append@plt>
  mov    0x20(%rsp),%r12
  add    0x38(%rsp),%r12
  jmp    L238
L156:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%ecx
  lea    0x70(%rsp),%rdi
  mov    %r12,%rdx
  mov    %r13,%rsi
  call   <str_append@plt>
  mov    0x20(%rsp),%r12
  jmp    L238
L178:
  test   %rax,%rax
  je     L10
  cmpl   $0x0,0xc(%rsp)
  je     L217
  cmp    %rbx,(%rsp)
  jb     L79
L217:
  mov    0x70(%rsp),%rdx
  mov    0x40(%rsp),%rsi
  mov    0x48(%rsp),%rdi
  call   <__argz_add@plt>
  mov    %rax,%r12
  jmp    L19
L79:
  mov    %ebx,%ecx
  mov    (%rsp),%rdx
  sub    %edx,%ecx
  mov    0x40(%rsp),%rsi
  mov    0x48(%rsp),%rdi
  call   <__argz_append@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L217
L19:
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  movl   $0x0,0xc(%rsp)
L188:
  mov    0x18(%rsp),%rax
  test   %rax,%rax
  je     L96
  addl   $0x1,(%rax)
L96:
  test   %r12,%r12
  jne    L253
L104:
  mov    %rbx,%rdx
  mov    0x10(%rsp),%rsi
  mov    (%rsp),%rdi
  call   <argz_next@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L248
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  jne    L39
  cmpl   $0x0,0xc(%rsp)
  jne    L104
  mov    %rbx,%rdx
  mov    0x40(%rsp),%rsi
  mov    0x48(%rsp),%rdi
  call   <__argz_add@plt>
  mov    %rax,%r12
  jmp    L96
L10:
  mov    D7(%rip),%rax
  mov    (%rax),%r12
  jmp    L188
L248:
  mov    $0x0,%r12d
  cmpl   $0x0,0xc(%rsp)
  jne    L258
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    0x58(%rsp),%rax
  mov    0x28(%rsp),%rbx
  mov    %rax,(%rbx)
  mov    0x60(%rsp),%rax
  mov    0x30(%rsp),%rbx
  mov    %rax,(%rbx)
  jmp    L258
L253:
  cmpq   $0x0,0x60(%rsp)
  je     L258
  mov    0x58(%rsp),%rdi
  call   <free@plt>
  jmp    L258
L32:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
error_t __argz_replace(char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count) {
  error_t err = 0;
  if (str && *str) {
    char *arg = 0;
    char *src = *argz;
    size_t src_len = *argz_len;
    char *dst = 0;
    size_t dst_len = 0;
    int delayed_copy = 1;
    size_t str_len = strlen(str), with_len = strlen(with);
    while (!err && (arg = argz_next(src, src_len, arg))) {
      char *match = strstr(arg, str);
      if (match) {
        char *from = match + str_len;
        size_t to_len = match - arg;
        char *to = __strndup(arg, to_len);
        while (to && from) {
          str_append(&to, &to_len, with, with_len);
          if (to) {
            match = strstr(from, str);
            if (match) {
              str_append(&to, &to_len, from, match - from);
              from = match + str_len;
            } else {
              str_append(&to, &to_len, from, strlen(from));
              from = 0;
            }
          }
        }
        if (to) {
          if (delayed_copy) {
            if (arg > src)
              err = __argz_append(&dst, &dst_len, src, (arg - src));
            delayed_copy = 0;
          }
          if (!err)
            err = __argz_add(&dst, &dst_len, to);
          free(to);
        } else
          err = ENOMEM;
        if (replace_count)
          (*replace_count)++;
      } else if (!delayed_copy)
        err = __argz_add(&dst, &dst_len, arg);
    }
    if (!err) {
      if (!delayed_copy) {
        free(src);
        *argz = dst;
        *argz_len = dst_len;
      }
    } else if (dst_len > 0)
      free(dst);
  }
  return err;
}
```