user: Converte this assembly snippet into its equivalent C code:

```asm
<find_intf>:
  endbr64
  push   %r15
  mov    %edx,%ecx
  lea    D5(%rip),%rdx
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x478,%rsp
  mov    %rdi,0x10(%rsp)
  lea    0x20(%rsp),%rbp
  mov    %rsi,0x18(%rsp)
  mov    %rbp,%rdi
  mov    $0x40,%esi
  mov    %fs:0x28,%rax
  mov    %rax,0x468(%rsp)
  xor    %eax,%eax
  call   <snprintf@plt>
  lea    D69(%rip),%rsi
  mov    %rbp,%rdi
  call   <popen@plt>
  test   %rax,%rax
  je     L52
  mov    %rax,%r12
  xor    %ebx,%ebx
  lea    0x60(%rsp),%rbp
  lea    D7(%rip),%r13
  jmp    L58
  nopl   0x0(%rax,%rax,1)
L41:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L69
  lea    D12(%rip),%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L69
  sub    %r14,%rax
  lea    0x1(%rax),%esi
  mov    %esi,%edi
  mov    %esi,0xc(%rsp)
  call   <malloc@plt>
  mov    0xc(%rsp),%esi
  mov    %r14,%rcx
  lea    D71(%rip),%rdx
  mov    %rax,%r15
  mov    %rax,%rdi
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    0x10(%rsp),%rax
  mov    %r15,(%rax,%rbx,8)
  add    $0x1,%rbx
L58:
  mov    %r12,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L41
  cmp    $0x4,%ebx
  jne    L97
  mov    0x18(%rsp),%rax
  mov    %r12,%rdi
  movl   $0x4,(%rax)
  call   <pclose@plt>
  xor    %eax,%eax
  jmp    L62
  nopl   (%rax)
L69:
  lea    D39(%rip),%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <pclose@plt>
  mov    $0xffffffff,%eax
L62:
  mov    0x468(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L56
  add    $0x478,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L97:
  lea    D4(%rip),%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <pclose@plt>
  mov    $0xffffffff,%eax
  jmp    L62
L52:
  mov    %rbp,%rsi
  lea    D34(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L62
L56:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D5
type_infered: string
name: unpack_data
arguments: label: D69
type_infered: string
name: unpack_data
arguments: label: D7
type_infered: string
name: unpack_data
arguments: label: D12
type_infered: string
name: unpack_data
arguments: label: D71
type_infered: string
name: unpack_data
arguments: label: D39
type_infered: string
name: unpack_data
arguments: label: D4
type_infered: string
name: unpack_data
arguments: label: D34
type_infered: string

tool: D5: grep -r '%x' /sys/class/net/*/device/device

tool: D69: r

tool: D7: eth

tool: D12: /device

tool: D71: %s

tool: D39: Error in parse interface name

tool: D4: Failed to find all ethernet interface

tool: D34: Failed open pipe to run cmd : %s


assistant: ```c
int find_intf(char **intf, uint8_t *size, int did) {
  char cmd[64];
  snprintf(cmd, 64, "grep -r '%x' /sys/class/net/*/device/device", did);
  FILE *fp = popen(cmd, "r");
  if (fp == NULL) {
    printf("Failed open pipe to run cmd : %s\n", cmd);
    return -1;
  }
  char buf[1024];
  uint8_t index = 0;
  while (fgets(buf, sizeof(buf), fp) != NULL) {
    char *start = strstr(buf, "eth");
    if (start == NULL) {
      printf("Error in parse interface name\n");
      pclose(fp);
      return -1;
    }
    char *end = strstr(buf, "/device");
    if (end == NULL) {
      printf("Error in parse interface name\n");
      pclose(fp);
      return -1;
    }
    uint8_t len = end - start;
    char *interf = (char *)malloc(sizeof(char) * (len + 1));
    snprintf(interf, len + 1, "%s", start);
    intf[index] = interf;
    index++;
  }
  if (index != 4) {
    printf("Failed to find all ethernet interface\n");
    pclose(fp);
    return -1;
  }
  *size = 4;
  pclose(fp);
  return 0;
}
```