user: Converte this assembly snippet into its equivalent C code:

```asm
<inet_ntop6>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %rdx,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  movzwl (%rdi),%eax
  rol    $0x8,%ax
  movzwl %ax,%eax
  test   %eax,%eax
  mov    %eax,0x10(%rsp)
  movzwl 0x2(%rdi),%eax
  je     L437
  rol    $0x8,%ax
  add    $0x4,%rdi
  movzwl %ax,%eax
  mov    %eax,0x14(%rsp)
  test   %eax,%eax
  jne    L278
  mov    $0x1,%r14d
  mov    $0x1,%r13d
  jmp    L426
  nopl   0x0(%rax)
L437:
  rol    $0x8,%ax
  add    $0x4,%rdi
  movzwl %ax,%eax
  mov    %eax,0x14(%rsp)
  test   %eax,%eax
  je     L45
  mov    $0x1,%r14d
  xor    %r13d,%r13d
L466:
  movzwl (%rdi),%eax
  add    $0x2,%rdi
  rol    $0x8,%ax
  movzwl %ax,%eax
  mov    %eax,0x18(%rsp)
  test   %eax,%eax
  je     L421
L425:
  movzwl (%rdi),%eax
  add    $0x2,%rdi
  rol    $0x8,%ax
  movzwl %ax,%eax
  mov    %eax,0x1c(%rsp)
  test   %eax,%eax
  je     L261
L346:
  cmpw   $0x0,(%rdi)
  lea    0x2(%rdi),%rdx
  je     L314
L281:
  cmpw   $0x0,(%rdx)
  lea    0x2(%rdx),%rsi
  je     L307
L54:
  cmpw   $0x0,(%rsi)
  lea    0x2(%rsi),%rdx
  jne    L201
  cmpw   $0x0,(%rdx)
  mov    $0x1,%eax
  mov    $0x6,%ecx
  je     L128
L267:
  cmp    $0xffffffff,%r13d
  je     L477
  cmp    %r14d,%eax
  setg   %dl
  test   %dl,%dl
  cmove  %r13d,%ecx
  cmove  %r14d,%eax
L477:
  mov    %eax,%r14d
  mov    %ecx,%r13d
L111:
  cmp    $0x1,%r14d
  mov    $0xffffffff,%eax
  cmovle %eax,%r13d
L420:
  lea    0x20(%rsp),%rbp
  lea    D3(%rip),%r15
  xor    %r12d,%r12d
  mov    %rbp,%rbx
  jmp    L86
  nop
L313:
  test   %r12d,%r12d
  je     L479
  movb   $0x3a,(%rbx)
  add    $0x1,%rbx
L479:
  movslq %r12d,%rax
  mov    %rbx,%rdi
  mov    %r15,%rdx
  add    $0x1,%r12d
  mov    0x10(%rsp,%rax,4),%ecx
  mov    %ebp,%eax
  sub    %ebx,%eax
  lea    0x2e(%rax),%esi
  call   <snprintf@plt>
  cltq
  add    %rax,%rbx
  cmp    $0x3,%r12d
  jg     L378
L86:
  cmp    %r12d,%r13d
  jne    L313
  lea    0x0(%r13,%r14,1),%r12d
  movb   $0x3a,(%rbx)
  add    $0x1,%rbx
  cmp    $0x3,%r12d
  jle    L86
L378:
  cmp    $0xffffffff,%r13d
  je     L234
  lea    0x0(%r13,%r14,1),%r9d
  cmp    $0x4,%r9d
  jne    L234
  movb   $0x3a,(%rbx)
  add    $0x1,%rbx
L234:
  movb   $0x0,(%rbx)
  add    $0x1,%rbx
  xor    %eax,%eax
  sub    %rbp,%rbx
  cmp    (%rsp),%rbx
  ja     L191
  mov    0x8(%rsp),%rbx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
L191:
  mov    0x58(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L110
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L45:
  mov    $0x2,%r14d
  xor    %r13d,%r13d
L426:
  movzwl (%rdi),%eax
  add    $0x2,%rdi
  rol    $0x8,%ax
  movzwl %ax,%eax
  mov    %eax,0x18(%rsp)
  test   %eax,%eax
  jne    L425
  lea    0x1(%r14),%eax
  mov    %r13d,%ecx
  xor    %r14d,%r14d
  mov    $0xffffffff,%r13d
L2:
  movzwl (%rdi),%edx
  add    $0x2,%rdi
  rol    $0x8,%dx
  movzwl %dx,%edx
  mov    %edx,0x1c(%rsp)
  test   %edx,%edx
  jne    L195
  add    $0x1,%eax
L430:
  cmpw   $0x0,(%rdi)
  lea    0x2(%rdi),%rdx
  jne    L130
  add    $0x1,%eax
L321:
  cmpw   $0x0,(%rdx)
  lea    0x2(%rdx),%rsi
  jne    L388
  add    $0x1,%eax
L473:
  cmpw   $0x0,(%rsi)
  lea    0x2(%rsi),%rdx
  jne    L13
  add    $0x1,%eax
  cmpw   $0x0,(%rdx)
  jne    L267
L128:
  add    $0x1,%eax
  cmp    %r14d,%eax
  jg     L477
  cmp    $0xffffffff,%r13d
  je     L477
  jmp    L111
  nopl   0x0(%rax)
L278:
  xor    %r14d,%r14d
  mov    $0xffffffff,%r13d
  jmp    L466
  cs nopw 0x0(%rax,%rax,1)
L13:
  cmp    %r14d,%eax
  jg     L475
  cmp    $0xffffffff,%r13d
  jne    L201
L475:
  mov    %eax,%r14d
  mov    %ecx,%r13d
L201:
  cmpw   $0x0,(%rdx)
  jne    L79
  cmp    $0xffffffff,%r13d
  je     L217
  test   %r14d,%r14d
  jg     L111
L217:
  mov    $0x1,%r14d
  mov    $0xffffffff,%r13d
  jmp    L420
  nopw   0x0(%rax,%rax,1)
L79:
  cmp    $0xffffffff,%r13d
  je     L420
  jmp    L111
  nop
L388:
  cmp    %r14d,%eax
  jg     L135
  cmp    $0xffffffff,%r13d
  jne    L54
L135:
  mov    %eax,%r14d
  mov    %ecx,%r13d
  jmp    L54
  nopw   0x0(%rax,%rax,1)
L130:
  cmp    %r14d,%eax
  jg     L435
  cmp    $0xffffffff,%r13d
  jne    L281
L435:
  cmpw   $0x0,(%rdx)
  mov    %eax,%r14d
  lea    0x2(%rdx),%rsi
  mov    %ecx,%r13d
  jne    L54
L307:
  mov    $0x1,%eax
  mov    $0x5,%ecx
  jmp    L473
  nopw   0x0(%rax,%rax,1)
L195:
  cmp    %eax,%r14d
  jl     L266
  cmp    $0xffffffff,%r13d
  jne    L346
L266:
  cmpw   $0x0,(%rdi)
  mov    %eax,%r14d
  lea    0x2(%rdi),%rdx
  mov    %ecx,%r13d
  jne    L281
L314:
  mov    $0x1,%eax
  mov    $0x4,%ecx
  jmp    L321
  nopw   0x0(%rax,%rax,1)
L261:
  mov    $0x1,%eax
  mov    $0x3,%ecx
  jmp    L430
  nop
L421:
  mov    $0x1,%eax
  mov    $0x2,%ecx
  jmp    L2
L110:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D3
datatype: string

tool: D3: %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);
}
```