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

```asm
<copy_bits>:
  endbr64
  mov    %rdi,%r9
  mov    %esi,%edi
  mov    %ecx,%eax
  mov    %ecx,%esi
  mov    %edi,%ecx
  shr    $0x3,%eax
  shr    $0x3,%ecx
  shl    $0x2,%rax
  lea    (%r9,%rcx,4),%r9
  mov    %esi,%ecx
  lea    (%rdx,%rax,1),%r11
  or     %r8d,%ecx
  or     %edi,%ecx
  and    $0x7,%ecx
  je     L6
  mov    %edi,%edx
  and    $0x7,%esi
  and    $0x7,%edx
  test   %r8d,%r8d
  je     L41
  push   %r14
  mov    $0x8,%r10d
  push   %rbx
  mov    $0xff,%ebx
L72:
  mov    %r10d,%ecx
  mov    %r10d,%eax
  mov    (%r11),%edi
  mov    %ebx,%r14d
  sub    %edx,%ecx
  sub    %esi,%eax
  cmp    %edx,%esi
  cmovb  %ecx,%eax
  mov    %esi,%ecx
  cmp    %r8d,%eax
  cmova  %r8d,%eax
  shl    %cl,%edi
  mov    %r10d,%ecx
  sub    %eax,%ecx
  add    %eax,%esi
  shl    %cl,%r14d
  mov    %edx,%ecx
  and    %r14d,%edi
  shr    %cl,%edi
  or     %edi,(%r9)
  cmp    $0x7,%esi
  jbe    L31
  add    $0x4,%r11
  sub    $0x8,%esi
L31:
  add    %eax,%edx
  cmp    $0x7,%edx
  jbe    L111
  add    $0x4,%r9
  sub    $0x8,%edx
L111:
  sub    %eax,%r8d
  jne    L72
  pop    %rbx
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L6:
  mov    %r8d,%ecx
  shr    $0x3,%ecx
  je     L41
  lea    0x4(%rdx,%rax,1),%rdx
  mov    %r9,%rax
  lea    -0x1(%rcx),%esi
  sub    %rdx,%rax
  cmp    $0x8,%rax
  jbe    L59
  cmp    $0x2,%esi
  jbe    L59
  shr    $0x5,%r8d
  xor    %eax,%eax
  mov    %r8d,%edx
  shl    $0x4,%rdx
  xchg   %ax,%ax
L83:
  movdqu (%r11,%rax,1),%xmm0
  movups %xmm0,(%r9,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L83
  lea    0x0(,%r8,4),%eax
  mov    %rax,%r8
  shl    $0x2,%rax
  add    %rax,%r9
  add    %r11,%rax
  cmp    %r8d,%ecx
  je     L41
  mov    (%rax),%edx
  mov    %edx,(%r9)
  sub    %r8d,%esi
  je     L41
  mov    0x4(%rax),%edx
  mov    %edx,0x4(%r9)
  cmp    $0x1,%esi
  je     L41
  mov    0x8(%rax),%eax
  mov    %eax,0x8(%r9)
  ret
  nopl   0x0(%rax)
L41:
  ret
  nopl   0x0(%rax)
L59:
  mov    %ecx,%ecx
  xor    %eax,%eax
  nopl   0x0(%rax)
L17:
  mov    (%r11,%rax,4),%edx
  mov    %edx,(%r9,%rax,4)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L17
  ret
```

assistant: ```c
void copy_bits(uint8_t *out, unsigned int out_pos, const uint8_t *in, unsigned int in_pos, unsigned int length) {
  unsigned int offset, chunk_size;
  uint8_t temp, mask;
  if (((out_pos | in_pos | length) & 0x07) == 0) {
    out += out_pos >> 3;
    in += in_pos >> 3;
    for (length >>= 3; length > 0; length--)
      *out++ = *in++;
    return;
  }
  offset = out_pos / 8;
  out += offset;
  out_pos -= offset * 8;
  offset = in_pos / 8;
  in += offset;
  in_pos -= offset * 8;
  while (length > 0) {
    chunk_size = (in_pos < out_pos) ? 8 - out_pos : 8 - in_pos;
    if (chunk_size == 0)
      chunk_size = 8;
    if (chunk_size > length)
      chunk_size = length;
    temp = (uint8_t)((*in) << in_pos);
    temp >>= out_pos;
    mask = (uint8_t)(0xff << (8 - chunk_size));
    mask = (uint8_t)(mask >> out_pos);
    *out |= mask & temp;
    in_pos += chunk_size;
    if (in_pos >= 8) {
      in++;
      in_pos -= 8;
    }
    out_pos += chunk_size;
    if (out_pos >= 8) {
      out++;
      out_pos -= 8;
    }
    length -= chunk_size;
  }
}
```