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

```asm
<inet_ntop6>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,%r14
  mov    %rsi,0x8(%rsp)
  mov    %rdx,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  mov    $0x0,%edi
  mov    $0xffffffff,%esi
  mov    $0x0,%r13d
  mov    $0xffffffff,%r12d
  mov    $0xffffffff,%r9d
  jmp    L264
L23:
  cmp    $0xffffffff,%esi
  je     L184
  cmp    %edi,%r13d
  jl     L175
  cmp    $0xffffffff,%r12d
  jne    L64
L175:
  mov    %edi,%r13d
  mov    %esi,%r12d
  mov    %r9d,%esi
L184:
  add    $0x1,%rax
  cmp    $0x8,%rax
  je     L98
L264:
  movzbl (%r14,%rax,2),%ecx
  shl    $0x8,%ecx
  movzbl 0x1(%r14,%rax,2),%edx
  or     %ecx,%edx
  mov    %edx,0x10(%rsp,%rax,4)
  jne    L23
  add    $0x1,%edi
  cmp    $0xffffffff,%esi
  jne    L184
  mov    %eax,%esi
  mov    $0x1,%edi
  jmp    L184
L64:
  mov    %r9d,%esi
  jmp    L184
L98:
  cmp    $0xffffffff,%esi
  je     L100
  cmp    %edi,%r13d
  jl     L105
  cmp    $0xffffffff,%r12d
  jne    L100
L105:
  mov    %edi,%r13d
  mov    %esi,%r12d
L100:
  cmp    $0x1,%r13d
  mov    $0xffffffff,%eax
  cmovle %eax,%r12d
  mov    $0x0,%ebx
  lea    0x20(%rsp),%rbp
  jmp    L18
L15:
  movb   $0x3a,0x0(%rbp)
  add    %r13d,%ebx
  lea    0x1(%rbp),%rbp
  jmp    L262
L72:
  mov    %r15,%rbp
L45:
  movslq %ebx,%rax
  mov    0x10(%rsp,%rax,4),%ecx
  lea    0x20(%rsp),%rax
  sub    %ebp,%eax
  lea    0x2e(%rax),%esi
  lea    D6(%rip),%rdx
  mov    %rbp,%rdi
  call   <snprintf@plt>
  cltq
  add    %rax,%rbp
  add    $0x1,%ebx
L262:
  cmp    $0x3,%ebx
  jg     L93
L18:
  cmp    %ebx,%r12d
  je     L15
  test   %ebx,%ebx
  je     L45
  lea    0x1(%rbp),%r15
  movb   $0x3a,0x0(%rbp)
  test   %r12d,%r12d
  jne    L72
  cmp    $0x6,%ebx
  jne    L72
  cmp    $0x6,%r13d
  je     L267
  mov    %r15,%rbp
  cmp    $0x5,%r13d
  jne    L45
  cmpl   $0xffff,0x24(%rsp)
  jne    L45
L267:
  lea    0x20(%rsp),%rax
  sub    %r15d,%eax
  lea    0x2e(%rax),%edx
  lea    0xc(%r14),%rdi
  mov    %r15,%rsi
  call   <inet_ntop4@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  test   %edx,%edx
  je     L3
  mov    %r15,%rdi
  call   <strlen@plt>
  movslq %eax,%rbp
  add    %r15,%rbp
  jmp    L39
L93:
  cmp    $0xffffffff,%r12d
  je     L236
L39:
  add    %r13d,%r12d
  cmp    $0x4,%r12d
  je     L151
L236:
  movb   $0x0,0x0(%rbp)
  lea    0x60(%rsp),%rax
  sub    %rax,%rbp
  lea    0x41(%rbp),%rdx
  mov    $0x0,%eax
  cmp    (%rsp),%rdx
  ja     L3
  lea    0x20(%rsp),%rsi
  mov    0x8(%rsp),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
L3:
  mov    0x58(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L74
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L151:
  movb   $0x3a,0x0(%rbp)
  lea    0x1(%rbp),%rbp
  jmp    L236
L74:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D6
type: string

tool: D6: %x

assistant: ```c
const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) {
  char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
  struct {
    int base, len;
  } best = {-1, 0}, cur = {-1, 0};
  unsigned int words[16 / sizeof(int16_t)];
  int i;
  const unsigned char *next_src, *src_end;
  unsigned int *next_dest;
  next_src = src;
  src_end = src + 16;
  next_dest = words;
  i = 0;
  do {
    unsigned int next_word = (unsigned int)*next_src++;
    next_word <<= 8;
    next_word |= (unsigned int)*next_src++;
    *next_dest++ = next_word;
    if (next_word == 0) {
      if (cur.base == -1) {
        cur.base = i;
        cur.len = 1;
      } else {
        cur.len++;
      }
    } else {
      if (cur.base != -1) {
        if (best.base == -1 || cur.len > best.len) {
          best = cur;
        }
        cur.base = -1;
      }
    }
    i++;
  } while (next_src < src_end);
  if (cur.base != -1) {
    if (best.base == -1 || cur.len > best.len) {
      best = cur;
    }
  }
  if (best.base != -1 && best.len < 2) {
    best.base = -1;
  }
  tp = tmp;
  for (i = 0; i < ((int)(16 / sizeof(int16_t)));) {
    if (i == best.base) {
      *tp++ = ':';
      i += best.len;
      continue;
    }
    if (i != 0) {
      *tp++ = ':';
    }
    if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
      if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp))) {
        return (NULL);
      }
      tp += strlen(tp);
      break;
    }
    tp += snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
    i++;
  }
  if (best.base != -1 && (best.base + best.len) == (16 / sizeof(int16_t))) {
    *tp++ = ':';
  }
  *tp++ = '\0';
  if ((size_t)(tp - tmp) > size) {
    return (NULL);
  }
  strcpy(dst, tmp);
  return (dst);
}
```