user: What is the c source code of the assembly code below:

```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)
  cmpq   $0x0,-0x828(%rbp)
  je     L102
  mov    -0x828(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L106
L102:
  lea    D9(%rip),%rax
  jmp    L101
L106:
  cmpq   $0x0,-0x830(%rbp)
  je     L42
  mov    -0x830(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L38
L42:
  mov    -0x828(%rbp),%rax
  mov    $0x400,%edx
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
  lea    D9(%rip),%rax
  jmp    L101
L38:
  mov    -0x838(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L33
  mov    -0x838(%rbp),%rcx
  lea    -0x410(%rbp),%rax
  mov    $0x400,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
L33:
  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
L70:
  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    L47
  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
L47:
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%rax
  cmp    $0x3ff,%rax
  ja     L25
  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)
L25:
  addq   $0x1,-0x828(%rbp)
L82:
  mov    -0x828(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L70
  lea    -0x810(%rbp),%rax
  mov    $0x400,%edx
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <Q_strncpyz@plt>
  lea    D9(%rip),%rax
L101:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L115
  call   <__stack_chk_fail@plt>
L115:
  leave
  ret
```

assistant: ```c
char *Q_StrReplace(char *haystack, char *needle, char *newp) {
  static char final[1024] = {""};
  char dest[1024] = {""};
  char new[1024] = {""};
  char *destp;
  int needle_len = 0;
  int new_len = 0;
  if (!haystack || !*haystack) {
    return final;
  }
  if (!needle || !*needle) {
    Q_strncpyz(final, haystack, sizeof(final));
    return final;
  }
  if (*newp) {
    Q_strncpyz(new, newp, sizeof(new));
  }
  dest[0] = '\0';
  needle_len = strlen(needle);
  new_len = strlen(new);
  destp = &dest[0];
  while (*haystack) {
    if (!Q_stricmpn(haystack, needle, needle_len)) {
      Q_strcat(dest, sizeof(dest), new);
      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;
}
```