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

```asm
<getLocalHostIp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x488,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x478(%rsp)
  xor    %eax,%eax
  lea    0x18(%rsp),%rdi
  movq   $0x0,0x18(%rsp)
  call   <getifaddrs@plt>
  test   %rax,%rax
  jne    L73
  mov    0x18(%rsp),%rbp
  pxor   %xmm0,%xmm0
  movaps %xmm0,0x20(%rsp)
  test   %rbp,%rbp
  je     L147
  movl   $0x0,0xc(%rsp)
  mov    D7(%rip),%rbx
  lea    0x70(%rsp),%r13
  jmp    L30
  nopl   0x0(%rax)
L91:
  mov    0x10(%rbp),%rbp
  test   %rbp,%rbp
  je     L134
L30:
  mov    0x8(%rbp),%rdi
  mov    (%rbx),%rax
  cmp    %rax,(%rdi)
  jne    L91
  mov    0x0(%rbp),%eax
  test   $0x1,%al
  je     L91
  test   $0x8,%al
  jne    L91
  sub    $0x8,%rsp
  xor    %r9d,%r9d
  xor    %r8d,%r8d
  mov    $0x401,%ecx
  push   $0x2
  mov    %r13,%rdx
  mov    $0x10,%esi
  call   <getnameinfo@plt>
  mov    0x8(%rbp),%r15
  lea    0x40(%rsp),%r14
  mov    (%rbx),%rdi
  mov    $0x10,%ecx
  mov    %r14,%rdx
  mov    %r15,%rsi
  call   <inet_ntop@plt>
  pop    %rdx
  pop    %rcx
  test   %rax,%rax
  je     L91
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  xor    %esi,%esi
  test   %rax,%rax
  setne  %sil
  cmpq   $0x0,0x20(%rsp)
  jne    L125
  movdqu (%r15),%xmm1
  lea    0x20(%rsp),%rdi
  movaps %xmm1,0x20(%rsp)
  call   <ipAddressLevel@plt>
  mov    0x10(%rbp),%rbp
  mov    %eax,0xc(%rsp)
  test   %rbp,%rbp
  jne    L30
  nopw   0x0(%rax,%rax,1)
L134:
  mov    0x18(%rsp),%rbp
L147:
  mov    %rbp,%rdi
  call   <freeifaddrs@plt>
  cmpq   $0x0,0x20(%rsp)
  je     L73
  mov    D7(%rip),%rax
  lea    0x20(%rsp),%rsi
  mov    $0x10,%ecx
  mov    %r12,%rdx
  mov    (%rax),%rdi
  call   <inet_ntop@plt>
  cmp    $0x1,%rax
  sbb    %eax,%eax
L104:
  mov    0x478(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L128
  add    $0x488,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L125:
  mov    %r15,%rdi
  call   <ipAddressLevel@plt>
  cmp    %eax,0xc(%rsp)
  jge    L91
  movdqu (%r15),%xmm2
  mov    %eax,0xc(%rsp)
  movaps %xmm2,0x20(%rsp)
  jmp    L91
L73:
  mov    $0xffffffff,%eax
  jmp    L104
L128:
  call   <__stack_chk_fail@plt>
```

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;
  }
}
```