user: 请将以下的汇编代码转换成C语言代码：

```asm
<CopyBits>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rsi,-0x20(%rbp)
  mov    %ecx,%eax
  mov    %r8,-0x30(%rbp)
  mov    %r9d,%r8d
  mov    0x10(%rbp),%ecx
  mov    %edi,%esi
  mov    %sil,-0x14(%rbp)
  mov    %dl,-0x18(%rbp)
  mov    %al,-0x24(%rbp)
  mov    %r8d,%eax
  mov    %al,-0x28(%rbp)
  mov    %ecx,%eax
  mov    %al,-0x34(%rbp)
  jmp    L81
L36:
  movzbl -0x28(%rbp),%eax
  sub    -0x18(%rbp),%al
  mov    %al,-0x6(%rbp)
  cmpb   $0x0,-0x6(%rbp)
  jle    L103
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  movsbl -0x6(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  jmp    L98
L103:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  movsbl -0x6(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
L98:
  mov    %al,-0x5(%rbp)
  cmpb   $0x0,-0x6(%rbp)
  jle    L94
  mov    $0x8,%eax
  sub    -0x28(%rbp),%al
  jmp    L106
L94:
  mov    $0x8,%eax
  sub    -0x18(%rbp),%al
L106:
  mov    %al,-0x4(%rbp)
  movzbl -0x4(%rbp),%edx
  movzbl -0x14(%rbp),%eax
  cmp    %al,%dl
  cmovbe %edx,%eax
  mov    %al,-0x3(%rbp)
  movzbl -0x28(%rbp),%edx
  movzbl -0x3(%rbp),%eax
  add    %edx,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,%esi
  movzbl -0x28(%rbp),%edx
  mov    $0x8,%eax
  sub    %edx,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  or     %esi,%eax
  mov    %al,-0x2(%rbp)
  movzbl -0x2(%rbp),%eax
  not    %eax
  mov    %eax,%edx
  movzbl -0x5(%rbp),%eax
  and    %edx,%eax
  mov    %al,-0x1(%rbp)
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  and    -0x2(%rbp),%al
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  or     -0x1(%rbp),%al
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %dl,(%rax)
  movzbl -0x3(%rbp),%eax
  add    %al,-0x18(%rbp)
  cmpb   $0x7,-0x18(%rbp)
  jbe    L43
  movb   $0x0,-0x18(%rbp)
  cmpb   $0x0,-0x24(%rbp)
  je     L117
  mov    $0xffffffffffffffff,%rax
  jmp    L13
L117:
  mov    $0x1,%eax
L13:
  add    %rax,-0x20(%rbp)
L43:
  movzbl -0x3(%rbp),%eax
  add    %al,-0x28(%rbp)
  cmpb   $0x7,-0x28(%rbp)
  jbe    L28
  movb   $0x0,-0x28(%rbp)
  cmpb   $0x0,-0x34(%rbp)
  je     L73
  mov    $0xffffffffffffffff,%rax
  jmp    L104
L73:
  mov    $0x1,%eax
L104:
  add    %rax,-0x30(%rbp)
L28:
  movzbl -0x3(%rbp),%eax
  sub    %al,-0x14(%rbp)
L81:
  cmpb   $0x0,-0x14(%rbp)
  jne    L36
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void CopyBits(unsigned char NbBits, unsigned char *SrcByteIndex, unsigned char SrcBitIndex, unsigned char SrcBigEndian, unsigned char *DestByteIndex, unsigned char DestBitIndex, unsigned char DestBigEndian) {
  while (NbBits > 0) {
    signed char Vect = DestBitIndex - SrcBitIndex;
    unsigned char Aligned = Vect > 0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect;
    unsigned char BoudaryLimit = (Vect > 0 ? 8 - DestBitIndex : 8 - SrcBitIndex);
    unsigned char BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit;
    unsigned char Mask = ((0xff << (DestBitIndex + BitsToCopy)) | (0xff >> (8 - DestBitIndex)));
    unsigned char Filtered = Aligned & ~Mask;
    *DestByteIndex &= Mask;
    *DestByteIndex |= Filtered;
    if ((SrcBitIndex += BitsToCopy) > 7) {
      SrcBitIndex = 0;
      SrcByteIndex += (SrcBigEndian ? -1 : 1);
    }
    if ((DestBitIndex += BitsToCopy) > 7) {
      DestBitIndex = 0;
      DestByteIndex += (DestBigEndian ? -1 : 1);
    }
    NbBits -= BitsToCopy;
  }
}
```