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

```asm
<str_replace>:
  endbr64
  push   %r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x20(%rsp)
  mov    %esi,0x2c(%rsp)
  mov    %rdx,(%rsp)
  mov    %r8,0x18(%rsp)
  test   %r9d,%r9d
  jle    L68
  mov    %rcx,%r13
  mov    %rdi,%r15
  mov    %rdx,%rdi
  mov    %r8,%r12
  lea    -0x1(%r9),%ebx
  mov    %r12,%r14
  call   <strlen@plt>
  mov    %r13,%rdi
  mov    %eax,0x28(%rsp)
  call   <strlen@plt>
  movslq %eax,%rcx
  mov    0x28(%rsp),%eax
  mov    %rcx,0x10(%rsp)
  mov    %rcx,%rbp
  test   %eax,%eax
  jne    L96
  mov    0x2c(%rsp),%eax
  mov    0x20(%rsp),%rsi
  cmp    %eax,%ebx
  mov    %eax,%r14d
  cmovle %ebx,%r14d
  mov    0x18(%rsp),%rbx
  mov    %r14d,%edx
  mov    %rbx,%rdi
  call   <memcpy@plt>
  movslq %r14d,%rax
  movb   $0x0,(%rbx,%rax,1)
L68:
  add    $0x38,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L37:
  mov    %rax,%r10
  sub    %r15,%r10
  mov    %r10d,%edx
  test   %r10d,%r10d
  jle    L19
  cmp    %r10d,%ebx
  mov    %r10,0x8(%rsp)
  jle    L79
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   <memcpy@plt>
  mov    0x8(%rsp),%r10
  movslq %r10d,%rax
  sub    %r10d,%ebx
  add    %rax,%r14
L19:
  cmp    %ebp,%ebx
  jle    L53
  mov    %r14,%rdi
  mov    %ebp,%edx
  mov    %r13,%rsi
  sub    %ebp,%ebx
  call   <memcpy@plt>
  movslq 0x28(%rsp),%r9
  add    0x10(%rsp),%r14
  lea    (%r12,%r9,1),%r15
L96:
  mov    (%rsp),%rsi
  mov    %r15,%rdi
  call   <strstr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L37
  movslq 0x2c(%rsp),%rax
  add    0x20(%rsp),%rax
  sub    %r15,%rax
  test   %eax,%eax
  jle    L70
  cmp    %eax,%ebx
  mov    %r14,%rdi
  mov    %r15,%rsi
  cmovg  %eax,%ebx
  mov    %ebx,%edx
  movslq %ebx,%rbx
  call   <memcpy@plt>
  add    %rbx,%r14
L70:
  movb   $0x0,(%r14)
  sub    0x18(%rsp),%r14d
  jmp    L68
  nopl   0x0(%rax)
L53:
  mov    %ebx,%edx
  mov    %r13,%rsi
L39:
  mov    %r14,%rdi
  movslq %ebx,%rbx
  call   <memcpy@plt>
  lea    (%r14,%rbx,1),%r8
  movb   $0x0,(%r8)
  mov    %r8d,%r14d
  sub    0x18(%rsp),%r14d
  jmp    L68
  nopl   (%rax)
L79:
  mov    %ebx,%edx
  mov    %r15,%rsi
  jmp    L39
```

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