user: Demonstrate the C code that generates the assembly output below:

```asm
<wcsnrtombs>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x148,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  mov    (%rsi),%rax
  mov    %rax,0x8(%rsp)
  mov    %rax,0x28(%rsp)
  test   %rdi,%rdi
  je     L200
  mov    %rcx,%r12
  mov    %rdi,%r13
L239:
  cmpq   $0x0,0x8(%rsp)
  je     L24
  test   %r12,%r12
  je     L24
  cmp    $0x20,%rbp
  ja     L108
  cmp    %r12,%rbp
  jb     L248
L108:
  mov    $0x0,%r14d
  lea    0x28(%rsp),%r15
  jmp    L142
L200:
  lea    0x30(%rsp),%r13
  mov    $0x100,%r12d
  jmp    L239
L31:
  mov    %rax,0x8(%rsp)
L142:
  cmp    %r12,%rbp
  mov    %r12,%rdx
  cmovbe %rbp,%rdx
  mov    $0x0,%ecx
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <wcsrtombs@plt>
  mov    %rax,%rbx
  cmp    $0xffffffffffffffff,%rax
  je     L93
  lea    0x30(%rsp),%rax
  cmp    %rax,%r13
  je     L299
  add    %rbx,%r13
  sub    %rbx,%r12
L88:
  mov    0x28(%rsp),%rax
  test   %rax,%rax
  je     L227
  mov    %rax,%rdx
  sub    0x8(%rsp),%rdx
  sar    $0x2,%rdx
  sub    %rdx,%rbp
  add    %rbx,%r14
  test   %r12,%r12
  je     L123
  cmp    $0x20,%rbp
  ja     L31
  cmp    %rbp,%r12
  jbe    L31
L256:
  mov    %r14,%rbx
  jmp    L247
L299:
  lea    0x30(%rsp),%r13
  jmp    L88
L24:
  cmpq   $0x0,0x28(%rsp)
  je     L184
  mov    $0x0,%ebx
L247:
  test   %r12,%r12
  je     L93
  test   %rbp,%rbp
  je     L93
L235:
  mov    $0x0,%edx
  mov    0x28(%rsp),%rax
  mov    (%rax),%esi
  mov    %r13,%rdi
  call   <wcrtomb@plt>
  lea    0x1(%rax),%rdx
  cmp    $0x1,%rdx
  jbe    L246
  addq   $0x4,0x28(%rsp)
  sub    $0x1,%rbp
  add    %rax,%r13
  add    %rax,%rbx
  sub    %rax,%r12
  je     L93
  test   %rbp,%rbp
  jne    L235
  jmp    L93
L123:
  mov    %r14,%rbx
  jmp    L247
L246:
  test   %rax,%rax
  jne    L170
  movq   $0x0,0x28(%rsp)
  jmp    L93
L184:
  mov    $0x0,%ebx
  jmp    L93
L170:
  mov    %rax,%rbx
  jmp    L93
L248:
  mov    $0x0,%r14d
  jmp    L256
L227:
  add    %r14,%rbx
L93:
  cmpq   $0x0,0x10(%rsp)
  je     L48
  mov    0x28(%rsp),%rax
  mov    0x18(%rsp),%rcx
  mov    %rax,(%rcx)
L48:
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L164
  mov    %rbx,%rax
  add    $0x148,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L164:
  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;
}
```