user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<BTSHASP_EmitString>:
  endbr64
  push   %r13
  mov    %rdi,%rax
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,(%rsp)
  movzbl -0x1(%rdi),%edx
  cmp    $0x22,%dl
  je     L55
  cmp    $0x27,%dl
  je     L55
L5:
  lea    0x1(%rax),%rdx
  mov    %rsp,%rbx
  lea    0x8(%rsp),%rbp
  mov    %rdx,0x8(%rsp)
  lea    D19(%rip),%r13
  lea    D8(%rip),%r12
  movb   $0x22,(%rax)
  nopw   0x0(%rax,%rax,1)
L170:
  mov    (%rsp),%rax
  cmpb   $0x0,(%rax)
  je     L46
L113:
  mov    %rbx,%rdi
  call   <BTSHASP_ParseChar@plt>
  mov    %eax,%esi
  lea    -0x20(%rax),%eax
  cmp    $0x5d,%eax
  jbe    L198
  mov    0x8(%rsp),%rdi
  cmp    $0xff,%esi
  jg     L31
  cmp    $0xd,%esi
  je     L9
  jg     L143
  cmp    $0x9,%esi
  je     L95
  cmp    $0xa,%esi
  jne    L29
  lea    0x1(%rdi),%rax
  mov    %rax,0x8(%rsp)
  movb   $0x5c,(%rdi)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x6e,(%rax)
  mov    (%rsp),%rax
  cmpb   $0x0,(%rax)
  jne    L113
L46:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x22,(%rax)
  mov    0x8(%rsp),%rax
  movb   $0x0,(%rax)
  mov    0x8(%rsp),%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L198:
  cmp    $0x22,%esi
  je     L36
  cmp    $0x27,%esi
  je     L36
  cmp    $0x5c,%esi
  jne    L127
L36:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
L127:
  mov    %rbp,%rdi
  call   <BTSHASP_EmitChar@plt>
  jmp    L170
  nopl   (%rax)
L143:
  cmp    $0x1b,%esi
  jne    L29
  lea    0x1(%rdi),%rax
  mov    %rax,0x8(%rsp)
  movb   $0x5c,(%rdi)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x65,(%rax)
  jmp    L170
  nopw   0x0(%rax,%rax,1)
L31:
  mov    %esi,%edx
  mov    %r12,%rsi
  call   <sprintf@plt>
  addq   $0x6,0x8(%rsp)
  jmp    L170
  nopl   (%rax)
L9:
  lea    0x1(%rdi),%rax
  mov    %rax,0x8(%rsp)
  movb   $0x5c,(%rdi)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x72,(%rax)
  jmp    L170
  nopw   0x0(%rax,%rax,1)
L29:
  mov    %esi,%edx
  mov    %r13,%rsi
  call   <sprintf@plt>
  addq   $0x4,0x8(%rsp)
  jmp    L170
  nopl   (%rax)
L95:
  lea    0x1(%rdi),%rax
  mov    %rax,0x8(%rsp)
  movb   $0x5c,(%rdi)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x74,(%rax)
  jmp    L170
  nopw   0x0(%rax,%rax,1)
L55:
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x20,(%rax)
  mov    0x8(%rsp),%rax
  jmp    L5
```

tool_calls: name: unpack_data
arguments: tag: D19
data_type: string
name: unpack_data
arguments: tag: D8
data_type: string

tool: D19: \x%02X

tool: D8: \u%04X

assistant: ```c
char *BTSHASP_EmitString(char *t, char *s) {
  int i;
  if ((*(t - 1) == '\"') || (*(t - 1) == '\''))
    *t++ = ' ';
  *t++ = '\"';
  while (*s) {
    i = BTSHASP_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++ = '\\';
    BTSHASP_EmitChar(&t, i);
  }
  *t++ = '\"';
  *t = 0;
  return (t);
}
```