user: Translate the below assembly code into C programming language:

```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    D18(%rip),%rdi
  call   <opendir@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L2
  lea    0x120(%rsp),%rbx
  lea    D18(%rip),%rbp
  mov    %rbp,%rcx
  lea    D30(%rip),%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    L67
L108:
  mov    %ebp,%ebx
  add    %r12,%rbx
  movsbl (%rbx),%edi
  call   <toupper@plt>
  mov    %al,(%rbx)
  add    $0x1,%ebp
L22:
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    %ebp,%eax
  ja     L108
  mov    0x18(%rsp),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L47
L31:
  mov    %r14,%rdi
  call   <fclose@plt>
L67:
  mov    0x8(%rsp),%rdi
  call   <readdir@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L51
  mov    0x10(%rsp),%rax
  movb   $0x0,(%rax)
  mov    0x0(%r13),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  lea    D21(%rip),%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  lea    D9(%rip),%rsi
  mov    %r15,%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L67
  lea    0x20(%rsp),%rdi
  mov    %rax,%rdx
  mov    $0x100,%esi
  call   <fgets@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L31
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L76
  movb   $0x0,(%rax)
L76:
  mov    $0x0,%ebp
  jmp    L22
L47:
  mov    0x0(%r13),%rdi
  call   <strdup@plt>
  mov    %rax,%r13
  mov    %r14,%rdi
  call   <fclose@plt>
L51:
  mov    0x8(%rsp),%rdi
  call   <closedir@plt>
L24:
  mov    0x228(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  mov    %r13,%rax
  add    $0x238,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  mov    0x8(%rsp),%r13
  jmp    L24
L40:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D18
type: string
name: disassemble_data
arguments: data_label: D30
type: string
name: disassemble_data
arguments: data_label: D21
type: string
name: disassemble_data
arguments: data_label: D9
type: string

tool: D18: /sys/class/net/

tool: D30: %s

tool: D21: /address

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