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

```asm
<kvp_get_if_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x270,%rsp
  mov    %rdi,-0x268(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x258(%rbp)
  lea    D35(%rip),%rax
  mov    %rax,-0x250(%rbp)
  mov    -0x268(%rbp),%rax
  mov    %rax,%rdi
  call   <kvp_get_mac_addr@plt>
  mov    %rax,-0x248(%rbp)
  cmpq   $0x0,-0x248(%rbp)
  jne    L68
  mov    $0x0,%eax
  jmp    L69
L68:
  mov    -0x250(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x240(%rbp)
  cmpq   $0x0,-0x240(%rbp)
  jne    L110
  mov    $0x0,%eax
  jmp    L69
L110:
  mov    -0x250(%rbp),%rdx
  lea    -0x110(%rbp),%rax
  mov    %rdx,%rcx
  lea    D27(%rip),%rdx
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
  mov    -0x250(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x110(%rbp),%rdx
  add    %rdx,%rax
  mov    %rax,-0x238(%rbp)
  jmp    L11
L17:
  mov    -0x238(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x230(%rbp),%rax
  mov    (%rax),%rdx
  lea    -0x110(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x110(%rbp),%rax
  lea    D39(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x110(%rbp),%rax
  lea    D18(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x228(%rbp)
  cmpq   $0x0,-0x228(%rbp)
  jne    L123
  jmp    L11
L123:
  mov    -0x228(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  mov    %rax,-0x220(%rbp)
  cmpq   $0x0,-0x220(%rbp)
  je     L71
  mov    -0x220(%rbp),%rax
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x218(%rbp)
  cmpq   $0x0,-0x218(%rbp)
  je     L56
  mov    -0x218(%rbp),%rax
  movb   $0x0,(%rax)
L56:
  mov    -0x248(%rbp),%rdx
  mov    -0x220(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L71
  mov    -0x230(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x258(%rbp)
  mov    -0x228(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L61
L71:
  mov    -0x228(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L11:
  mov    -0x240(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x230(%rbp)
  cmpq   $0x0,-0x230(%rbp)
  jne    L17
L61:
  mov    -0x240(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x248(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x258(%rbp),%rax
L69:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L5
  call   <__stack_chk_fail@plt>
L5:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D35
data_type: string
name: extract_symbolic_data
arguments: tag: D27
data_type: string
name: extract_symbolic_data
arguments: tag: D39
data_type: string
name: extract_symbolic_data
arguments: tag: D18
data_type: string

tool: D35: /sys/class/net/

tool: D27: %s

tool: D39: /address

tool: D18: r

assistant: ```c
char *kvp_get_if_name(char *guid) {
  DIR *dir;
  struct dirent *entry;
  FILE *file;
  char *p, *q, *x;
  char *mac_addr;
  char *if_name = NULL;
  char buf[256];
  char *kvp_net_dir = "/sys/class/net/";
  char dev_id[256];
  mac_addr = kvp_get_mac_addr(guid);
  if (mac_addr == NULL)
    return NULL;
  dir = opendir(kvp_net_dir);
  if (dir == NULL)
    return NULL;
  snprintf(dev_id, sizeof(dev_id), "%s", kvp_net_dir);
  q = dev_id + strlen(kvp_net_dir);
  while ((entry = readdir(dir)) != NULL) {
    *q = '\0';
    strcat(dev_id, entry->d_name);
    strcat(dev_id, "/address");
    file = fopen(dev_id, "r");
    if (file == NULL)
      continue;
    p = fgets(buf, sizeof(buf), file);
    if (p) {
      x = strchr(p, '\n');
      if (x)
        *x = '\0';
      if (!strcmp(p, mac_addr)) {
        if_name = strdup(entry->d_name);
        fclose(file);
        break;
      }
    }
    fclose(file);
  }
  closedir(dir);
  free(mac_addr);
  return if_name;
}
```