user: Translate the below assembly code into C programming language:

```asm
<wcsnrtombs>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x170,%rsp
  mov    %rdi,-0x148(%rbp)
  mov    %rsi,-0x150(%rbp)
  mov    %rdx,-0x158(%rbp)
  mov    %rcx,-0x160(%rbp)
  mov    %r8,-0x168(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x138(%rbp)
  mov    -0x150(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x140(%rbp)
  cmpq   $0x0,-0x148(%rbp)
  jne    L79
  lea    -0x110(%rbp),%rax
  mov    %rax,-0x128(%rbp)
  movq   $0x100,-0x160(%rbp)
  jmp    L51
L79:
  mov    -0x148(%rbp),%rax
  mov    %rax,-0x128(%rbp)
  jmp    L51
L181:
  mov    -0x130(%rbp),%rax
  cmp    -0x160(%rbp),%rax
  jb     L119
  mov    -0x160(%rbp),%rax
  mov    %rax,-0x130(%rbp)
L119:
  mov    -0x140(%rbp),%rax
  mov    %rax,-0x120(%rbp)
  mov    -0x130(%rbp),%rdx
  lea    -0x140(%rbp),%rsi
  mov    -0x128(%rbp),%rax
  mov    $0x0,%ecx
  mov    %rax,%rdi
  call   <wcsrtombs@plt>
  mov    %rax,-0x118(%rbp)
  cmpq   $0xffffffffffffffff,-0x118(%rbp)
  jne    L69
  mov    -0x118(%rbp),%rax
  mov    %rax,-0x138(%rbp)
  movq   $0x0,-0x160(%rbp)
  jmp    L126
L69:
  lea    -0x110(%rbp),%rax
  cmp    %rax,-0x128(%rbp)
  je     L183
  mov    -0x118(%rbp),%rax
  add    %rax,-0x128(%rbp)
  mov    -0x118(%rbp),%rax
  sub    %rax,-0x160(%rbp)
L183:
  mov    -0x140(%rbp),%rax
  test   %rax,%rax
  je     L94
  mov    -0x140(%rbp),%rax
  sub    -0x120(%rbp),%rax
  sar    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x158(%rbp),%rax
  sub    %rdx,%rax
  jmp    L145
L94:
  mov    $0x0,%eax
L145:
  mov    %rax,-0x158(%rbp)
  mov    -0x118(%rbp),%rax
  add    %rax,-0x138(%rbp)
L51:
  mov    -0x140(%rbp),%rax
  test   %rax,%rax
  je     L126
  cmpq   $0x0,-0x160(%rbp)
  je     L126
  mov    -0x158(%rbp),%rax
  mov    %rax,-0x130(%rbp)
  mov    -0x130(%rbp),%rax
  cmp    -0x160(%rbp),%rax
  jae    L181
  cmpq   $0x20,-0x130(%rbp)
  ja     L181
L126:
  mov    -0x140(%rbp),%rax
  test   %rax,%rax
  je     L132
  jmp    L80
L123:
  mov    -0x140(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x128(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <wcrtomb@plt>
  mov    %rax,-0x118(%rbp)
  mov    -0x118(%rbp),%rax
  add    $0x1,%rax
  cmp    $0x1,%rax
  ja     L70
  cmpq   $0x0,-0x118(%rbp)
  jne    L147
  movq   $0x0,-0x140(%rbp)
  jmp    L132
L147:
  mov    -0x118(%rbp),%rax
  mov    %rax,-0x138(%rbp)
  jmp    L132
L70:
  mov    -0x140(%rbp),%rax
  add    $0x4,%rax
  mov    %rax,-0x140(%rbp)
  subq   $0x1,-0x158(%rbp)
  mov    -0x118(%rbp),%rax
  add    %rax,-0x128(%rbp)
  mov    -0x118(%rbp),%rax
  sub    %rax,-0x160(%rbp)
  mov    -0x118(%rbp),%rax
  add    %rax,-0x138(%rbp)
L80:
  cmpq   $0x0,-0x160(%rbp)
  je     L132
  cmpq   $0x0,-0x158(%rbp)
  jne    L123
L132:
  cmpq   $0x0,-0x148(%rbp)
  je     L85
  mov    -0x140(%rbp),%rdx
  mov    -0x150(%rbp),%rax
  mov    %rdx,(%rax)
L85:
  mov    -0x138(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L163
  call   <__stack_chk_fail@plt>
L163:
  leave
  ret
```

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;
}
```