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

```asm
<c_escape>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%edi
  test   %dil,%dil
  je     L74
  mov    %rbx,%r14
  mov    $0x1,%r13d
  jmp    L124
  nopw   0x0(%rax,%rax,1)
L193:
  add    $0x4,%r13
L121:
  movsbl 0x1(%r14),%edi
  add    $0x1,%r14
  test   %dil,%dil
  je     L84
L124:
  call   <iscntrl@plt>
  test   %rax,%rax
  jne    L193
  movsbl (%r14),%edi
  call   <isascii@plt>
  test   %eax,%eax
  je     L193
  movzbl (%r14),%eax
  cmp    $0x22,%al
  je     L190
  cmp    $0x5c,%al
  je     L190
  movsbl 0x1(%r14),%edi
  add    $0x1,%r14
  add    $0x1,%r13
  test   %dil,%dil
  jne    L124
  nopw   0x0(%rax,%rax,1)
L84:
  cmp    %rbp,%r13
  ja     L83
  movsbl (%rbx),%edi
  test   %dil,%dil
  je     L39
  lea    D7(%rip),%r14
  jmp    L35
  xchg   %ax,%ax
L9:
  movsbl (%rbx),%edi
  call   <isascii@plt>
  test   %eax,%eax
  je     L20
  movsbl (%rbx),%ecx
  cmp    $0x22,%cl
  je     L105
  cmp    $0x5c,%cl
  je     L105
  mov    %cl,(%r12)
  mov    $0x1,%r15d
  nopl   0x0(%rax,%rax,1)
L87:
  xor    %edi,%edi
  cmp    %rbp,%r15
  setb   %dil
  add    $0x1,%rbx
  add    %r15,%r12
  sub    %r15,%rbp
  call   <assert@plt>
  movsbl (%rbx),%edi
  test   %dil,%dil
  je     L39
L35:
  call   <iscntrl@plt>
  test   %rax,%rax
  je     L9
L20:
  movsbl (%rbx),%ecx
  mov    %r12,%rdi
  mov    %r14,%rdx
  mov    %rbp,%rsi
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x4,%rax
  mov    %rax,%r15
  sete   %dil
  call   <assert@plt>
  jmp    L87
  nop
L74:
  mov    $0x1,%r13d
  test   %rdx,%rdx
  je     L83
  nopl   0x0(%rax,%rax,1)
L39:
  xor    %edi,%edi
  test   %rbp,%rbp
  setne  %dil
  call   <assert@plt>
  movb   $0x0,(%r12)
L83:
  add    $0x8,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L190:
  add    $0x2,%r13
  jmp    L121
  nopl   0x0(%rax)
L105:
  mov    %r12,%rdi
  lea    D4(%rip),%rdx
  mov    %rbp,%rsi
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x2,%rax
  mov    %rax,%r15
  sete   %dil
  call   <assert@plt>
  jmp    L87
```

tool_calls: name: unpack_data
arguments: data_label: D7
datatype: string
name: unpack_data
arguments: data_label: D4
datatype: string

tool: D7: \x%02hhx

tool: D4: \%c

assistant: ```c
size_t c_escape(const char *in, char *out, size_t len) {
  size_t r = 1, s;
  const char *c;
  for (c = in; *c != '\0'; c++) {
    if (iscntrl(*c) || !isascii(*c))
      r += 4;
    else {
      if (*c == '\"' || *c == '\\')
        r += 2;
      else
        r++;
    }
  }
  if (r > len)
    return r;
  for (c = in; *c != '\0'; c++) {
    if (iscntrl(*c) || !isascii(*c)) {
      s = snprintf(out, len, "\\x%02hhx", *c);
      assert(s == 4);
    } else {
      if (*c == '\"' || *c == '\\') {
        s = snprintf(out, len, "\\%c", *c);
        assert(s == 2);
      } else {
        *out = *c;
        s = 1;
      }
    }
    assert(s < len);
    out += s;
    len -= s;
  }
  assert(len > 0);
  *out = '\0';
  return r;
}
```