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

```asm
<copy_bits>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    %r8d,-0x2c(%rbp)
  mov    -0x1c(%rbp),%eax
  or     -0x20(%rbp),%eax
  or     -0x2c(%rbp),%eax
  and    $0x7,%eax
  test   %eax,%eax
  jne    L10
  mov    -0x1c(%rbp),%eax
  shr    $0x3,%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x3,%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rax,-0x28(%rbp)
  shrl   $0x3,-0x2c(%rbp)
  jmp    L73
L14:
  mov    -0x28(%rbp),%rdx
  lea    0x4(%rdx),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rcx
  mov    %rcx,-0x18(%rbp)
  mov    (%rdx),%edx
  mov    %edx,(%rax)
  subl   $0x1,-0x2c(%rbp)
L73:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L14
  jmp    L7
L10:
  mov    -0x1c(%rbp),%eax
  shr    $0x3,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  shl    $0x2,%rax
  add    %rax,-0x18(%rbp)
  mov    -0xc(%rbp),%eax
  shl    $0x3,%eax
  sub    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x3,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  shl    $0x2,%rax
  add    %rax,-0x28(%rbp)
  mov    -0xc(%rbp),%eax
  shl    $0x3,%eax
  sub    %eax,-0x20(%rbp)
  jmp    L109
L101:
  mov    -0x20(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jae    L17
  mov    $0x8,%eax
  sub    -0x1c(%rbp),%eax
  jmp    L65
L17:
  mov    $0x8,%eax
  sub    -0x20(%rbp),%eax
L65:
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jne    L55
  movl   $0x8,-0x10(%rbp)
L55:
  mov    -0x10(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jbe    L91
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
L91:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  shrl   %cl,-0x8(%rbp)
  mov    $0x8,%eax
  sub    -0x10(%rbp),%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  shrl   %cl,-0x4(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  and    -0x8(%rbp),%eax
  or     %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%eax
  add    %eax,-0x20(%rbp)
  cmpl   $0x7,-0x20(%rbp)
  jbe    L45
  addq   $0x4,-0x28(%rbp)
  subl   $0x8,-0x20(%rbp)
L45:
  mov    -0x10(%rbp),%eax
  add    %eax,-0x1c(%rbp)
  cmpl   $0x7,-0x1c(%rbp)
  jbe    L4
  addq   $0x4,-0x18(%rbp)
  subl   $0x8,-0x1c(%rbp)
L4:
  mov    -0x10(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
L109:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L101
L7:
  pop    %rbp
  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;
  }
}
```