user: 请从给定的汇编指令推导出C源代码:

```asm
<rt_modbus_read_input_table>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D30(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x38(%rbp),%rax
  lea    0x8(%rax),%rcx
  lea    -0x30(%rbp),%rax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <swap16@plt>
  mov    -0x38(%rbp),%rax
  lea    0x10(%rax),%rcx
  lea    -0x2c(%rbp),%rax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x2c(%rbp),%rax
  mov    %rax,%rdi
  call   <swap16@plt>
  mov    -0x2c(%rbp),%eax
  cmp    $0x80,%eax
  jle    L63
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x2c(%rbp),%edx
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x38(%rbp),%rax
  add    $0x4,%rax
  movl   $0x82,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0x8,%rax
  movl   $0x4,(%rax)
  mov    -0x38(%rbp),%rax
  mov    $0xffff,%edx
  mov    $0x5,%esi
  mov    %rax,%rdi
  call   <add_CRC@plt>
  mov    $0x5,%eax
  jmp    L28
L63:
  mov    -0x2c(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x2c(%rbp),%eax
  cltd
  shr    $0x1d,%edx
  add    %edx,%eax
  and    $0x7,%eax
  sub    %edx,%eax
  test   %eax,%eax
  jle    L34
  addl   $0x1,-0x28(%rbp)
L34:
  mov    -0x38(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    -0x28(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x24(%rbp)
  jmp    L23
L30:
  mov    -0x10(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movl   $0x0,(%rax)
  addl   $0x1,-0x24(%rbp)
L23:
  mov    -0x24(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L30
  movl   $0x0,-0x24(%rbp)
  jmp    L39
L72:
  mov    -0x30(%rbp),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edi
  call   <read_di@plt>
  mov    %eax,-0x20(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  je     L89
  mov    -0x24(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  cltd
  shr    $0x1d,%edx
  add    %edx,%eax
  and    $0x7,%eax
  sub    %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  add    $0x3,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  or     -0x14(%rbp),%eax
  mov    %eax,(%rdx)
L89:
  addl   $0x1,-0x24(%rbp)
L39:
  mov    -0x2c(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L72
  mov    -0x28(%rbp),%eax
  lea    0x5(%rax),%ecx
  mov    -0x38(%rbp),%rax
  mov    $0xffff,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <add_CRC@plt>
  mov    -0x28(%rbp),%eax
  add    $0x5,%eax
L28:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D30
type_guessed: string
name: parse_data
arguments: data_label: D29
type_guessed: string
name: parse_data
arguments: data_label: D23
type_guessed: string
name: parse_data
arguments: data_label: D28
type_guessed: string

tool: D30: In Read Input Table, n = %d


tool: D29: *** Too many points specified!

tool: D23: Start %u, Num %u


tool: D28: In Read Input Table, byte count = %d, num_points = %d


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, bit;
  uint8_t mask;
  printf("In Read Input Table, n = %d\n", n);
  memcpy(&start_point, buf + 2, 2);
  swap16(&start_point);
  memcpy(&num_points, buf + 4, 2);
  swap16(&num_points);
  if (num_points > 128) {
    printf("*** Too many points specified!\n");
    printf("Start %u, Num %u\n", start_point, num_points);
    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;
  printf("In Read Input Table, byte count = %d, num_points = %d\n", byte_count, num_points);
  p = buf + 3;
  for (i = 0; i < byte_count; i++) {
    *(p++) = 0x00;
  }
  for (i = 0; i < num_points; i++) {
    val = read_di(i + start_point);
    if (val) {
      byte = i / 8;
      bit = i % 8;
      mask = 1 << bit;
      buf[byte + 3] |= mask;
    }
  }
  add_CRC(buf, 5 + byte_count, 0xffff);
  return (5 + byte_count);
}
```