user: Converte this assembly snippet into its equivalent C code:

```asm
<RandomFunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  shr    $0x3,%rax
  or     $0xbab5,%ax
  mov    %ax,-0xa(%rbp)
  movw   $0x0,-0xc(%rbp)
  jmp    L20
L8:
  movzwl -0xa(%rbp),%eax
  cmp    %ax,-0xc(%rbp)
  jae    L76
  movzwl -0xa(%rbp),%eax
  cmp    %ax,-0xc(%rbp)
  jae    L74
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%edx
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%eax
  and    $0x6,%eax
  or     $0x1,%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  movzwl -0xc(%rbp),%eax
  cltq
  mov    %dx,-0xa(%rbp,%rax,2)
  jmp    L74
L76:
  movzwl -0xa(%rbp),%eax
  cmp    %ax,-0xc(%rbp)
  jb     L78
  movzwl -0xc(%rbp),%eax
  lea    -0xa(%rbp),%rdx
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0xd(%rbp)
  movzwl -0xc(%rbp),%eax
  lea    -0xa(%rbp),%rdx
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  add    $0x1,%rax
  movzwl -0xc(%rbp),%edx
  lea    -0xa(%rbp),%rcx
  movslq %edx,%rdx
  add    %rdx,%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  movzwl -0xc(%rbp),%eax
  lea    -0xa(%rbp),%rdx
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  lea    0x1(%rax),%rdx
  movzbl -0xd(%rbp),%eax
  mov    %al,(%rdx)
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%edx
  movzwl -0xa(%rbp),%eax
  shr    %ax
  movzwl %ax,%eax
  and    $0x6,%eax
  or     $0x1,%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  movzwl -0xc(%rbp),%eax
  cltq
  mov    %dx,-0xa(%rbp,%rax,2)
  jmp    L74
L78:
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%edx
  movzwl -0xa(%rbp),%eax
  shr    $0x2,%ax
  movzwl %ax,%eax
  and    $0x6,%eax
  or     $0x1,%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  movzwl -0xc(%rbp),%eax
  cltq
  mov    %dx,-0xa(%rbp,%rax,2)
L74:
  addw   $0x2,-0xc(%rbp)
L20:
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0xc(%rbp)
  jb     L8
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%eax
  shr    $0x5,%rax
  and    $0xed6,%ax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %dx,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L35
  call   <__stack_chk_fail@plt>
L35:
  leave
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local1;
  char copy14;
  {
    state[0UL] = (input[0UL] | 51238316UL) >> (unsigned short)3;
    local1 = 0UL;
    while (local1 < input[1UL]) {
      if (state[0UL] > local1) {
        if (state[0UL] > local1) {
          state[local1] = state[0UL] >> ((state[0UL] & (unsigned short)7) | 1UL);
        }
      } else if (state[0UL] <= local1) {
        copy14 = *((char *)(&state[local1]) + 0);
        *((char *)(&state[local1]) + 0) = *((char *)(&state[local1]) + 1);
        *((char *)(&state[local1]) + 1) = copy14;
        state[local1] = state[0UL] >> (((state[0UL] >> (unsigned short)1) & (unsigned short)7) | 1UL);
      } else {
        state[local1] = state[0UL] >> (((state[0UL] >> (unsigned short)2) & (unsigned short)7) | 1UL);
      }
      local1 += 2UL;
    }
    output[0UL] = (state[0UL] & 237099718UL) >> (unsigned short)5;
  }
}
```