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

```asm
<path_cleancut>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x18,%rsp
  mov    %r8,(%rsp)
  test   %rdx,%rdx
  je     L0
  test   %rdi,%rdi
  je     L0
  test   %rbp,%rbp
  je     L27
L20:
  lea    0x1(%r12),%r14
  cmp    %rbx,%r14
  ja     L15
L39:
  mov    %rbp,%rdi
  call   <wcslen@plt>
  mov    %r14,%rdx
  cmp    %r12,%rax
  jbe    L64
  mov    (%rsp),%rsi
  mov    %r13,%rdi
  call   <wcslcpy@plt>
  mov    %rax,0x8(%rsp)
  cmp    %rax,%r12
  jbe    L116
  mov    %r12,%rbx
  mov    %rbp,%r15
  sub    %rax,%rbx
  jmp    L54
L25:
  lea    0x4(%r15),%rax
  cmpl   $0x2f,(%r15)
  mov    $0x2f,%esi
  cmove  %rax,%r15
  mov    %r15,%rdi
  call   <wcschr@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L38
L54:
  mov    %r15,%rdi
  call   <wcslen@plt>
  cmp    %rbx,%rax
  ja     L25
  mov    0x8(%rsp),%rax
  mov    %r14,%rdx
  add    $0x18,%rsp
  mov    %r15,%rsi
  pop    %rbx
  pop    %rbp
  lea    0x0(%r13,%rax,4),%r8
  pop    %r12
  sub    %rax,%rdx
  pop    %r13
  mov    %r8,%rdi
  pop    %r14
  pop    %r15
  jmp    10c0 <wcsncpy@plt>
  nopl   0x0(%rax,%rax,1)
L116:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L64:
  add    $0x18,%rsp
  mov    %rbp,%rsi
  mov    %r13,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <wcslcpy@plt>
  nopl   0x0(%rax)
L15:
  lea    D5(%rip),%rsi
  mov    $0x1,%edi
  call   <errx@plt>
  jmp    L39
  cs nopw 0x0(%rax,%rax,1)
L0:
  lea    D21(%rip),%rsi
  mov    $0x1,%edi
  call   <errx@plt>
  test   %rbp,%rbp
  jne    L20
L27:
  lea    D2(%rip),%rsi
  mov    $0x1,%edi
  call   <errx@plt>
  jmp    L20
L38:
  mov    (%rsp),%r8
  add    $0x18,%rsp
  mov    %r12,%rcx
  mov    %r14,%rdx
  pop    %rbx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10f0 <path_quickcut@plt>
```

tool_calls: name: parse_data
arguments: tag: D5
data_type: string
name: parse_data
arguments: tag: D21
data_type: string
name: parse_data
arguments: tag: D2
data_type: string

tool: D5: path_cleancut: maxlen too long

tool: D21: path_cleancut: invalid output

tool: D2: path_cleancut: null input

assistant: ```c
void path_cleancut(wchar_t *out, wchar_t *path, size_t len, size_t maxlen, wchar_t *filler) {
  size_t maxplen, flen;
  wchar_t *c;
  if (len == 0 || out == NULL)
    errx(1, "path_cleancut: invalid output");
  if (path == NULL)
    errx(1, "path_cleancut: null input");
  if (maxlen + 1 > len)
    errx(1, "path_cleancut: maxlen too long");
  len = maxlen + 1;
  if (wcslen(path) <= maxlen) {
    wcslcpy(out, path, len);
    return;
  }
  flen = wcslcpy(out, filler, len);
  if (flen >= maxlen)
    return;
  maxplen = maxlen - flen;
  for (c = path; wcslen(c) > maxplen;) {
    if (*c == L'/')
      c++;
    c = wcschr(c, '/');
    if (c == NULL) {
      path_quickcut(out, path, len, maxlen, filler);
      return;
    }
  }
  wcsncpy(out + flen, c, len - flen);
}
```