user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<kvp_mac_to_if_name>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x238,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x228(%rsp)
  xor    %eax,%eax
  lea    D33(%rip),%rdi
  call   <opendir@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L90
  lea    0x120(%rsp),%rbx
  lea    D33(%rip),%rbp
  mov    %rbp,%rdx
  mov    $0x100,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%eax
  add    %rbx,%rax
  mov    %rax,0x10(%rsp)
  mov    %rbx,%r15
  jmp    L46
L83:
  mov    %ebp,%ebx
  add    %r12,%rbx
  movsbl (%rbx),%edi
  call   <toupper@plt>
  mov    %al,(%rbx)
  add    $0x1,%ebp
L39:
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    %ebp,%eax
  ja     L83
  mov    0x18(%rsp),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L44
L45:
  mov    %r14,%rdi
  call   <fclose@plt>
L46:
  mov    0x8(%rsp),%rdi
  call   <readdir@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L0
  mov    0x10(%rsp),%rax
  movb   $0x0,(%rax)
  mov    0x0(%r13),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  lea    D28(%rip),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  lea    D38(%rip),%rsi
  mov    %r15,%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L46
  lea    0x20(%rsp),%rdi
  mov    %rax,%rdx
  mov    $0x100,%esi
  call   <fgets@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L45
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L15
  movb   $0x0,(%rax)
L15:
  mov    $0x0,%ebp
  jmp    L39
L44:
  mov    0x0(%r13),%rdi
  call   <strdup@plt>
  mov    %rax,%r13
  mov    %r14,%rdi
  call   <fclose@plt>
L0:
  mov    0x8(%rsp),%rdi
  call   <closedir@plt>
L89:
  mov    0x228(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L52
  mov    %r13,%rax
  add    $0x238,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L90:
  mov    0x8(%rsp),%r13
  jmp    L89
L52:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D33
data_type: string
name: disassemble_data
arguments: label: D28
data_type: string
name: disassemble_data
arguments: label: D38
data_type: string

tool: D33: /sys/class/net/

tool: D28: /address

tool: D38: 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), 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;
}
```