user: What would the C source look like for the assembly code provided here?

```asm
<wcsnrtombs>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x148,%rsp
  mov    (%rsi),%rbp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  mov    %rbp,0x28(%rsp)
  test   %rdi,%rdi
  je     L63
  test   %rcx,%rcx
  mov    %rcx,%r14
  mov    %rdi,%r15
  setne  %al
L147:
  test   %rbp,%rbp
  setne  %dl
  xor    %r12d,%r12d
  and    %al,%dl
  mov    %dl,0xf(%rsp)
  je     L73
  cmp    %r14,%r13
  jae    L232
  cmp    $0x20,%r13
  jbe    L93
L232:
  lea    0x30(%rsp),%rax
  lea    0x28(%rsp),%rbx
  mov    %rax,(%rsp)
  jmp    L90
  cs nopw 0x0(%rax,%rax,1)
L85:
  mov    %rdx,%rax
  sub    %rbp,%rax
  sar    $0x2,%rax
  sub    %rax,%r13
  test   %r14,%r14
  je     L199
  cmp    $0x20,%r13
  ja     L194
  cmp    %r13,%r14
  ja     L93
L194:
  mov    %rdx,%rbp
L90:
  cmp    %r14,%r13
  mov    %r14,%rdx
  mov    %rbx,%rsi
  mov    %r15,%rdi
  cmovbe %r13,%rdx
  xor    %ecx,%ecx
  call   <wcsrtombs@plt>
  cmp    $0xffffffffffffffff,%rax
  je     L10
  cmp    (%rsp),%r15
  je     L191
  add    %rax,%r15
  sub    %rax,%r14
L191:
  mov    0x28(%rsp),%rdx
  add    %rax,%r12
  test   %rdx,%rdx
  jne    L85
L131:
  cmpq   $0x0,0x10(%rsp)
  je     L162
  mov    0x28(%rsp),%rax
  mov    0x18(%rsp),%rbx
  mov    %rax,(%rbx)
L162:
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L187
  add    $0x148,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L73:
  test   %rbp,%rbp
  je     L131
L199:
  test   %r14,%r14
  setne  0xf(%rsp)
L93:
  test   %r13,%r13
  je     L131
  cmpb   $0x0,0xf(%rsp)
  je     L131
  mov    0x28(%rsp),%rcx
  jmp    L142
  nopl   0x0(%rax,%rax,1)
L218:
  mov    0x28(%rsp),%rbx
  sub    $0x1,%r13
  add    %rax,%r15
  add    %rax,%r12
  lea    0x4(%rbx),%rcx
  mov    %rcx,0x28(%rsp)
  sub    %rax,%r14
  je     L131
  test   %r13,%r13
  je     L131
L142:
  mov    (%rcx),%esi
  xor    %edx,%edx
  mov    %r15,%rdi
  call   <wcrtomb@plt>
  lea    0x1(%rax),%rdx
  cmp    $0x1,%rdx
  ja     L218
  test   %rax,%rax
  jne    L10
  movq   $0x0,0x28(%rsp)
  jmp    L131
  nopl   0x0(%rax,%rax,1)
L10:
  mov    $0xffffffffffffffff,%r12
  jmp    L131
  nopl   0x0(%rax)
L63:
  mov    $0x1,%eax
  lea    0x30(%rsp),%r15
  mov    $0x100,%r14d
  jmp    L147
L187:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st) {
  size_t l, cnt = 0, n2;
  char *s, buf[256];
  const wchar_t *ws = *wcs;
  const wchar_t *tmp_ws;
  if (!dst)
    s = buf, n = sizeof buf;
  else
    s = dst;
  while (ws && n && ((n2 = wn) >= n || n2 > 32)) {
    if (n2 >= n)
      n2 = n;
    tmp_ws = ws;
    l = wcsrtombs(s, &ws, n2, 0);
    if (!(l + 1)) {
      cnt = l;
      n = 0;
      break;
    }
    if (s != buf) {
      s += l;
      n -= l;
    }
    wn = ws ? wn - (ws - tmp_ws) : 0;
    cnt += l;
  }
  if (ws)
    while (n && wn) {
      l = wcrtomb(s, *ws, 0);
      if ((l + 1) <= 1) {
        if (!l)
          ws = 0;
        else
          cnt = l;
        break;
      }
      ws++;
      wn--;
      s += l;
      n -= l;
      cnt += l;
    }
  if (dst)
    *wcs = ws;
  return cnt;
}
```