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

```asm
<BS2PP_EmitCharString>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x22,%al
  je     L151
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x27,%al
  jne    L131
L151:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x20,(%rax)
L131:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x27,(%rax)
  jmp    L4
L173:
  lea    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <BS2PP_ParseChar@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x1f,-0x4(%rbp)
  jle    L179
  cmpl   $0x7d,-0x4(%rbp)
  jle    L200
L179:
  cmpl   $0xff,-0x4(%rbp)
  jle    L216
  mov    -0x18(%rbp),%rax
  mov    -0x4(%rbp),%edx
  lea    D0(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rax
  add    $0x6,%rax
  mov    %rax,-0x18(%rbp)
  jmp    L4
L216:
  cmpl   $0x1b,-0x4(%rbp)
  je     L153
  cmpl   $0x1b,-0x4(%rbp)
  jg     L100
  cmpl   $0xd,-0x4(%rbp)
  je     L60
  cmpl   $0xd,-0x4(%rbp)
  jg     L100
  cmpl   $0x9,-0x4(%rbp)
  je     L190
  cmpl   $0xa,-0x4(%rbp)
  je     L167
  jmp    L100
L60:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x72,(%rax)
  jmp    L114
L167:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x6e,(%rax)
  jmp    L114
L190:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x74,(%rax)
  jmp    L114
L153:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x65,(%rax)
  jmp    L114
L100:
  mov    -0x18(%rbp),%rax
  mov    -0x4(%rbp),%edx
  lea    D18(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    %rax,-0x18(%rbp)
  nop
L114:
  jmp    L4
L200:
  cmpl   $0x22,-0x4(%rbp)
  jne    L49
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
L49:
  cmpl   $0x27,-0x4(%rbp)
  jne    L83
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
L83:
  cmpl   $0x5c,-0x4(%rbp)
  jne    L155
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x5c,(%rax)
L155:
  mov    -0x4(%rbp),%edx
  lea    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <BS2PP_EmitChar@plt>
L4:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L173
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x27,(%rax)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D0
type_guessed: string
name: unpack_data
arguments: data_tag: D18
type_guessed: string

tool: D0: \u%04X

tool: D18: \x%02X

assistant: ```c
char *BS2PP_EmitCharString(char *t, char *s) {
  int i;
  if ((*(t - 1) == '\"') || (*(t - 1) == '\''))
    *t++ = ' ';
  *t++ = '\'';
  while (*s) {
    i = BS2PP_ParseChar(&s);
    if ((i < ' ') || (i >= '~')) {
      if (i > 0xFF) {
        sprintf(t, "\\u%04X", i);
        t += 6;
        continue;
      }
      switch (i) {
      case '\r':
        *t++ = '\\';
        *t++ = 'r';
        break;
      case '\n':
        *t++ = '\\';
        *t++ = 'n';
        break;
      case '\t':
        *t++ = '\\';
        *t++ = 't';
        break;
      case '\x1B':
        *t++ = '\\';
        *t++ = 'e';
        break;
      default:
        sprintf(t, "\\x%02X", i);
        t += 4;
        break;
      }
      continue;
    }
    if (i == '\"')
      *t++ = '\\';
    if (i == '\'')
      *t++ = '\\';
    if (i == '\\')
      *t++ = '\\';
    BS2PP_EmitChar(&t, i);
  }
  *t++ = '\'';
  *t = 0;
  return (t);
}
```