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

```asm
<bitcpy>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  mov    %r13d,%r15d
  push   %rbp
  mov    %r13d,%ebp
  and    $0x7,%r15d
  push   %rbx
  mov    %r8,%rbx
  sar    $0x3,%ebp
  movslq %ebp,%rbp
  sub    $0x18,%rsp
  mov    %ecx,0xc(%rsp)
  mov    %rdi,(%rsp)
  call   <assert@plt>
  mov    %r14d,%edi
  call   <assert@plt>
  mov    $0x1,%edi
  call   <assert@plt>
  mov    0xc(%rsp),%ecx
  mov    (%rsp),%r10
  mov    %ecx,%r12d
  mov    %ecx,%r9d
  or     %ecx,%r13d
  add    %r10,%rbp
  sar    $0x3,%r12d
  and    $0x7,%r9d
  movslq %r12d,%r12
  add    %r14,%r12
  and    $0x7,%r13d
  jne    L60
  test   $0x7,%bl
  je     L82
L60:
  movslq %r9d,%rax
  add    %rbx,%rax
  cmp    $0x37,%rax
  jbe    L74
  cmp    %r9d,%r15d
  je     L12
L50:
  test   %r15d,%r15d
  jne    L75
  test   $0x3,%bpl
  jne    L75
L118:
  lea    0x0(,%rbp,8),%r14d
  lea    0x0(,%r12,8),%r8d
  xor    %edi,%edi
  mov    %ebx,%r13d
  and    $0x18,%r8d
  and    $0x18,%r14d
  and    $0xfffffffffffffffc,%rbp
  and    $0xfffffffffffffffc,%r12
  or     %r9d,%r8d
  or     %r15d,%r14d
  sete   %dil
  mov    %r8d,(%rsp)
  call   <assert@plt>
  mov    $0x1,%edi
  call   <assert@plt>
  and    $0xffffffe0,%r13d
  mov    (%rsp),%r8d
  jne    L116
L23:
  lea    (%r8,%r13,1),%edx
  lea    (%r14,%r13,1),%edi
  mov    %r8d,%ecx
  mov    %r14d,%esi
  sar    $0x3,%edx
  sar    $0x3,%edi
  mov    %ebx,%r8d
  and    $0x7,%ecx
  movslq %edx,%rdx
  movslq %edi,%rdi
  and    $0x7,%esi
  sub    %r13d,%r8d
  add    %r12,%rdx
  add    %rbp,%rdi
L78:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <_bitcpy_short@plt>
  cs nopw 0x0(%rax,%rax,1)
L75:
  lea    0x0(,%rbp,8),%eax
  mov    $0x1,%edi
  mov    $0x20,%r13d
  mov    %r9d,(%rsp)
  and    $0x18,%eax
  or     %r15d,%eax
  sub    %eax,%r13d
  call   <assert@plt>
  mov    (%rsp),%ecx
  mov    %r12,%rdx
  mov    %r15d,%esi
  mov    %rbp,%rdi
  mov    %r13d,%r8d
  sub    %r13,%rbx
  call   <_bitcpy_short@plt>
  mov    (%rsp),%r9d
  lea    (%r15,%r13,1),%edx
  mov    %edx,%r15d
  sar    $0x3,%edx
  lea    (%r9,%r13,1),%eax
  movslq %edx,%rdx
  and    $0x7,%r15d
  mov    %eax,%r9d
  sar    $0x3,%eax
  add    %rdx,%rbp
  cltq
  and    $0x7,%r9d
  add    %rax,%r12
  jmp    L118
  nopl   0x0(%rax,%rax,1)
L116:
  mov    %r13d,%eax
  mov    %r8d,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  sar    $0x5,%eax
  cltq
  lea    (%r12,%rax,4),%rcx
  call   <_bitcpy_aligned@plt>
  mov    (%rsp),%r8d
  jmp    L23
  nopl   0x0(%rax,%rax,1)
L74:
  mov    %ebx,%r8d
  mov    %r9d,%ecx
  mov    %r12,%rdx
  mov    %r15d,%esi
  mov    %rbp,%rdi
  jmp    L78
  nopl   0x0(%rax)
L82:
  mov    %rbx,%rdx
  mov    %r14,%rsi
  mov    %r10,%rdi
  mov    %r9d,(%rsp)
  shr    $0x3,%rdx
  call   <memcpy@plt>
  mov    (%rsp),%r9d
  jmp    L60
  nop
L12:
  mov    $0x8,%r13d
  mov    %r15d,%ecx
  mov    %r12,%rdx
  mov    %rbp,%rdi
  sub    %r15d,%r13d
  mov    %r15d,%esi
  add    $0x1,%rbp
  add    $0x1,%r12
  mov    %r13d,%r8d
  movslq %r13d,%r13
  mov    %r9d,(%rsp)
  call   <_bitcpy_short@plt>
  sub    %r13,%rbx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  mov    %rbx,%r13
  shr    $0x3,%r13
  mov    %r13d,%edx
  movslq %r13d,%r13
  call   <memcpy@plt>
  mov    %ebx,%r8d
  lea    0x0(%r13,%r12,1),%rdx
  xor    %ecx,%ecx
  lea    0x0(%r13,%rbp,1),%rdi
  and    $0x7,%r8d
  xor    %esi,%esi
  call   <_bitcpy_short@plt>
  mov    (%rsp),%r9d
  jmp    L50
```

assistant: ```c
void bitcpy(void *dest, int destn, const void *src, int srcn, size_t nbits) {
  assert(dest);
  assert(src);
  assert(0 <= nbits);
  uintptr_t a = (uintptr_t)dest;
  uintptr_t b = (uintptr_t)src;
  a += destn >> 3;
  b += srcn >> 3;
  destn &= 7;
  srcn &= 7;
  if (!destn && !srcn && !(nbits & 7)) {
    memcpy(dest, src, nbits >> 3);
  }
  if (srcn + nbits < 56) {
    _bitcpy_short((unsigned char *)a, destn, (unsigned char *)b, srcn, (int)nbits);
    return;
  }
  if (srcn == destn) {
    int m = 8 - srcn;
    _bitcpy_short((unsigned char *)a, destn, (unsigned char *)b, srcn, m);
    ++a;
    ++b;
    nbits -= m;
    int p = (int)(nbits >> 3);
    memcpy((void *)a, (void *)b, p);
    _bitcpy_short((unsigned char *)a + p, 0, (unsigned char *)b + p, 0, nbits & 7);
  }
  int m = 0;
  if (destn || (a & 3)) {
    m = (int)(32 - (destn + ((a & 3) << 3)));
    assert(m < nbits);
    _bitcpy_short((unsigned char *)a, destn, (unsigned char *)b, srcn, m);
    destn += m;
    srcn += m;
    nbits -= m;
  }
  a += destn >> 3;
  b += srcn >> 3;
  destn = (destn & 7) | (((int)a & 3) << 3);
  srcn = (srcn & 7) | (((int)b & 3) << 3);
  a &= ~3;
  b &= ~3;
  assert(!destn);
  assert((0 <= srcn) && (srcn < 32));
  int p = (int)nbits & ~31;
  if (p) {
    _bitcpy_aligned((int *)a, (const int *)b, srcn, ((const int *)b) + (p >> 5));
  }
  nbits -= p;
  destn += p;
  srcn += p;
  a += destn >> 3;
  b += srcn >> 3;
  destn &= 7;
  srcn &= 7;
  _bitcpy_short((unsigned char *)a, destn, (unsigned char *)b, srcn, (int)nbits);
}
```