user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<scan_ip6>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x3c(%rbp)
  movl   $0x0,-0x38(%rbp)
  movl   $0x0,-0x34(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L169
L138:
  mov    -0x40(%rbp),%edx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  addl   $0x1,-0x40(%rbp)
L169:
  cmpl   $0xf,-0x40(%rbp)
  jbe    L138
L239:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3a,%al
  jne    L190
  addl   $0x1,-0x3c(%rbp)
  mov    -0x48(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x3a,%al
  jne    L151
  addq   $0x2,-0x48(%rbp)
  addl   $0x1,-0x3c(%rbp)
  jmp    L244
L151:
  addq   $0x1,-0x48(%rbp)
L190:
  lea    -0x30(%rbp),%rcx
  mov    -0x48(%rbp),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strtoul@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x48(%rbp),%rax
  mov    %eax,-0x40(%rbp)
  cmpl   $0x0,-0x40(%rbp)
  jne    L38
  mov    $0x0,%eax
  jmp    L275
L38:
  cmpl   $0xc,-0x38(%rbp)
  jne    L88
  mov    -0x40(%rbp),%edx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L88
  mov    -0x50(%rbp),%rax
  lea    0xc(%rax),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <inet_aton@plt>
  test   %rax,%rax
  je     L250
  mov    -0x40(%rbp),%edx
  mov    -0x3c(%rbp),%eax
  add    %edx,%eax
  jmp    L275
L250:
  mov    $0x0,%eax
  jmp    L275
L88:
  mov    -0x28(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rcx
  mov    -0x38(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x38(%rbp)
  mov    %eax,%edx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x38(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x38(%rbp)
  mov    %eax,%edx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%rdx
  mov    %dl,(%rax)
  mov    -0x40(%rbp),%eax
  add    %rax,-0x48(%rbp)
  mov    -0x40(%rbp),%eax
  add    %eax,-0x3c(%rbp)
  cmpl   $0x10,-0x38(%rbp)
  jne    L239
  mov    -0x3c(%rbp),%eax
  jmp    L275
L244:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3a,%al
  jne    L294
  cmpl   $0x0,-0x34(%rbp)
  je     L106
  addq   $0x1,-0x48(%rbp)
  addl   $0x1,-0x3c(%rbp)
  jmp    L290
L294:
  cmpl   $0x0,-0x34(%rbp)
  jne    L28
L290:
  lea    -0x30(%rbp),%rcx
  mov    -0x48(%rbp),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x48(%rbp),%rax
  mov    %eax,-0x40(%rbp)
  cmpl   $0x0,-0x40(%rbp)
  jne    L44
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L227
  subl   $0x1,-0x3c(%rbp)
  jmp    L227
L44:
  mov    -0x34(%rbp),%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cmp    $0xc,%eax
  ja     L118
  mov    -0x40(%rbp),%edx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L118
  mov    -0x34(%rbp),%eax
  lea    -0x20(%rbp),%rdx
  add    %rax,%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <inet_aton@plt>
  test   %rax,%rax
  je     L292
  addl   $0x4,-0x34(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %eax,-0x3c(%rbp)
  jmp    L277
L292:
  mov    $0xc,%eax
  sub    -0x34(%rbp),%eax
  mov    %eax,-0x38(%rbp)
L118:
  mov    -0x28(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rcx
  mov    -0x34(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x34(%rbp)
  mov    %ecx,%edx
  mov    %eax,%eax
  mov    %dl,-0x20(%rbp,%rax,1)
  mov    -0x34(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x34(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    %eax,%eax
  mov    %dl,-0x20(%rbp,%rax,1)
  mov    -0x40(%rbp),%eax
  add    %rax,-0x48(%rbp)
  mov    -0x40(%rbp),%eax
  add    %eax,-0x3c(%rbp)
  mov    -0x38(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cmp    $0x10,%eax
  je     L209
  jmp    L244
L106:
  nop
  jmp    L277
L28:
  nop
  jmp    L277
L227:
  nop
  jmp    L277
L209:
  nop
L277:
  movl   $0x0,-0x40(%rbp)
  jmp    L191
L57:
  mov    -0x40(%rbp),%eax
  sub    -0x34(%rbp),%eax
  add    $0x10,%eax
  mov    %eax,%edx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x40(%rbp),%eax
  movzbl -0x20(%rbp,%rax,1),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x40(%rbp)
L191:
  mov    -0x40(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jb     L57
  mov    -0x3c(%rbp),%eax
L275:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L320
  call   <__stack_chk_fail@plt>
L320:
  leave
  ret
```

assistant: ```c
unsigned int scan_ip6(const char *s, char ip[16]) {
  unsigned int i;
  unsigned int len = 0;
  unsigned long u;
  char suffix[16];
  unsigned int prefixlen = 0;
  unsigned int suffixlen = 0;
  for (i = 0; i < 16; i++)
    ip[i] = 0;
  for (;;) {
    if (*s == ':') {
      len++;
      if (s[1] == ':') {
        s += 2;
        len++;
        break;
      }
      s++;
    }
    {
      char *tmp;
      u = strtoul(s, &tmp, 16);
      i = tmp - s;
    }
    if (!i)
      return 0;
    if (prefixlen == 12 && s[i] == '.') {
      if (inet_aton(s, (struct in_addr *)(ip + 12)))
        return i + len;
      else
        return 0;
    }
    ip[prefixlen++] = (u >> 8);
    ip[prefixlen++] = (u & 255);
    s += i;
    len += i;
    if (prefixlen == 16)
      return len;
  }
  for (;;) {
    if (*s == ':') {
      if (suffixlen == 0)
        break;
      s++;
      len++;
    } else if (suffixlen != 0)
      break;
    {
      char *tmp;
      u = strtol(s, &tmp, 16);
      i = tmp - s;
    }
    if (!i) {
      if (*s)
        len--;
      break;
    }
    if (suffixlen + prefixlen <= 12 && s[i] == '.') {
      if (inet_aton(s, (struct in_addr *)(suffix + suffixlen))) {
        suffixlen += 4;
        len += strlen(s);
        break;
      } else
        prefixlen = 12 - suffixlen;
    }
    suffix[suffixlen++] = (u >> 8);
    suffix[suffixlen++] = (u & 255);
    s += i;
    len += i;
    if (prefixlen + suffixlen == 16)
      break;
  }
  for (i = 0; i < suffixlen; i++)
    ip[16 - suffixlen + i] = suffix[i];
  return len;
}
```