user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<get_ip_from_ifname>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x60,%rsp
  mov    %edi,%r12d
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x18(%rsp)
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  movq   $0x0,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  movq   $0x0,0x40(%rsp)
  movq   $0x0,0x48(%rsp)
  lea    0x8(%rsp),%rdi
  call   <getifaddrs@plt>
  test   %rax,%rax
  jne    L184
  lea    -0x80(%r12),%eax
  mov    $0x0,%ebx
  cmp    $0x1,%eax
  ja     L169
  mov    0x8(%rsp),%rbx
  test   %rbx,%rbx
  jne    L107
L78:
  mov    0x8(%rsp),%rdi
  call   <freeifaddrs@plt>
  mov    $0x0,%ebx
  jmp    L169
L24:
  mov    0x8(%rbx),%rsi
  cmpl   $0x81,(%rsi)
  je     L117
L141:
  mov    0x18(%rbx),%rbx
  test   %rbx,%rbx
  je     L78
L107:
  cmpq   $0x0,0x8(%rbx)
  je     L141
  mov    (%rbx),%eax
  mov    D3(%rip),%rdx
  and    (%rdx),%eax
  je     L141
  mov    0x10(%rbx),%esi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L141
  cmp    $0x81,%r12d
  je     L24
  mov    0x8(%rbx),%rsi
  cmpl   $0x80,(%rsi)
  jne    L141
  lea    0x10(%rsp),%rdx
  mov    $0x40,%ecx
  mov    $0x80,%edi
  call   <inet_ntop@plt>
  test   %rax,%rax
  je     L78
  lea    0x10(%rsp),%rdi
  call   <strdup@plt>
  mov    %rax,%rbx
  jmp    L71
L117:
  lea    0x10(%rsp),%rdx
  mov    $0x40,%ecx
  mov    $0x81,%edi
  call   <inet_ntop@plt>
  test   %rax,%rax
  je     L78
  lea    0x10(%rsp),%rdi
  call   <strdup@plt>
  mov    %rax,%rbx
L71:
  mov    0x8(%rsp),%rdi
  call   <freeifaddrs@plt>
  test   %rbx,%rbx
  je     L169
  cmpb   $0x0,(%rbx)
  je     L146
L169:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  mov    %rbx,%rax
  add    $0x60,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L146:
  mov    %rbx,%rdi
  call   <free@plt>
  mov    $0x0,%ebx
  jmp    L169
L184:
  mov    $0x0,%ebx
  jmp    L169
L70:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *get_ip_from_ifname(const int inet_family, const char *const ifname) {
  char *retv = NULL;
  struct ifaddrs *myaddrs;
  struct ifaddrs *ifa;
  struct sockaddr_in *s4;
  struct sockaddr_in6 *s6;
  char buf[64] = {'\0'};
  if (getifaddrs(&myaddrs))
    return NULL;
  switch (inet_family) {
  case AF_INET:
  case AF_INET6:
    break;
  default:
    return NULL;
  }
  for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) {
    if (NULL == ifa->ifa_addr)
      continue;
    if (0 == (ifa->ifa_flags & IFF_UP))
      continue;
    if (strcmp(ifname, ifa->ifa_name))
      continue;
    if (AF_INET == inet_family) {
      if (ifa->ifa_addr->sa_family == AF_INET) {
        s4 = (struct sockaddr_in *)(ifa->ifa_addr);
        if (inet_ntop(ifa->ifa_addr->sa_family, (void *)&(s4->sin_addr), buf, sizeof(buf)) == NULL) {
          break;
        } else {
          retv = strdup(buf);
          break;
        }
      }
    }
    if (AF_INET6 == inet_family) {
      if (ifa->ifa_addr->sa_family == AF_INET6) {
        s6 = (struct sockaddr_in6 *)(ifa->ifa_addr);
        if (inet_ntop(ifa->ifa_addr->sa_family, (void *)&(s6->sin6_addr), buf, sizeof(buf)) == NULL) {
          break;
        } else {
          retv = strdup(buf);
          break;
        }
      }
    }
  }
  freeifaddrs(myaddrs);
  if (retv && ('\0' == retv[0])) {
    free(retv);
    retv = NULL;
  }
  return retv;
}
```