user: Please show me the C implementation that matches the assembly code listed below:

```asm
<path_newsgroupize>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  movq   $0x0,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L27
  cmpq   $0x0,-0x30(%rbp)
  je     L142
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x2f,%eax
  je     L63
L72:
  mov    -0x10(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jb     L73
  mov    -0x10(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  jmp    L81
L73:
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    -0x10(%rbp),%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addq   $0x1,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x2f,%eax
  je     L63
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L72
L63:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L112
  mov    -0x10(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  jmp    L81
L112:
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    -0x10(%rbp),%rdx
  lea    0x1(%rdx),%rcx
  mov    %rcx,-0x10(%rbp)
  lea    0x0(,%rdx,4),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <wcschr@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L147
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L134
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  jmp    L112
L147:
  nop
  jmp    L140
L134:
  nop
L140:
  mov    -0x38(%rbp),%rax
  sub    -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x10(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rax,%rcx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <wcslcpy@plt>
  jmp    L81
L27:
  nop
  jmp    L81
L142:
  nop
L81:
  leave
  ret
```

assistant: ```c
void path_newsgroupize(wchar_t *output, const wchar_t *path, size_t len) {
  const wchar_t *last = NULL, *c = path;
  size_t idx = 0;
  if (len < 1)
    return;
  if (path == NULL)
    return;
  if (*path != L'/') {
    do {
      if (idx >= len) {
        output[idx] = L'\0';
        return;
      }
      output[idx] = *(c++);
      idx++;
    } while (*c != L'/' && *c != L'\0');
  }
  if (*c == L'\0') {
    output[idx] = L'\0';
    return;
  }
  for (;;) {
    output[idx++] = *(c++);
    last = c;
    if ((c = wcschr(c, L'/')) == NULL)
      break;
    if (*(c + 1) == L'\0')
      break;
    output[idx++] = *last;
  }
  wcslcpy(output + idx, last, len - idx);
}
```