user: 请将以下的汇编代码转换成C语言代码:

```asm
<BTSHASP_EmitString>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rax
  mov    %rdi,0x8(%rsp)
  mov    %rsi,(%rsp)
  movzbl -0x1(%rdi),%edx
  cmp    $0x22,%dl
  je     L158
  cmp    $0x27,%dl
  je     L158
L148:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x22,(%rax)
  mov    (%rsp),%rax
  cmpb   $0x0,(%rax)
  je     L222
  mov    %rsp,%rbx
  lea    0x8(%rsp),%rbp
  lea    D15(%rip),%r13
  lea    D1(%rip),%r12
  jmp    L11
L158:
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x20,(%rax)
  jmp    L148
L145:
  mov    %esi,%edx
  mov    %r12,%rsi
  mov    0x8(%rsp),%rdi
  call   <sprintf@plt>
  addq   $0x6,0x8(%rsp)
  jmp    L108
L55:
  cmp    $0x1b,%esi
  jne    L6
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x65,(%rax)
  jmp    L108
L40:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x72,(%rax)
  jmp    L108
L126:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x74,(%rax)
  jmp    L108
L6:
  mov    %esi,%edx
  mov    %r13,%rsi
  mov    0x8(%rsp),%rdi
  call   <sprintf@plt>
  addq   $0x4,0x8(%rsp)
  jmp    L108
L23:
  cmp    $0x22,%esi
  je     L197
  cmp    $0x27,%esi
  jne    L227
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  jmp    L228
L197:
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
L228:
  mov    %rbp,%rdi
  call   <BTSHASP_EmitChar@plt>
L108:
  mov    (%rsp),%rax
  cmpb   $0x0,(%rax)
  je     L222
L11:
  mov    %rbx,%rdi
  call   <BTSHASP_ParseChar@plt>
  mov    %eax,%esi
  lea    -0x20(%rax),%eax
  cmp    $0x5d,%eax
  jbe    L23
  cmp    $0xff,%esi
  jg     L145
  cmp    $0xd,%esi
  je     L40
  jg     L55
  cmp    $0x9,%esi
  je     L126
  cmp    $0xa,%esi
  jne    L6
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x6e,(%rax)
  jmp    L108
L227:
  cmp    $0x5c,%esi
  jne    L228
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,0x8(%rsp)
  movb   $0x5c,(%rax)
  jmp    L228
L222:
  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
```

tool_calls: name: read_data
arguments: data_tag: D15
datatype: string
name: read_data
arguments: data_tag: D1
datatype: string

tool: D15: \x%02X

tool: D1: \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);
}
```