user: Converte this assembly snippet into its equivalent C code:

```asm
<CodeQuality>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x1,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  subl   $0x1,-0x24(%rbp)
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0xe(%rbp)
  cmpb   $0x20,-0xe(%rbp)
  jg     L159
  mov    -0x4(%rbp),%eax
  jmp    L41
L159:
  movl   $0x1,-0xc(%rbp)
  jmp    L50
L135:
  movzbl -0xe(%rbp),%eax
  cmp    -0xd(%rbp),%al
  jne    L146
  addl   $0x1,-0x8(%rbp)
  jmp    L9
L146:
  mov    -0x8(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L85
  cmpl   $0xff,-0x8(%rbp)
  jg     L92
  movzbl -0xe(%rbp),%eax
  neg    %eax
  movsbl %al,%eax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x8(%rbp),%edx
  mov    %edx,%ecx
  mov    %eax,%edx
  lea    D39(%rip),%rax
  mov    %rax,%rsi
  call   <sprintf@plt>
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L63
L92:
  movzbl -0xe(%rbp),%eax
  neg    %eax
  movsbl %al,%eax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    $0xff,%ecx
  mov    %eax,%edx
  lea    D39(%rip),%rax
  mov    %rax,%rsi
  call   <sprintf@plt>
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  subl   $0xff,-0x8(%rbp)
  cmpl   $0xff,-0x8(%rbp)
  jg     L92
  mov    -0x8(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L52
  movzbl -0xe(%rbp),%eax
  neg    %eax
  movsbl %al,%eax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x8(%rbp),%edx
  mov    %edx,%ecx
  mov    %eax,%edx
  lea    D39(%rip),%rax
  mov    %rax,%rsi
  call   <sprintf@plt>
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L63
L12:
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl -0xe(%rbp),%eax
  mov    %al,(%rdx)
L52:
  mov    -0x8(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x8(%rbp)
  test   %eax,%eax
  jg     L12
  jmp    L63
L21:
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl -0xe(%rbp),%eax
  mov    %al,(%rdx)
L85:
  mov    -0x8(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x8(%rbp)
  test   %eax,%eax
  jg     L21
L63:
  movl   $0x1,-0x8(%rbp)
  movzbl -0xd(%rbp),%eax
  mov    %al,-0xe(%rbp)
L9:
  addl   $0x1,-0xc(%rbp)
L50:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0xd(%rbp)
  cmpb   $0x20,-0xd(%rbp)
  jg     L135
  mov    -0x8(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L130
  movzbl -0xe(%rbp),%eax
  neg    %eax
  movsbl %al,%eax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x8(%rbp),%edx
  mov    %edx,%ecx
  mov    %eax,%edx
  lea    D39(%rip),%rax
  mov    %rax,%rsi
  call   <sprintf@plt>
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L150
L136:
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl -0xe(%rbp),%eax
  mov    %al,(%rdx)
L130:
  mov    -0x8(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x8(%rbp)
  test   %eax,%eax
  jg     L136
L150:
  mov    -0x4(%rbp),%eax
L41:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D39
data_type: string

tool: D39: %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;
}
```