user: Please show me the C implementation that matches the assembly code listed below:

```asm
<escape_predefined_character_entities>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  call   <strdup@plt>
  mov    %rax,%r14
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    (%rax,%rax,2),%edi
  add    %edi,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L23
  movzbl (%r14),%edx
  test   %dl,%dl
  je     L9
  mov    %rax,%rbx
  mov    %r14,%rbp
  lea    D6(%rip),%r13
  lea    D11(%rip),%r15
  jmp    L17
  mov    $0x5,%edx
  lea    D43(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x5,%rbx
L3:
  add    $0x1,%rbp
  movzbl 0x0(%rbp),%edx
  test   %dl,%dl
  je     L64
L17:
  lea    -0x22(%rdx),%eax
  cmp    $0x1c,%al
  ja     L36
  movzbl %al,%eax
  movslq 0x0(%r13,%rax,4),%rax
  add    %r13,%rax
  notrack jmp *%rax
  mov    $0x4,%edx
  lea    D42(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x4,%rbx
  jmp    L3
  mov    $0x4,%edx
  lea    D18(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x4,%rbx
  jmp    L3
  mov    $0x6,%edx
  lea    D0(%rip),%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x6,%rbx
  jmp    L3
  mov    $0x6,%edx
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  add    $0x6,%rbx
  jmp    L3
L36:
  mov    %dl,(%rbx)
  add    $0x1,%rbx
  jmp    L3
L9:
  mov    %rax,%rbx
L64:
  movb   $0x0,(%rbx)
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%esi
  movslq %esi,%rsi
  mov    %r12,%rdi
  call   <realloc@plt>
  mov    %rax,%r12
L23:
  mov    %r12,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: label: D11
type_infered: string
name: disassemble_data
arguments: label: D43
type_infered: string
name: disassemble_data
arguments: label: D42
type_infered: string
name: disassemble_data
arguments: label: D18
type_infered: string
name: disassemble_data
arguments: label: D0
type_infered: string

tool: D11: &quot;

tool: D43: &amp;

tool: D42: &lt;

tool: D18: &gt;

tool: D0: &apos;

assistant: ```c
char *escape_predefined_character_entities(const char *string) {
  const int MAX_ESCAPE_LEN = 6;
  char *s = strdup(string);
  char *result = malloc(MAX_ESCAPE_LEN * strlen(string) * sizeof(char));
  if (NULL == result)
    return NULL;
  char *c;
  char *result_end = result;
  for (c = s; *c != '\0'; c++) {
    switch (*c) {
    case '&':
      strncpy(result_end, "&amp;", 5);
      result_end += 5;
      break;
    case '<':
      strncpy(result_end, "&lt;", 4);
      result_end += 4;
      break;
    case '>':
      strncpy(result_end, "&gt;", 4);
      result_end += 4;
      break;
    case '\'':
      strncpy(result_end, "&apos;", 6);
      result_end += 6;
      break;
    case '"':
      strncpy(result_end, "&quot;", 6);
      result_end += 6;
      break;
    default:
      *result_end = *c;
      result_end++;
      break;
    }
  }
  *result_end = '\0';
  free(s);
  size_t new_length = strlen(result) + 1;
  result = realloc(result, new_length);
  return result;
}
```