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

```asm
<json_str>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdx,(%rsp)
  call   <strlen@plt>
  movb   $0x22,(%r12)
  test   %rax,%rax
  je     L79
  mov    (%rsp),%r8
  mov    %rax,%r14
  mov    $0x1,%ebp
  xor    %ebx,%ebx
  lea    D19(%rip),%rsi
  lea    D13(%rip),%rcx
  movabs $0x400000020000021,%r15
  lea    -0x2(%r8),%r9
  jmp    L40
  nopl   0x0(%rax,%rax,1)
L146:
  bt     %rdx,%r15
  jb     L141
L103:
  cmp    %rbp,%r9
  jb     L35
L141:
  mov    %al,(%r12,%rbp,1)
  add    $0x1,%rbp
L12:
  add    $0x1,%rbx
  cmp    %rbx,%r14
  je     L45
L40:
  movzbl 0x0(%r13,%rbx,1),%eax
  test   %al,%al
  je     L141
  lea    -0x22(%rax),%edx
  cmp    $0x3a,%dl
  jbe    L146
  lea    -0x20(%rax),%edx
  cmp    $0x5e,%dl
  jbe    L103
  lea    -0x3(%r8),%rax
  cmp    %rbp,%rax
  jb     L35
  movb   $0x5c,(%r12,%rbp,1)
  movzbl 0x0(%r13,%rbx,1),%eax
  lea    0x1(%rbp),%rdx
  sub    $0x8,%eax
  cmp    $0x5,%al
  ja     L39
  movzbl %al,%eax
  movslq (%rcx,%rax,4),%rax
  add    %rcx,%rax
  notrack jmp *%rax
  xchg   %ax,%ax
  add    $0x1,%rbx
  movb   $0x72,(%r12,%rdx,1)
  add    $0x2,%rbp
  cmp    %rbx,%r14
  jne    L40
  nopw   0x0(%rax,%rax,1)
L45:
  lea    0x1(%rbp),%rax
L105:
  movb   $0x22,(%r12,%rbp,1)
  movb   $0x0,(%r12,%rax,1)
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
  movb   $0x66,(%r12,%rdx,1)
  add    $0x2,%rbp
  jmp    L12
  xchg   %ax,%ax
  movb   $0x6e,(%r12,%rdx,1)
  add    $0x2,%rbp
  jmp    L12
  xchg   %ax,%ax
  movb   $0x74,(%r12,%rdx,1)
  add    $0x2,%rbp
  jmp    L12
  xchg   %ax,%ax
  movb   $0x62,(%r12,%rdx,1)
  add    $0x2,%rbp
  jmp    L12
  xchg   %ax,%ax
L39:
  lea    -0x4(%r8),%rax
  mov    %r9,0x8(%rsp)
  mov    %r8,(%rsp)
  cmp    %rdx,%rax
  jb     L35
  movsbl (%r12,%rdx,1),%edx
  lea    (%r12,%rbx,1),%rdi
  add    $0x2,%rbp
  call   <sprintf@plt>
  mov    (%rsp),%r8
  mov    0x8(%rsp),%r9
  lea    D19(%rip),%rsi
  lea    D13(%rip),%rcx
  jmp    L12
L35:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L79:
  mov    $0x2,%eax
  mov    $0x1,%ebp
  jmp    L105
```

tool_calls: name: retrieve_data
arguments: data_label: D19
data_type: string

tool: D19: u%04x

assistant: ```c
const char *json_str(const char *str, char *buf, size_t len) {
  size_t ix, bufix = 0;
  size_t sl;
  sl = strlen(str);
  buf[bufix++] = '"';
  for (ix = 0; ix < sl; ++ix) {
    switch (str[ix]) {
    case '\\':
    case '\0':
    case '\?':
    case '\"':
    case '\'':
      buf[bufix++] = str[ix];
      break;
    default:
      if (str[ix] < ' ' || str[ix] > '\x7e') {
        if (bufix > len - 3)
          return NULL;
        buf[bufix++] = '\\';
        switch (str[ix]) {
        case '\b':
          buf[bufix++] = 'b';
          break;
        case '\f':
          buf[bufix++] = 'f';
          break;
        case '\n':
          buf[bufix++] = 'n';
          break;
        case '\r':
          buf[bufix++] = 'r';
          break;
        case '\t':
          buf[bufix++] = 't';
          break;
        default:
          if (bufix > len - 4)
            return NULL;
          sprintf(buf + ix, "u%04x", (unsigned int)buf[bufix++]);
        }
      } else {
        if (bufix > len - 2)
          return NULL;
        buf[bufix++] = str[ix];
      }
    }
  }
  buf[bufix++] = '\"';
  buf[bufix] = '\0';
  return buf;
}
```