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

```asm
<CG_FitTextToWidth2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x460,%rsp
  mov    %rdi,-0x448(%rbp)
  movss  %xmm0,-0x44c(%rbp)
  movss  %xmm1,-0x450(%rbp)
  mov    %esi,-0x454(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x448(%rbp),%rcx
  lea    -0x410(%rbp),%rax
  mov    $0x400,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <Q_strncpyz@plt>
  mov    -0x454(%rbp),%edx
  mov    -0x448(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x448(%rbp),%rax
  mov    %rax,-0x430(%rbp)
  mov    -0x430(%rbp),%rax
  mov    %rax,-0x420(%rbp)
  lea    -0x410(%rbp),%rax
  mov    %rax,-0x428(%rbp)
  movq   $0x0,-0x418(%rbp)
  movl   $0x0,-0x434(%rbp)
  jmp    L41
L43:
  mov    -0x428(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x428(%rbp)
  movzbl (%rax),%edx
  mov    -0x420(%rbp),%rax
  mov    %dl,(%rax)
  addl   $0x1,-0x434(%rbp)
  mov    -0x420(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L112
  mov    -0x420(%rbp),%rax
  mov    %rax,-0x418(%rbp)
L112:
  addq   $0x1,-0x420(%rbp)
  mov    -0x428(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L7
  mov    -0x420(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x430(%rbp)
  movl   $0x0,-0x434(%rbp)
  jmp    L41
L7:
  mov    -0x44c(%rbp),%edx
  mov    -0x430(%rbp),%rax
  mov    $0x0,%esi
  movd   %edx,%xmm0
  mov    %rax,%rdi
  call   <CG_Text_Width@plt>
  movd   %xmm0,%eax
  movd   %eax,%xmm2
  comiss -0x450(%rbp),%xmm2
  ja     L47
  jmp    L41
L47:
  cmpq   $0x0,-0x418(%rbp)
  je     L68
  mov    -0x418(%rbp),%rax
  movb   $0xa,(%rax)
  mov    -0x418(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x430(%rbp)
  jmp    L83
L68:
  mov    -0x420(%rbp),%rax
  movzbl -0x1(%rax),%edx
  mov    -0x420(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x420(%rbp),%rax
  sub    $0x1,%rax
  movb   $0xa,(%rax)
  mov    -0x420(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x420(%rbp)
  mov    %rax,-0x430(%rbp)
L83:
  movq   $0x0,-0x418(%rbp)
  movl   $0x0,-0x434(%rbp)
L41:
  mov    -0x428(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L43
  lea    -0x410(%rbp),%rax
  cmp    %rax,-0x420(%rbp)
  je     L106
  mov    -0x420(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  je     L106
  mov    -0x420(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x420(%rbp)
  movb   $0xa,(%rax)
L106:
  mov    -0x420(%rbp),%rax
  movb   $0x0,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L85
  call   <__stack_chk_fail@plt>
L85:
  leave
  ret
```

assistant: ```c
void CG_FitTextToWidth2(char *instr, float scale, float w, int size) {
  char buffer[1024];
  char *s, *p, *c, *ls;
  int l;
  Q_strncpyz(buffer, instr, 1024);
  memset(instr, 0, size);
  c = s = instr;
  p = buffer;
  ls = ((void *)0);
  l = 0;
  while (*p) {
    *c = *p++;
    l++;
    if (*c == ' ') {
      ls = c;
    }
    c++;
    if (*p == '\n') {
      s = c + 1;
      l = 0;
    } else if (CG_Text_Width(s, scale, 0) > w) {
      if (ls) {
        *ls = '\n';
        s = ls + 1;
      } else {
        *c = *(c - 1);
        *(c - 1) = '\n';
        s = c++;
      }
      ls = ((void *)0);
      l = 0;
    }
  }
  if (c != buffer && (*(c - 1) != '\n')) {
    *c++ = '\n';
  }
  *c = '\0';
}
```