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

```asm
<xml_append_esc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L15
  mov    -0x1c(%rbp),%eax
  jmp    L64
L15:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <pool_state@plt>
  mov    %eax,-0x4(%rbp)
  jmp    L66
L30:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x22,%eax
  cmp    $0x1c,%eax
  ja     L95
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  lea    D5(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D5(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_str@plt>
  mov    %eax,-0x1c(%rbp)
  jmp    L13
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  lea    D52(%rip),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_str@plt>
  mov    %eax,-0x1c(%rbp)
  jmp    L13
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  lea    D17(%rip),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_str@plt>
  mov    %eax,-0x1c(%rbp)
  jmp    L13
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  lea    D58(%rip),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_str@plt>
  mov    %eax,-0x1c(%rbp)
  jmp    L13
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  lea    D51(%rip),%rdx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_str@plt>
  mov    %eax,-0x1c(%rbp)
  jmp    L13
L95:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <pool_append_char@plt>
  mov    %eax,-0x1c(%rbp)
L13:
  cmpl   $0xffffffff,-0x1c(%rbp)
  jne    L56
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pool_restore@plt>
  jmp    L113
L56:
  addq   $0x1,-0x28(%rbp)
L66:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L30
L113:
  mov    -0x1c(%rbp),%eax
L64:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D1
data_type: string
name: read_data
arguments: tag: D52
data_type: string
name: read_data
arguments: tag: D17
data_type: string
name: read_data
arguments: tag: D58
data_type: string
name: read_data
arguments: tag: D51
data_type: string

tool: D1: &apos;

tool: D52: &quot;

tool: D17: &amp;

tool: D58: &lt;

tool: D51: &gt;

assistant: ```c
int xml_append_esc(struct pool *pool, int h, const char *str) {
  int mark;
  if (!str)
    return h;
  mark = pool_state(pool);
  for (; *str; str++) {
    switch (*str) {
    case '\'':
      h = pool_append_str(pool, h, "&apos;");
      break;
    case '"':
      h = pool_append_str(pool, h, "&quot;");
      break;
    case '&':
      h = pool_append_str(pool, h, "&amp;");
      break;
    case '<':
      h = pool_append_str(pool, h, "&lt;");
      break;
    case '>':
      h = pool_append_str(pool, h, "&gt;");
      break;
    default:
      h = pool_append_char(pool, h, *str);
    }
    if (h == (-1)) {
      pool_restore(pool, mark);
      break;
    }
  }
  return h;
}
```