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

```asm
<udev_device_new_from_syspath>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x828,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x818(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L94
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  test   %rdi,%rdi
  je     L94
  call   <udev_get_sys_path@plt>
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%r12
  mov    %rbx,%rdi
  call   <udev_get_sys_path@plt>
  mov    %rax,%rsi
  mov    %r12d,%edx
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L87
  lea    0x1(%rbp,%r12,1),%r13
  mov    $0x2f,%esi
  mov    %r13,%rdi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L89
  cmpb   $0x0,0x1(%rax)
  je     L89
  add    $0x2,%r13
  cmp    %r13,%rax
  jb     L89
  lea    0x10(%rsp),%r13
  mov    %rbp,%rdx
  mov    $0x400,%esi
  mov    %r13,%rdi
  call   <util_strscpy@plt>
  mov    $0x400,%edx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <util_resolve_sys_link@plt>
  lea    0x0(%r13,%r12,1),%rdi
  mov    $0x9,%edx
  lea    D66(%rip),%rsi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L57
  mov    %r13,%rdx
  lea    0x410(%rsp),%r12
  mov    $0x0,%r8d
  lea    D6(%rip),%rcx
  mov    $0x400,%esi
  mov    %r12,%rdi
  call   <util_strscpyl@plt>
  lea    0xc(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L92
L90:
  mov    %rbx,%rdi
  call   <udev_device_new@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L119
  lea    0x10(%rsp),%rsi
  mov    %rax,%rdi
  call   <udev_device_set_syspath@plt>
  mov    %rbp,%rdi
  call   <udev_device_get_devpath@plt>
  mov    %eax,%ecx
  mov    %rbp,%rdx
  lea    D54(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  jmp    L119
L87:
  mov    %rbp,%rdx
  lea    D14(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    $0x0,%ebp
  jmp    L119
L89:
  mov    %rbp,%rdx
  lea    D1(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    $0x0,%ebp
L119:
  mov    0x818(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  mov    %rbp,%rax
  add    $0x828,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L92:
  mov    %rbp,%rdx
  lea    D2(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    $0x0,%ebp
  jmp    L119
L57:
  lea    0xc(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L46
  mov    0xc(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L90
L46:
  mov    %rbp,%rdx
  lea    D25(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <udev_log_null@plt>
  mov    $0x0,%ebp
  jmp    L119
L94:
  mov    $0x0,%ebp
  jmp    L119
L3:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D66
type: string
name: extract_symbolic_data
arguments: tag: D6
type: string
name: extract_symbolic_data
arguments: tag: D54
type: string
name: extract_symbolic_data
arguments: tag: D14
type: string
name: extract_symbolic_data
arguments: tag: D1
type: string
name: extract_symbolic_data
arguments: tag: D2
type: string
name: extract_symbolic_data
arguments: tag: D25
type: string

tool: D66: /devices/

tool: D6: /uevent

tool: D54: device %p has devpath '%s'


tool: D14: not in sys :%s


tool: D1: not a subdir :%s


tool: D2: not a device: %s


tool: D25: directory not found: %s


assistant: ```c
struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) {
  size_t len;
  const char *subdir;
  char path[1024];
  char *pos;
  struct stat statbuf;
  struct udev_device *udev_device;
  if (udev == NULL)
    return NULL;
  if (syspath == NULL)
    return NULL;
  len = strlen(udev_get_sys_path(udev));
  if (strncmp(syspath, udev_get_sys_path(udev), len) != 0) {
    udev_log_null(udev, "not in sys :%s\n", syspath);
    return NULL;
  }
  subdir = &syspath[len + 1];
  pos = strrchr(subdir, '/');
  if (pos == NULL || pos[1] == '\0' || pos < &subdir[2]) {
    udev_log_null(udev, "not a subdir :%s\n", syspath);
    return NULL;
  }
  util_strscpy(path, sizeof(path), syspath);
  util_resolve_sys_link(udev, path, sizeof(path));
  if (strncmp(&path[len], "/devices/", 9) == 0) {
    char file[1024];
    util_strscpyl(file, sizeof(file), path, "/uevent", NULL);
    if (stat(file, &statbuf) != 0) {
      udev_log_null(udev, "not a device: %s\n", syspath);
      return NULL;
    }
  } else {
    if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) {
      udev_log_null(udev, "directory not found: %s\n", syspath);
      return NULL;
    }
  }
  udev_device = udev_device_new(udev);
  if (udev_device == NULL)
    return NULL;
  udev_device_set_syspath(udev_device, path);
  udev_log_null(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
  return udev_device;
}
```