user: Translate the below assembly code into C programming language:

```asm
<if_nameindex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    $0x0,%edx
  mov    D19(%rip),%rax
  mov    (%rax),%esi
  mov    D76(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  js     L16
L72:
  movq   $0x0,-0x40(%rbp)
  movl   $0x0,-0x60(%rbp)
  lea    -0x60(%rbp),%rdx
  mov    D38(%rip),%rax
  mov    (%rax),%esi
  mov    %r15d,%edi
  call   <ioctl@plt>
  movq   $0x0,-0x70(%rbp)
  test   %eax,%eax
  js     L102
  movslq -0x60(%rbp),%rdi
  call   <alloca@plt>
  mov    %rax,-0x40(%rbp)
  lea    -0x60(%rbp),%rdx
  mov    D38(%rip),%rax
  mov    (%rax),%esi
  mov    %r15d,%edi
  call   <ioctl@plt>
  movq   $0x0,-0x70(%rbp)
  test   %eax,%eax
  js     L102
  movslq -0x60(%rbp),%rdx
  movabs $0xcccccccccccccccd,%rcx
  mov    %rdx,%rax
  mul    %rcx
  shr    $0x5,%rdx
  mov    %rdx,%r12
  lea    0x1(%rdx),%edi
  shl    $0x4,%edi
  mov    D25(%rip),%rax
  mov    %edx,%ecx
  imul   (%rax),%ecx
  add    %ecx,%edi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    %rax,-0x70(%rbp)
  test   %rax,%rax
  je     L102
  movslq %r12d,%rbx
  add    $0x1,%rbx
  shl    $0x4,%rbx
  add    %rax,%rbx
  test   %r12d,%r12d
  jle    L103
  lea    -0x1(%r12),%eax
  lea    0x4(,%rax,4),%rax
  mov    %rax,-0x68(%rbp)
  mov    $0x0,%r12d
  jmp    L57
L16:
  mov    $0x0,%edx
  mov    D19(%rip),%rax
  mov    (%rax),%esi
  mov    D24(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  mov    %eax,%r15d
  jmp    L72
L54:
  add    $0x4,%r12
  cmp    -0x68(%rbp),%r12
  je     L108
L57:
  mov    %r12,%r13
  add    -0x48(%rbp),%r13
  mov    %rbx,(%r14)
  mov    0x10(%r13),%esi
  mov    D25(%rip),%rax
  mov    (%rax),%edx
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %r13,%rdx
  mov    D87(%rip),%rax
  mov    (%rax),%esi
  mov    %r15d,%edi
  call   <ioctl@plt>
  cmp    $0xffffffff,%eax
  je     L54
  mov    0x8(%r13),%rax
  mov    %rax,0x8(%r14)
  mov    D25(%rip),%rax
  movslq (%rax),%rax
  add    %rax,%rbx
  add    $0x10,%r14
  jmp    L54
L103:
  mov    -0x70(%rbp),%r14
L108:
  movq   $0x0,(%r14)
  movq   $0x0,0x8(%r14)
L102:
  mov    %r15d,%edi
  call   <close@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L18
  mov    -0x70(%rbp),%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
struct if_nameindex *if_nameindex(void) {
  struct ifconf ic;
  int fd, len, i;
  struct if_nameindex *x = 0, *y;
  char *dest;
  fd = socket(AF_INET6, SOCK_DGRAM, 0);
  if (fd < 0)
    fd = socket(AF_INET, SOCK_DGRAM, 0);
  ic.ifc_buf = 0;
  ic.ifc_len = 0;
  if (ioctl(fd, SIOCGIFCONF, &ic) < 0)
    goto b0rken;
  ic.ifc_buf = alloca((size_t)ic.ifc_len);
  if (ioctl(fd, SIOCGIFCONF, &ic) < 0)
    goto b0rken;
  len = (ic.ifc_len / sizeof(struct ifreq));
  x = (struct if_nameindex *)malloc((len + 1) * sizeof(struct if_nameindex) + len * IFNAMSIZ);
  if (!x)
    goto b0rken;
  dest = (char *)(x + len + 1);
  y = x;
  for (i = 0; i < len; ++i) {
    struct ifreq *ir = (struct ifreq *)&ic.ifc_req[i];
    y->if_name = dest;
    memcpy(dest, ir->ifr_name, IFNAMSIZ);
    if (ioctl(fd, SIOCGIFINDEX, ir) == -1)
      continue;
    y->if_index = ir->ifr_ifindex;
    dest += IFNAMSIZ;
    ++y;
  }
  y->if_name = 0;
  y->if_index = 0;
b0rken:
  close(fd);
  return x;
}
```