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

```asm
<htmlspecialchars>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  test   %rdi,%rdi
  je     L157
  call   <strlen@plt>
  lea    0x1(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  movb   $0x0,(%rax)
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jle    L114
  mov    %r13,%rbx
  lea    -0x1(%rax),%eax
  lea    0x1(%r13,%rax,1),%r13
  lea    D49(%rip),%r15
  lea    D75(%rip),%r14
  jmp    L91
L163:
  lea    D42(%rip),%rdi
  call   <strlen@plt>
  add    %eax,%r12d
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  lea    D42(%rip),%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
L168:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L114
L91:
  mov    %rbx,%rsi
  movzbl (%rbx),%eax
  cmp    $0x26,%al
  je     L163
  cmp    $0x22,%al
  je     L195
  cmp    $0x27,%al
  je     L20
  cmp    $0x3c,%al
  je     L97
  cmp    $0x3e,%al
  je     L120
  mov    $0x1,%edx
  mov    %rbp,%rdi
  call   <strncat@plt>
  jmp    L168
L195:
  mov    %r14,%rdi
  call   <strlen@plt>
  add    %eax,%r12d
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  mov    %r14,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  jmp    L168
L20:
  lea    D31(%rip),%rdi
  call   <strlen@plt>
  add    %eax,%r12d
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  lea    D31(%rip),%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  jmp    L168
L97:
  lea    D56(%rip),%rdi
  call   <strlen@plt>
  add    %eax,%r12d
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  lea    D56(%rip),%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  jmp    L168
L120:
  mov    %r15,%rdi
  call   <strlen@plt>
  add    %eax,%r12d
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  mov    %r15,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  jmp    L168
L157:
  mov    %rdi,%rbp
L114:
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: label: D49
type: string
name: retrieve_data
arguments: label: D75
type: string
name: retrieve_data
arguments: label: D42
type: string
name: retrieve_data
arguments: label: D31
type: string
name: retrieve_data
arguments: label: D56
type: string

tool: D49: &gt;

tool: D75: &quot;

tool: D42: &amp;

tool: D31: &#039;

tool: D56: &lt;

assistant: ```c
char *htmlspecialchars(const char *s) {
  if (s == NULL) {
    return NULL;
  }
  char *t = malloc(strlen(s) + 1);
  if (t == NULL) {
    return NULL;
  }
  t[0] = '\0';
  for (int i = 0, old = strlen(s), new = old; i < old; i++) {
    if (s[i] == '&') {
      const char *entity = "&amp;";
      new += strlen(entity);
      t = realloc(t, new);
      if (t == NULL) {
        return NULL;
      }
      strcat(t, entity);
    } else if (s[i] == '"') {
      const char *entity = "&quot;";
      new += strlen(entity);
      t = realloc(t, new);
      if (t == NULL) {
        return NULL;
      }
      strcat(t, entity);
    } else if (s[i] == '\'') {
      const char *entity = "&#039;";
      new += strlen(entity);
      t = realloc(t, new);
      if (t == NULL) {
        return NULL;
      }
      strcat(t, entity);
    } else if (s[i] == '<') {
      const char *entity = "&lt;";
      new += strlen(entity);
      t = realloc(t, new);
      if (t == NULL) {
        return NULL;
      }
      strcat(t, entity);
    } else if (s[i] == '>') {
      const char *entity = "&gt;";
      new += strlen(entity);
      t = realloc(t, new);
      if (t == NULL) {
        return NULL;
      }
      strcat(t, entity);
    } else {
      strncat(t, s + i, 1);
    }
  }
  return t;
}
```