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

```asm
<link_find_prioritized>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %esi,-0x5c(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %rcx,-0x70(%rbp)
  mov    %r8,-0x78(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_udev@plt>
  mov    %rax,-0x38(%rbp)
  movl   $0x0,-0x44(%rbp)
  movq   $0x0,-0x40(%rbp)
  cmpl   $0x0,-0x5c(%rbp)
  je     L99
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devlink_priority@plt>
  mov    %eax,-0x44(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devnode@plt>
  mov    %rax,%rdx
  mov    -0x78(%rbp),%rcx
  mov    -0x70(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <util_strscpy@plt>
  mov    -0x70(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L99:
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  jne    L71
  mov    -0x40(%rbp),%rax
  jmp    L78
L71:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L26
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L26
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  je     L136
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x68(%rbp),%rcx
  mov    -0x38(%rbp),%rax
  lea    D29(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_id_filename@plt>
  mov    %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L62
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <udev_device_new_from_id_filename@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L71
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devnode@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L97
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devlink_priority@plt>
  mov    %eax,%ebx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devnode@plt>
  mov    %rax,%rsi
  mov    -0x44(%rbp),%ecx
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %ebx,%r9d
  mov    %rsi,%r8
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  cmpq   $0x0,-0x40(%rbp)
  je     L125
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devlink_priority@plt>
  cmp    %eax,-0x44(%rbp)
  jge    L97
L125:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devlink_priority@plt>
  mov    %eax,%ebx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_syspath@plt>
  cltq
  mov    %rax,%rsi
  mov    -0x68(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%r8
  mov    %ebx,%ecx
  mov    %rsi,%rdx
  lea    D11(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_devlink_priority@plt>
  mov    %eax,-0x44(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x78(%rbp),%rcx
  mov    -0x70(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <util_strscpy@plt>
  mov    -0x70(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L97:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_unref@plt>
  jmp    L71
L136:
  nop
  jmp    L71
L62:
  nop
  jmp    L71
L26:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x40(%rbp),%rax
L78:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D29
type_guessed: string
name: disassemble_data
arguments: label: D4
type_guessed: string
name: disassemble_data
arguments: label: D11
type_guessed: string

tool: D29: found '%s' claiming '%s'


tool: D4: compare priority of '%s'(%i) > '%s'(%i)


tool: D11: '%s' claims priority %i for '%s'


assistant: ```c
const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize) {
  struct udev *udev = udev_device_get_udev(dev);
  DIR *dir;
  int priority = 0;
  const char *target = NULL;
  if (add) {
    priority = udev_device_get_devlink_priority(dev);
    util_strscpy(buf, bufsize, udev_device_get_devnode(dev));
    target = buf;
  }
  dir = opendir(stackdir);
  if (dir == NULL)
    return target;
  for (;;) {
    struct udev_device *dev_db;
    struct dirent *dent;
    dent = readdir(dir);
    if (dent == NULL || dent->d_name[0] == '\0')
      break;
    if (dent->d_name[0] == '.')
      continue;
    udev_log_null(udev, "found '%s' claiming '%s'\n", dent->d_name, stackdir);
    if (strcmp(dent->d_name, udev_device_get_id_filename(dev)) == 0)
      continue;
    dev_db = udev_device_new_from_id_filename(udev, dent->d_name);
    if (dev_db != NULL) {
      const char *devnode;
      devnode = udev_device_get_devnode(dev_db);
      if (devnode != NULL) {
        udev_log_null(udev, "compare priority of '%s'(%i) > '%s'(%i)\n", target, priority, udev_device_get_devnode(dev_db), udev_device_get_devlink_priority(dev_db));
        if (target == NULL || udev_device_get_devlink_priority(dev_db) > priority) {
          udev_log_null(udev, "'%s' claims priority %i for '%s'\n", udev_device_get_syspath(dev_db), udev_device_get_devlink_priority(dev_db), stackdir);
          priority = udev_device_get_devlink_priority(dev_db);
          util_strscpy(buf, bufsize, devnode);
          target = buf;
        }
      }
      udev_device_unref(dev_db);
    }
  }
  closedir(dir);
  return target;
}
```