user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<getLocalHostIp>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x4a0,%rsp
  mov    %rdi,-0x498(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x478(%rbp)
  lea    -0x478(%rbp),%rax
  mov    %rax,%rdi
  call   <getifaddrs@plt>
  test   %rax,%rax
  je     L94
  mov    $0xffffffff,%eax
  jmp    L59
L94:
  movq   $0x0,-0x460(%rbp)
  movq   $0x0,-0x458(%rbp)
  movl   $0x0,-0x484(%rbp)
  movl   $0x0,-0x480(%rbp)
  mov    -0x478(%rbp),%rax
  mov    %rax,-0x470(%rbp)
  jmp    L36
L27:
  mov    -0x470(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    (%rax),%rdx
  mov    D25(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L177
  mov    -0x470(%rbp),%rax
  mov    (%rax),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L101
  mov    -0x470(%rbp),%rax
  mov    (%rax),%eax
  and    $0x8,%eax
  test   %eax,%eax
  jne    L104
  mov    -0x470(%rbp),%rax
  mov    0x8(%rax),%rax
  lea    -0x410(%rbp),%rdx
  sub    $0x8,%rsp
  push   $0x2
  mov    $0x0,%r9d
  mov    $0x0,%r8d
  mov    $0x401,%ecx
  mov    $0x10,%esi
  mov    %rax,%rdi
  call   <getnameinfo@plt>
  add    $0x10,%rsp
  mov    -0x470(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x468(%rbp)
  mov    D25(%rip),%rax
  mov    (%rax),%rax
  lea    -0x450(%rbp),%rdx
  mov    -0x468(%rbp),%rsi
  mov    $0x10,%ecx
  mov    %rax,%rdi
  call   <inet_ntop@plt>
  test   %rax,%rax
  je     L148
  lea    -0x410(%rbp),%rdx
  lea    -0x450(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  mov    %eax,-0x47c(%rbp)
  mov    -0x460(%rbp),%rax
  test   %rax,%rax
  jne    L150
  mov    -0x468(%rbp),%rax
  mov    0x8(%rax),%rdx
  mov    (%rax),%rax
  mov    %rax,-0x460(%rbp)
  mov    %rdx,-0x458(%rbp)
  mov    -0x47c(%rbp),%edx
  lea    -0x460(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <ipAddressLevel@plt>
  mov    %eax,-0x484(%rbp)
  jmp    L177
L150:
  mov    -0x47c(%rbp),%edx
  mov    -0x468(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <ipAddressLevel@plt>
  mov    %eax,-0x480(%rbp)
  mov    -0x480(%rbp),%eax
  cmp    -0x484(%rbp),%eax
  jle    L177
  mov    -0x468(%rbp),%rax
  mov    0x8(%rax),%rdx
  mov    (%rax),%rax
  mov    %rax,-0x460(%rbp)
  mov    %rdx,-0x458(%rbp)
  mov    -0x480(%rbp),%eax
  mov    %eax,-0x484(%rbp)
  jmp    L177
L101:
  nop
  jmp    L177
L104:
  nop
  jmp    L177
L148:
  nop
L177:
  mov    -0x470(%rbp),%rax
  mov    0x10(%rax),%rax
  mov    %rax,-0x470(%rbp)
L36:
  cmpq   $0x0,-0x470(%rbp)
  jne    L27
  mov    -0x478(%rbp),%rax
  mov    %rax,%rdi
  call   <freeifaddrs@plt>
  mov    -0x460(%rbp),%rax
  test   %rax,%rax
  jne    L88
  mov    $0xffffffff,%eax
  jmp    L59
L88:
  mov    D25(%rip),%rax
  mov    (%rax),%rax
  mov    -0x498(%rbp),%rdx
  lea    -0x460(%rbp),%rsi
  mov    $0x10,%ecx
  mov    %rax,%rdi
  call   <inet_ntop@plt>
  test   %rax,%rax
  jne    L87
  mov    $0xffffffff,%eax
  jmp    L59
L87:
  mov    $0x0,%eax
L59:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L144
  call   <__stack_chk_fail@plt>
L144:
  leave
  ret
```

assistant: ```c
int getLocalHostIp(char *ip) {
  struct ifaddrs *ifaddrs = NULL;
  if (getifaddrs(&ifaddrs)) {
    return -1;
  }
  struct in_addr res = {0};
  int res_level = 0, tmp_level = 0;
  char ipBuf[64];
  struct ifaddrs *ifa;
  for (ifa = ifaddrs; NULL != ifa; ifa = ifa->ifa_next) {
    char hostname[1025];
    if (ifa->ifa_addr->sa_family == AF_INET) {
      if (!(ifa->ifa_flags & 0x1)) {
        continue;
      }
      if (ifa->ifa_flags & 0x8) {
        continue;
      }
      getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), hostname, 1025, NULL, 0, 0x00000002);
      struct in_addr *addr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
      if (NULL == inet_ntop(AF_INET, addr, ipBuf, 16)) {
        continue;
      }
      int offset = strcmp(ipBuf, hostname) == 0 ? 0 : 1;
      if (0 == res.s_addr) {
        res = *addr;
        res_level = ipAddressLevel(&res, offset);
      } else if (res_level < (tmp_level = ipAddressLevel(addr, offset))) {
        res = *addr;
        res_level = tmp_level;
      }
    }
  }
  freeifaddrs(ifaddrs);
  if (0 == res.s_addr) {
    return -1;
  } else {
    return NULL == inet_ntop(AF_INET, &res, ip, 16) ? -1 : 0;
  }
}
```