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

```asm
<str_replace>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x20(%rsp)
  mov    %esi,0x2c(%rsp)
  mov    %rdx,(%rsp)
  mov    %rcx,0x8(%rsp)
  mov    %r8,0x18(%rsp)
  mov    $0x0,%ebx
  test   %r9d,%r9d
  jle    L1
  mov    %rdi,%r12
  mov    %rcx,%r15
  mov    %r8,%r13
  lea    -0x1(%r9),%ebp
  mov    %rdx,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    %eax,0x28(%rsp)
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%r15d
  cltq
  mov    %rax,0x10(%rsp)
  test   %ebx,%ebx
  jne    L36
  mov    0x2c(%rsp),%eax
  cmp    %eax,%ebp
  mov    %eax,%ebx
  cmovle %ebp,%ebx
  mov    %ebx,%edx
  mov    0x20(%rsp),%rsi
  mov    0x18(%rsp),%r15
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq %ebx,%rax
  movb   $0x0,(%r15,%rax,1)
  jmp    L1
L94:
  mov    %ebp,%edx
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq %ebp,%rbx
  add    %r13,%rbx
  movb   $0x0,(%rbx)
  sub    0x18(%rsp),%ebx
  jmp    L1
L84:
  cmp    %r15d,%ebp
  jle    L44
  mov    %r15d,%edx
  mov    0x8(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  add    0x10(%rsp),%r13
  sub    %r15d,%ebp
  movslq 0x28(%rsp),%r12
  add    %rbx,%r12
L36:
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <strstr@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L37
  mov    %rax,%r14
  sub    %r12,%r14
  mov    %r14d,%edx
  test   %r14d,%r14d
  jle    L84
  cmp    %r14d,%ebp
  jle    L94
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq %r14d,%rax
  add    %rax,%r13
  sub    %r14d,%ebp
  jmp    L84
L44:
  mov    %ebp,%edx
  mov    0x8(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq %ebp,%rbx
  add    %r13,%rbx
  movb   $0x0,(%rbx)
  sub    0x18(%rsp),%ebx
  jmp    L1
L37:
  movslq 0x2c(%rsp),%rax
  add    0x20(%rsp),%rax
  sub    %r12,%rax
  test   %eax,%eax
  jg     L72
L48:
  movb   $0x0,0x0(%r13)
  mov    %r13d,%ebx
  sub    0x18(%rsp),%ebx
L1:
  mov    %ebx,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L72:
  cmp    %eax,%ebp
  cmovg  %eax,%ebp
  mov    %ebp,%edx
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq %ebp,%rbp
  add    %rbp,%r13
  jmp    L48
```

assistant: ```c
int str_replace(const char *s, const int src_len, const char *replaced, const char *new_str, char *dest, const int dest_size) {
  const char *pStart;
  const char *pEnd;
  char *pDest;
  const char *p;
  int old_len;
  int new_len;
  int len;
  int max_dest_len;
  int remain_len;
  if (dest_size <= 0) {
    return 0;
  }
  max_dest_len = dest_size - 1;
  old_len = strlen(replaced);
  new_len = strlen(new_str);
  if (old_len == 0) {
    len = src_len < max_dest_len ? src_len : max_dest_len;
    memcpy(dest, s, len);
    dest[len] = '\0';
    return len;
  }
  remain_len = max_dest_len;
  pDest = dest;
  pStart = s;
  pEnd = s + src_len;
  while (1) {
    p = strstr(pStart, replaced);
    if (p == NULL) {
      break;
    }
    len = p - pStart;
    if (len > 0) {
      if (len < remain_len) {
        memcpy(pDest, pStart, len);
        pDest += len;
        remain_len -= len;
      } else {
        memcpy(pDest, pStart, remain_len);
        pDest += remain_len;
        *pDest = '\0';
        return pDest - dest;
      }
    }
    if (new_len < remain_len) {
      memcpy(pDest, new_str, new_len);
      pDest += new_len;
      remain_len -= new_len;
    } else {
      memcpy(pDest, new_str, remain_len);
      pDest += remain_len;
      *pDest = '\0';
      return pDest - dest;
    }
    pStart = p + old_len;
  }
  len = pEnd - pStart;
  if (len > 0) {
    if (len > remain_len) {
      len = remain_len;
    }
    memcpy(pDest, pStart, len);
    pDest += len;
  }
  *pDest = '\0';
  return pDest - dest;
}
```