user: Please show me the C implementation that matches the assembly code listed below:

```asm
<iface_hw_addr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %edi,-0x74(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    D27(%rip),%rax
  mov    (%rax),%ecx
  mov    D58(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <socket@plt>
  mov    %eax,-0x6c(%rbp)
  cmpl   $0xffffffff,-0x6c(%rbp)
  jne    L74
  mov    $0x0,%eax
  jmp    L73
L74:
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x68(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L27:
  cmp    %rdx,%rsp
  je     L52
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L27
L52:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L68
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L68:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x60(%rbp)
  mov    -0x60(%rbp),%rdx
  mov    -0x74(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <if_indextoname@plt>
  test   %rax,%rax
  je     L6
  lea    -0x50(%rbp),%rax
  mov    $0x18,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x40(%rbp),%eax
  mov    -0x60(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <strncpy@plt>
  mov    D42(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x50(%rbp),%rdx
  mov    -0x6c(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <ioctl@plt>
  test   %rax,%rax
  js     L99
  mov    -0x50(%rbp),%rdx
  mov    D59(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L31
  mov    -0x48(%rbp),%eax
  mov    %eax,%esi
  mov    $0x3,%edi
  call   <addr_create@plt>
  mov    %rax,-0x58(%rbp)
  mov    -0x6c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x58(%rbp),%rax
  jmp    L73
L6:
  nop
  jmp    L5
L99:
  nop
  jmp    L5
L31:
  nop
L5:
  mov    -0x6c(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0x0,%eax
L73:
  mov    %rbx,%rsp
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L37
  call   <__stack_chk_fail@plt>
L37:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
struct addr *iface_hw_addr(int if_index) {
  int fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (fd == -1)
    return NULL;
  char if_name[IF_NAMESIZE];
  if (if_indextoname(if_index, if_name) == NULL)
    goto exit;
  struct ifreq ifr;
  memset(&ifr, 0, sizeof(ifr));
  strncpy(ifr.ifr_name, if_name, IF_NAMESIZE - 1);
  if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
    goto exit;
  if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
    goto exit;
  struct addr *addr = addr_create(3, ifr.ifr_hwaddr.sa_data);
  close(fd);
  return addr;
exit:
  close(fd);
  return NULL;
}
```