user: 请从给定的汇编指令推导出C源代码:

```asm
<kvp_mac_to_if_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x278,%rsp
  mov    %rdi,-0x278(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x260(%rbp)
  lea    D10(%rip),%rax
  mov    %rax,-0x258(%rbp)
  mov    -0x258(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x250(%rbp)
  cmpq   $0x0,-0x250(%rbp)
  jne    L39
  mov    $0x0,%eax
  jmp    L29
L39:
  mov    -0x258(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  mov    %rdx,%rcx
  lea    D14(%rip),%rdx
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
  mov    -0x258(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  lea    -0x120(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x248(%rbp)
  jmp    L116
L115:
  mov    -0x248(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x240(%rbp),%rax
  mov    (%rax),%rdx
  lea    -0x120(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x120(%rbp),%rax
  lea    D21(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    -0x120(%rbp),%rax
  lea    D16(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x238(%rbp)
  cmpq   $0x0,-0x238(%rbp)
  jne    L75
  jmp    L116
L75:
  mov    -0x238(%rbp),%rdx
  lea    -0x220(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  mov    %rax,-0x230(%rbp)
  cmpq   $0x0,-0x230(%rbp)
  je     L51
  mov    -0x230(%rbp),%rax
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x228(%rbp)
  cmpq   $0x0,-0x228(%rbp)
  je     L71
  mov    -0x228(%rbp),%rax
  movb   $0x0,(%rax)
L71:
  movl   $0x0,-0x264(%rbp)
  jmp    L100
L94:
  mov    -0x264(%rbp),%edx
  mov    -0x230(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    -0x264(%rbp),%ecx
  mov    -0x230(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rbx
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,(%rbx)
  addl   $0x1,-0x264(%rbp)
L100:
  mov    -0x230(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    %eax,-0x264(%rbp)
  jb     L94
  mov    -0x278(%rbp),%rdx
  mov    -0x230(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L51
  mov    -0x240(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x260(%rbp)
  mov    -0x238(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L3
L51:
  mov    -0x238(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L116:
  mov    -0x250(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x240(%rbp)
  cmpq   $0x0,-0x240(%rbp)
  jne    L115
L3:
  mov    -0x250(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x260(%rbp),%rax
L29:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L93
  call   <__stack_chk_fail@plt>
L93:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D10
type_infered: string
name: unpack_data
arguments: data_tag: D14
type_infered: string
name: unpack_data
arguments: data_tag: D21
type_infered: string
name: unpack_data
arguments: data_tag: D16
type_infered: string

tool: D10: /sys/class/net/

tool: D14: %s

tool: D21: /address

tool: D16: r

assistant: ```c
char *kvp_mac_to_if_name(char *mac) {
  DIR *dir;
  struct dirent *entry;
  FILE *file;
  char *p, *q, *x;
  char *if_name = NULL;
  char buf[256];
  char *kvp_net_dir = "/sys/class/net/";
  char dev_id[256];
  unsigned int i;
  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';
      for (i = 0; i < strlen(p); i++)
        p[i] = toupper(p[i]);
      if (!strcmp(p, mac)) {
        if_name = strdup(entry->d_name);
        fclose(file);
        break;
      }
    }
    fclose(file);
  }
  closedir(dir);
  return if_name;
}
```