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

```asm
<CodeQuality>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,(%rsp)
  movzbl (%rsi),%r13d
  mov    $0x0,%ebp
  cmp    $0x20,%r13b
  jle    L38
  lea    -0x1(%rdx),%eax
  mov    %eax,0xc(%rsp)
  movzbl 0x1(%rsi),%r15d
  cmp    $0x20,%r15b
  jle    L198
  lea    0x2(%rsi),%r14
  mov    $0x1,%ebx
  jmp    L23
L176:
  add    $0x1,%ebx
L192:
  add    $0x1,%r14
  movzbl -0x1(%r14),%r15d
  cmp    $0x20,%r15b
  jle    L65
L23:
  cmp    %r15b,%r13b
  je     L176
  cmp    %ebx,0xc(%rsp)
  jge    L61
  cmp    $0xff,%ebx
  jg     L52
  neg    %r13d
  movsbl %r13b,%edx
  movslq %ebp,%rdi
  add    (%rsp),%rdi
  mov    %ebx,%ecx
  lea    D15(%rip),%rsi
  call   <sprintf@plt>
  add    %eax,%ebp
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L61:
  lea    -0x1(%rbx),%ecx
  test   %ebx,%ebx
  jle    L145
  movslq %ebp,%rdx
  mov    (%rsp),%rsi
  lea    (%rsi,%rdx,1),%rax
  lea    0x1(%rsi,%rdx,1),%rdx
  lea    -0x1(%rbx),%esi
  add    %rsi,%rdx
L6:
  mov    %r13b,(%rax)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L6
  lea    0x1(%rcx,%rbp,1),%ebp
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L145:
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L52:
  mov    %r13d,%eax
  neg    %eax
  movsbl %al,%eax
  mov    %eax,0x8(%rsp)
L22:
  movslq %ebp,%rdi
  add    (%rsp),%rdi
  mov    $0xff,%ecx
  mov    0x8(%rsp),%edx
  lea    D15(%rip),%rsi
  call   <sprintf@plt>
  lea    0x0(%rbp,%rax,1),%r12d
  mov    %r12d,%ebp
  mov    %ebx,%edx
  sub    $0xff,%ebx
  cmp    $0xff,%ebx
  jg     L22
  cmp    %ebx,0xc(%rsp)
  jge    L90
  movslq %r12d,%rdi
  add    (%rsp),%rdi
  mov    %ebx,%ecx
  mov    0x8(%rsp),%edx
  lea    D15(%rip),%rsi
  call   <sprintf@plt>
  lea    (%r12,%rax,1),%ebp
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L90:
  movslq %r12d,%rcx
  add    (%rsp),%rcx
  mov    %rcx,%rax
  lea    -0xff(%rdx,%rcx,1),%esi
  test   %ebx,%ebx
  jle    L194
L83:
  mov    %r13b,(%rax)
  add    $0x1,%rax
  mov    %esi,%ecx
  sub    %eax,%ecx
  test   %ecx,%ecx
  jg     L83
  mov    $0x100,%eax
  cmp    %eax,%edx
  cmovl  %eax,%edx
  lea    -0xff(%rbp,%rdx,1),%ebp
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L194:
  mov    %r15d,%r13d
  mov    $0x1,%ebx
  jmp    L192
L198:
  mov    $0x0,%ebp
  mov    $0x1,%ebx
L65:
  cmp    %ebx,0xc(%rsp)
  jl     L59
  lea    -0x1(%rbx),%ecx
  test   %ebx,%ebx
  jle    L38
  movslq %ebp,%rdx
  mov    (%rsp),%rsi
  lea    (%rsi,%rdx,1),%rax
  lea    0x1(%rsi,%rdx,1),%rdx
  lea    -0x1(%rbx),%esi
  add    %rsi,%rdx
L24:
  mov    %r13b,(%rax)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L24
  lea    0x1(%rcx,%rbp,1),%ebp
L38:
  mov    %ebp,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L59:
  neg    %r13d
  movsbl %r13b,%edx
  movslq %ebp,%rdi
  add    (%rsp),%rdi
  mov    %ebx,%ecx
  lea    D15(%rip),%rsi
  call   <sprintf@plt>
  add    %eax,%ebp
  jmp    L38
```

tool_calls: name: extract_symbolic_data
arguments: label: D15
data_type: string

tool: D15: %c%c

assistant: ```c
int CodeQuality(char *buf, char *str, int n) {
  char prech, ch;
  int i, count = 1, len = 0;
  n--;
  if ((prech = *str) < 33)
    return len;
  for (i = 1; (ch = *(str + i)) > 32; i++) {
    if (prech == ch)
      count++;
    else {
      if (count > n) {
        if (count < 256)
          len += sprintf(buf + len, "%c%c", -prech, count);
        else {
          do {
            len += sprintf(buf + len, "%c%c", -prech, 255);
            count -= 255;
          } while (count > 255);
          if (count > n)
            len += sprintf(buf + len, "%c%c", -prech, count);
          else
            while (count-- > 0)
              *(buf + len++) = prech;
        }
      } else
        while (count-- > 0)
          *(buf + len++) = prech;
      count = 1;
      prech = ch;
    }
  }
  if (count > n)
    len += sprintf(buf + len, "%c%c", -prech, count);
  else
    while (count-- > 0)
      *(buf + len++) = prech;
  return len;
}
```