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

```asm
<find_intf>:
  endbr64
  push   %r15
  mov    %edx,%ecx
  lea    D50(%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    D43(%rip),%rsi
  mov    %rbp,%rdi
  call   <popen@plt>
  test   %rax,%rax
  je     L38
  mov    %rax,%r12
  xor    %ebx,%ebx
  lea    0x60(%rsp),%rbp
  lea    D62(%rip),%r13
  jmp    L77
  nopl   0x0(%rax,%rax,1)
L41:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L17
  lea    D19(%rip),%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L17
  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    D46(%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
L77:
  mov    %r12,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L41
  cmp    $0x4,%ebx
  jne    L30
  mov    0x18(%rsp),%rax
  mov    %r12,%rdi
  movl   $0x4,(%rax)
  call   <pclose@plt>
  xor    %eax,%eax
  jmp    L71
  nopl   (%rax)
L17:
  lea    D0(%rip),%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <pclose@plt>
  mov    $0xffffffff,%eax
L71:
  mov    0x468(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x478,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L30:
  lea    D71(%rip),%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <pclose@plt>
  mov    $0xffffffff,%eax
  jmp    L71
L38:
  mov    %rbp,%rsi
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L71
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D50
type_infered: string
name: disassemble_data
arguments: tag: D43
type_infered: string
name: disassemble_data
arguments: tag: D62
type_infered: string
name: disassemble_data
arguments: tag: D19
type_infered: string
name: disassemble_data
arguments: tag: D46
type_infered: string
name: disassemble_data
arguments: tag: D0
type_infered: string
name: disassemble_data
arguments: tag: D71
type_infered: string
name: disassemble_data
arguments: tag: D10
type_infered: string

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

tool: D43: r

tool: D62: eth

tool: D19: /device

tool: D46: %s

tool: D0: Error in parse interface name

tool: D71: Failed to find all ethernet interface

tool: D10: 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;
}
```