user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<random_bits>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  and    $0x7,%eax
  test   %eax,%eax
  je     L29
  mov    -0x1c(%rbp),%eax
  and    $0x7,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  not    %eax
  mov    %al,-0x6(%rbp)
  mov    -0x1c(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  and    -0x6(%rbp),%al
  mov    %al,(%rdx)
  mov    $0x0,%eax
  call   <random@plt>
  mov    %eax,%edx
  movzbl -0x6(%rbp),%eax
  not    %eax
  movzbl %al,%eax
  mov    %edx,%esi
  and    %eax,%esi
  mov    -0x1c(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  movslq %eax,%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rdx),%edx
  mov    %edx,%ecx
  mov    %esi,%edx
  or     %edx,%ecx
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
L29:
  mov    -0x1c(%rbp),%eax
  add    $0x7,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L23
L24:
  mov    $0x0,%eax
  call   <random@plt>
  movslq %eax,%rdx
  imul   $0xffffffff80808081,%rdx,%rdx
  shr    $0x20,%rdx
  add    %eax,%edx
  sar    $0x7,%edx
  mov    %eax,%esi
  sar    $0x1f,%esi
  mov    %edx,%ecx
  sub    %esi,%ecx
  mov    %ecx,%edx
  shl    $0x8,%edx
  sub    %ecx,%edx
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x4(%rbp)
L23:
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  cmp    %eax,-0x4(%rbp)
  jl     L24
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  and    $0x7,%eax
  test   %eax,%eax
  je     L9
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  and    $0x7,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x5(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  and    -0x5(%rbp),%al
  mov    %al,(%rdx)
  mov    $0x0,%eax
  call   <random@plt>
  mov    %eax,%edx
  movzbl -0x5(%rbp),%eax
  not    %eax
  movzbl %al,%eax
  mov    %edx,%esi
  and    %eax,%esi
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  movslq %eax,%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rdx),%edx
  mov    %edx,%ecx
  mov    %esi,%edx
  or     %edx,%ecx
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
L9:
  nop
  leave
  ret
```

assistant: ```c
void random_bits(unsigned char *buf, int first, int len) {
  int i;
  if (first % 8 != 0) {
    unsigned char mask = (0xFF >> (first % 8)) ^ 0xFF;
    buf[first / 8] &= mask;
    buf[first / 8] |= random() & (0xFF ^ mask);
  }
  for (i = (first + 7) / 8; i < (first + len) / 8; i++)
    buf[i] = random() % 0xFF;
  if ((first + len) % 8 != 0) {
    unsigned char mask = 0xFF >> ((first + len) % 8);
    buf[(first + len) / 8] &= mask;
    buf[(first + len) / 8] |= random() & (0xFF ^ mask);
  }
}
```