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

```asm
<rt_modbus_read_input_table>:
  endbr64
  push   %r12
  lea    0x8(%rdi),%rsi
  mov    $0x2,%edx
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r12
  mov    %r12,%rdi
  call   <memcpy@plt>
  mov    %r12,%rdi
  lea    0x4(%rsp),%r12
  call   <swap16@plt>
  lea    0x10(%rbp),%rsi
  mov    $0x2,%edx
  mov    %r12,%rdi
  call   <memcpy@plt>
  mov    %r12,%rdi
  call   <swap16@plt>
  mov    0x4(%rsp),%esi
  cmp    $0x80,%esi
  jg     L102
  test   %esi,%esi
  lea    0x7(%rsi),%r8d
  mov    %esi,%edx
  cmovns %esi,%r8d
  sar    $0x1f,%edx
  shr    $0x1d,%edx
  lea    (%rsi,%rdx,1),%eax
  sar    $0x3,%r8d
  and    $0x7,%eax
  sub    %edx,%eax
  lea    0xc(%rbp),%rdx
  test   %eax,%eax
  setg   %al
  movzbl %al,%eax
  add    %eax,%r8d
  mov    %r8d,0x8(%rbp)
  test   %r8d,%r8d
  jle    L27
  movslq %r8d,%rax
  shl    $0x2,%rax
  cmp    $0x8,%eax
  jae    L121
  test   $0x4,%al
  jne    L31
  test   %eax,%eax
  jne    L92
L27:
  test   %esi,%esi
  jle    L73
  xor    %eax,%eax
  mov    $0x1,%edi
  nopl   (%rax)
L11:
  test   $0x1,%al
  jne    L41
  mov    %eax,%edx
  mov    %eax,%ecx
  mov    %edi,%r9d
  sar    $0x3,%edx
  and    $0x7,%ecx
  add    $0x3,%edx
  shl    %cl,%r9d
  movslq %edx,%rdx
  or     %r9d,0x0(%rbp,%rdx,4)
L41:
  add    $0x1,%eax
  cmp    %eax,%esi
  jne    L11
L73:
  lea    0x5(%r8),%r12d
  mov    $0xffff,%edx
  mov    %rbp,%rdi
  mov    %r12d,%esi
  call   <add_CRC@plt>
L94:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L121:
  lea    0x14(%rbp),%rdi
  mov    %eax,%ecx
  movq   $0x0,0xc(%rbp)
  movq   $0x0,-0x8(%rdx,%rcx,1)
  and    $0xfffffffffffffff8,%rdi
  sub    %rdi,%rdx
  lea    (%rax,%rdx,1),%ecx
  mov    %ecx,%eax
  shr    $0x3,%eax
  mov    %eax,%ecx
  xor    %eax,%eax
  rep stos %rax,%es:(%rdi)
  jmp    L27
  nopw   0x0(%rax,%rax,1)
L92:
  movb   $0x0,0xc(%rbp)
  jmp    L27
  nopl   0x0(%rax)
L102:
  mov    $0xffff,%edx
  mov    $0x5,%esi
  mov    %rbp,%rdi
  movabs $0x400000082,%rax
  mov    %rax,0x4(%rbp)
  mov    $0x5,%r12d
  call   <add_CRC@plt>
  jmp    L94
L31:
  mov    %eax,%eax
  movl   $0x0,0xc(%rbp)
  movl   $0x0,-0x4(%rdx,%rax,1)
  jmp    L27
L40:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int rt_modbus_read_input_table(uint8_t *buf, int n) {
  uint16_t start_point;
  uint16_t num_points;
  int byte_count;
  uint8_t *p;
  int i;
  uint8_t val;
  int byte, bito;
  uint8_t mask;
  memcpy(&start_point, buf + 2, 2);
  swap16(&start_point);
  memcpy(&num_points, buf + 4, 2);
  swap16(&num_points);
  if (num_points > 128) {
    buf[1] = 128 + (0x02);
    buf[2] = 4;
    add_CRC(buf, 5, 0xffff);
    return 5;
  }
  byte_count = num_points / 8;
  if ((num_points % 8) > 0) {
    byte_count++;
  }
  buf[2] = byte_count;
  p = buf + 3;
  for (i = 0; i < byte_count; i++) {
    *(p++) = 0x00;
  }
  for (i = 0; i < num_points; i++) {
    val = (i % 2) == 0;
    if (val) {
      byte = i / 8;
      bito = i % 8;
      mask = 1 << bito;
      buf[byte + 3] |= mask;
    }
  }
  add_CRC(buf, 5 + byte_count, 0xffff);
  return (5 + byte_count);
}
```