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

```asm
<mbsnrtowcs>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  sub    $0x458,%rsp
  mov    (%rsi),%rdx
  mov    %rdi,0x18(%rsp)
  mov    %rsi,0x20(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x448(%rsp)
  xor    %eax,%eax
  mov    %rdx,0x38(%rsp)
  test   %rdi,%rdi
  je     L53
  test   %rcx,%rcx
  mov    %rcx,%rbx
  mov    %rdi,%r14
  setne  %cl
L9:
  test   %rdx,%rdx
  setne  %al
  and    %cl,%al
  mov    %al,0x2f(%rsp)
  je     L182
  movq   $0x0,0x8(%rsp)
  mov    %r13,%rdx
  shr    $0x2,%rdx
  cmp    $0x83,%r13
  ja     L132
  cmp    %rdx,%rbx
  ja     L174
L132:
  lea    0x40(%rsp),%rax
  lea    0x38(%rsp),%r12
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L24:
  cmp    %rdx,%rbx
  mov    %rbp,%rcx
  mov    %r12,%rsi
  mov    %r14,%rdi
  cmovbe %rbx,%rdx
  sub    %rdx,%r13
  call   <mbsrtowcs@plt>
  mov    %rax,%r15
  cmp    $0xffffffffffffffff,%rax
  je     L112
  cmp    0x10(%rsp),%r14
  je     L179
  lea    (%r14,%rax,4),%r14
  sub    %rax,%rbx
L179:
  add    %r15,0x8(%rsp)
  mov    0x38(%rsp),%rdx
  test   %rbx,%rbx
  setne  %al
  mov    %eax,%ecx
  test   %rdx,%rdx
  je     L129
  test   %al,%al
  je     L64
  mov    %r13,%rdx
  shr    $0x2,%rdx
  cmp    %rdx,%rbx
  jbe    L24
  cmp    $0x83,%r13
  ja     L24
L174:
  movzbl 0x2f(%rsp),%ecx
L204:
  test   %r13,%r13
  je     L129
  test   %cl,%cl
  je     L129
  mov    0x8(%rsp),%r15
  mov    0x38(%rsp),%rsi
  add    %r15,%rbx
  jmp    L113
  nopl   0x0(%rax,%rax,1)
L55:
  mov    0x38(%rsp),%rsi
  add    $0x1,%r15
  sub    %rax,%r13
  add    $0x4,%r14
  add    %rax,%rsi
  mov    %rsi,0x38(%rsp)
  cmp    %r15,%rbx
  je     L112
  test   %r13,%r13
  je     L112
L113:
  mov    %r13,%rdx
  mov    %rbp,%rcx
  mov    %r14,%rdi
  call   <mbrtowc@plt>
  lea    0x2(%rax),%rdx
  cmp    $0x2,%rdx
  ja     L55
  cmp    $0xffffffffffffffff,%rax
  je     L14
  movl   $0x0,0x0(%rbp)
L112:
  cmpq   $0x0,0x18(%rsp)
  je     L167
  mov    0x38(%rsp),%rax
  mov    0x20(%rsp),%rdi
  mov    %rax,(%rdi)
L167:
  mov    0x448(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L124
  add    $0x458,%rsp
  mov    %r15,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L53:
  mov    $0x1,%ecx
  lea    0x40(%rsp),%r14
  mov    $0x100,%ebx
  jmp    L9
L182:
  movq   $0x0,0x8(%rsp)
  nopl   (%rax)
L64:
  test   %rdx,%rdx
  jne    L204
L129:
  mov    0x8(%rsp),%r15
  jmp    L112
L14:
  mov    $0xffffffffffffffff,%r15
  jmp    L112
L124:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t mbsnrtowcs(wchar_t *wcs, const char **src, size_t n, size_t wn, mbstate_t *st) {
  size_t l, cnt = 0, n2;
  wchar_t *ws, wbuf[256];
  const char *s = *src;
  if (!wcs)
    ws = wbuf, wn = sizeof wbuf / sizeof *wbuf;
  else
    ws = wcs;
  while (s && wn && ((n2 = n / 4) >= wn || n2 > 32)) {
    if (n2 >= wn)
      n2 = wn;
    n -= n2;
    l = mbsrtowcs(ws, &s, n2, st);
    if (!(l + 1)) {
      cnt = l;
      wn = 0;
      break;
    }
    if (ws != wbuf) {
      ws += l;
      wn -= l;
    }
    cnt += l;
  }
  if (s)
    while (wn && n) {
      l = mbrtowc(ws, s, n, st);
      if (l + 2 <= 2) {
        if (!(l + 1)) {
          cnt = l;
          break;
        }
        *(unsigned *)st = 0;
        break;
      }
      s += l;
      n -= l;
      ws++;
      wn--;
      cnt++;
    }
  if (wcs)
    *src = s;
  return cnt;
}
```