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

```asm
<ll2escaped>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpl   $0x0,-0x30(%rbp)
  jg     L126
  lea    D20(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <L_DEBUG@plt>
  mov    $0xffffffff,%eax
  jmp    L13
L126:
  mov    -0x2c(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x2c(%rbp)
  test   %eax,%eax
  jne    L123
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <L_DEBUG@plt>
  mov    $0xfffffffe,%eax
  jmp    L13
L123:
  mov    -0x28(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L32
  mov    -0x2c(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %edx,%eax
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jns    L75
  mov    -0x2c(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <L_DEBUG@plt>
  mov    $0xfffffffe,%eax
  jmp    L13
L75:
  mov    -0x30(%rbp),%ecx
  mov    -0x38(%rbp),%rdx
  mov    -0x8(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <l2escaped@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jns    L64
  mov    -0x14(%rbp),%eax
  jmp    L13
L64:
  mov    -0x8(%rbp),%rax
  shl    $0x3,%rax
  add    %rax,-0x28(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  add    %rax,-0x38(%rbp)
  mov    -0x14(%rbp),%eax
  sub    %eax,-0x30(%rbp)
L32:
  cmpq   $0x0,-0x8(%rbp)
  je     L46
  mov    -0x30(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x30(%rbp)
  test   %eax,%eax
  jne    L5
  mov    $0x2e,%esi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <L_DEBUG@plt>
  mov    $0xffffffff,%eax
  jmp    L13
L5:
  mov    -0x38(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x38(%rbp)
  movb   $0x2e,(%rax)
  jmp    L126
L46:
  nop
  mov    -0x30(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x30(%rbp)
  test   %eax,%eax
  jne    L12
  mov    $0x0,%esi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <L_DEBUG@plt>
  mov    $0xffffffff,%eax
  jmp    L13
L12:
  mov    -0x38(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x38(%rbp)
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  sub    -0x10(%rbp),%rax
  sar    $0x3,%rax
L13:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D20
datatype: string
name: unpack_data
arguments: data_tag: D48
datatype: string
name: unpack_data
arguments: data_tag: D4
datatype: string
name: unpack_data
arguments: data_tag: D21
datatype: string

tool: D20: no output string available

tool: D48: out of input string (before last null label)

tool: D4: %d/%d bytes of label body missing

tool: D21: out of space in escaped pushing %d

assistant: ```c
int ll2escaped(const uint8_t *ll, int ll_left, char *escaped, int escaped_left) {
  const uint8_t *oll = ll;
  int r;
  if (escaped_left <= 0) {
    L_DEBUG("no output string available");
    return -1;
  }
  while (1) {
    if (!ll_left--) {
      L_DEBUG("out of input string (before last null label)");
      return -2;
    }
    uint8_t c = *(ll++);
    if (c) {
      ll_left -= c;
      if (ll_left < 0) {
        L_DEBUG("%d/%d bytes of label body missing", -ll_left, c);
        return -2;
      }
      r = l2escaped(ll, c, escaped, escaped_left);
      if (r < 0)
        return r;
      ll += c;
      escaped += r;
      escaped_left -= r;
    }
    if (!c)
      break;
    do {
      if (!escaped_left--) {
        L_DEBUG("out of space in escaped pushing %d", '.');
        return -1;
      }
      *(escaped++) = '.';
    } while (0);
  }
  do {
    if (!escaped_left--) {
      L_DEBUG("out of space in escaped pushing %d", 0);
      return -1;
    }
    *(escaped++) = 0;
  } while (0);
  return ll - oll;
}
```