user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<Q_StrReplace>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x840,%rsp
  mov    %rdi,-0x828(%rbp)
  mov    %rsi,-0x830(%rbp)
  mov    %rdx,-0x838(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x810(%rbp)
  movq   $0x0,-0x808(%rbp)
  lea    -0x800(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x7e,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  movq   $0x0,-0x410(%rbp)
  movq   $0x0,-0x408(%rbp)
  lea    -0x400(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x7e,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  movl   $0x0,-0x820(%rbp)
  movl   $0x0,-0x81c(%rbp)
  mov    -0x828(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L81
  lea    D2(%rip),%rax
  jmp    L39
L81:
  mov    -0x830(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L70
  mov    -0x828(%rbp),%rax
  mov    $0x400,%edx
  mov    %rax,%rsi
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
  lea    D2(%rip),%rax
  jmp    L39
L70:
  mov    -0x838(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L32
  mov    -0x838(%rbp),%rcx
  lea    -0x410(%rbp),%rax
  mov    $0x400,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
L32:
  movb   $0x0,-0x810(%rbp)
  mov    -0x830(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x820(%rbp)
  lea    -0x410(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x81c(%rbp)
  lea    -0x810(%rbp),%rax
  mov    %rax,-0x818(%rbp)
  jmp    L82
L108:
  mov    -0x820(%rbp),%edx
  mov    -0x830(%rbp),%rcx
  mov    -0x828(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_stricmpn@plt>
  test   %eax,%eax
  jne    L86
  lea    -0x410(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  mov    $0x400,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strcat@plt>
  mov    -0x820(%rbp),%eax
  cltq
  add    %rax,-0x828(%rbp)
  mov    -0x81c(%rbp),%eax
  cltq
  add    %rax,-0x818(%rbp)
  jmp    L82
L86:
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%rax
  cmp    $0x3ff,%rax
  ja     L0
  mov    -0x828(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x818(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x818(%rbp)
  mov    -0x818(%rbp),%rax
  movb   $0x0,(%rax)
L0:
  addq   $0x1,-0x828(%rbp)
L82:
  mov    -0x828(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L108
  lea    -0x810(%rbp),%rax
  mov    $0x400,%edx
  mov    %rax,%rsi
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
  lea    D2(%rip),%rax
L39:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L22
  call   <__stack_chk_fail@plt>
L22:
  leave
  ret
```

assistant: ```c
char *Q_StrReplace(char *haystack, char *needle, char *newp) {
  static char final[1024] = {""};
  char dest[1024] = {""};
  char newStr[1024] = {""};
  char *destp;
  int needle_len = 0;
  int new_len = 0;
  if (!*haystack) {
    return final;
  }
  if (!*needle) {
    Q_strncpyz(final, haystack, sizeof(final));
    return final;
  }
  if (*newp) {
    Q_strncpyz(newStr, newp, sizeof(newStr));
  }
  dest[0] = '\0';
  needle_len = strlen(needle);
  new_len = strlen(newStr);
  destp = &dest[0];
  while (*haystack) {
    if (!Q_stricmpn(haystack, needle, needle_len)) {
      Q_strcat(dest, sizeof(dest), newStr);
      haystack += needle_len;
      destp += new_len;
      continue;
    }
    if (1024 > (strlen(dest) + 1)) {
      *destp = *haystack;
      *++destp = '\0';
    }
    haystack++;
  }
  Q_strncpyz(final, dest, sizeof(final));
  return final;
}
```