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

```asm
<crypthead>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %r9d,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0xb,-0x34(%rbp)
  jg     L21
  mov    $0x0,%eax
  jmp    L4
L21:
  mov    D21(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D9(%rip)
  mov    D9(%rip),%eax
  cmp    $0x1,%eax
  jne    L69
  mov    $0x0,%edi
  call   <time@plt>
  xor    $0xbb40e64e,%eax
  mov    %eax,%edi
  call   <srand@plt>
L69:
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <init_keys@plt>
  movl   $0x0,-0x20(%rbp)
  jmp    L55
L28:
  mov    $0x0,%eax
  call   <rand@plt>
  sar    $0x7,%eax
  and    $0xff,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <decrypt_byte@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <update_keys@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  xor    %edx,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  cltq
  mov    %dl,-0x12(%rbp,%rax,1)
  addl   $0x1,-0x20(%rbp)
L55:
  cmpl   $0x9,-0x20(%rbp)
  jle    L28
  mov    -0x48(%rbp),%rdx
  mov    -0x40(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <init_keys@plt>
  movl   $0x0,-0x20(%rbp)
  jmp    L22
L0:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <decrypt_byte@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  movzbl -0x12(%rbp,%rax,1),%eax
  movzbl %al,%edx
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <update_keys@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  cltq
  movzbl -0x12(%rbp,%rax,1),%eax
  mov    %edx,%ecx
  xor    %eax,%ecx
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x20(%rbp)
L22:
  cmpl   $0x9,-0x20(%rbp)
  jle    L0
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <decrypt_byte@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x38(%rbp),%eax
  shr    $0x10,%eax
  movzbl %al,%edx
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <update_keys@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  shr    $0x10,%eax
  mov    %edx,%ecx
  xor    %eax,%ecx
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <decrypt_byte@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x38(%rbp),%eax
  shr    $0x18,%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <update_keys@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  shr    $0x18,%eax
  mov    %edx,%ecx
  xor    %eax,%ecx
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x20(%rbp),%eax
L4:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L52
  call   <__stack_chk_fail@plt>
L52:
  leave
  ret
```

assistant: ```c
int crypthead(const char *passwd, unsigned char *buf, int bufSize, unsigned int *pkeys, const unsigned int *pcrc_32_tab, unsigned int crcForCrypting) {
  int n;
  int t;
  int c;
  unsigned char header[12 - 2];
  static unsigned calls = 0;
  if (bufSize < 12)
    return 0;
  if (++calls == 1) {
    srand((unsigned)(time(NULL) ^ 3141592654UL));
  }
  init_keys(passwd, pkeys, pcrc_32_tab);
  for (n = 0; n < 12 - 2; n++) {
    c = (rand() >> 7) & 0xff;
    header[n] = (unsigned char)(t = decrypt_byte(pkeys), update_keys(pkeys, pcrc_32_tab, c), t ^ (c));
  }
  init_keys(passwd, pkeys, pcrc_32_tab);
  for (n = 0; n < 12 - 2; n++) {
    buf[n] = (unsigned char)(t = decrypt_byte(pkeys), update_keys(pkeys, pcrc_32_tab, header[n]), t ^ (header[n]));
  }
  buf[n++] = (unsigned char)(t = decrypt_byte(pkeys), update_keys(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff), t ^ ((int)(crcForCrypting >> 16) & 0xff));
  buf[n++] = (unsigned char)(t = decrypt_byte(pkeys), update_keys(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff), t ^ ((int)(crcForCrypting >> 24) & 0xff));
  return n;
}
```