user: Converte this assembly snippet into its equivalent C code:

```asm
<rt_modbus_preset_multiple_registers>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x28(%rbp),%rax
  mov    0x18(%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  add    $0x9,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x8(%rax),%rcx
  lea    -0x20(%rbp),%rax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <swap16@plt>
  mov    -0x28(%rbp),%rax
  lea    0x10(%rax),%rcx
  lea    -0x1c(%rbp),%rax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x1c(%rbp),%rax
  mov    %rax,%rdi
  call   <swap16@plt>
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1c(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1c(%rbp),%eax
  add    %eax,%eax
  cmp    %eax,-0x10(%rbp)
  jne    L36
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  jmp    L28
L36:
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L28:
  movl   $0x0,-0x14(%rbp)
  jmp    L48
L3:
  mov    -0x14(%rbp),%eax
  add    %eax,%eax
  cltq
  add    $0x7,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  lea    -0x18(%rbp),%rax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <swap16@plt>
  mov    -0x20(%rbp),%edx
  mov    -0x14(%rbp),%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %eax,%esi
  lea    D45(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x18(%rbp),%eax
  mov    -0x20(%rbp),%ecx
  mov    -0x14(%rbp),%edx
  add    %ecx,%edx
  mov    %eax,%esi
  mov    %edx,%edi
  call   <write_register@plt>
  addl   $0x1,-0x14(%rbp)
L48:
  mov    -0x1c(%rbp),%eax
  cmp    %eax,-0x14(%rbp)
  jl     L3
  mov    -0x28(%rbp),%rax
  mov    $0xffff,%edx
  mov    $0x8,%esi
  mov    %rax,%rdi
  call   <add_CRC@plt>
  mov    $0x8,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L2
  call   <__stack_chk_fail@plt>
L2:
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D11
datatype: string
name: parse_data
arguments: tag: D21
datatype: string
name: parse_data
arguments: tag: D35
datatype: string
name: parse_data
arguments: tag: D32
datatype: string
name: parse_data
arguments: tag: D45
datatype: string

tool: D11: start = %hu, num = %hu


tool: D21: data bytes = %hu, calculated size = %d


tool: D35: Size matches

tool: D32: *** Data error size does NOT match

tool: D45: value %d: %04hx, addr: %d


assistant: ```c
int rt_modbus_preset_multiple_registers(uint8_t *buf, int sz) {
  int data_bytes;
  int size;
  uint16_t start_point;
  uint16_t num_points;
  uint16_t tmp;
  int i;
  data_bytes = buf[6];
  size = 9 + data_bytes;
  memcpy(&start_point, buf + 2, 2);
  swap16(&start_point);
  memcpy(&num_points, buf + 4, 2);
  swap16(&num_points);
  printf("start = %hu, num = %hu\n", start_point, num_points);
  printf("data bytes = %hu, calculated size = %d\n", data_bytes, num_points * 2);
  if ((num_points * 2) == data_bytes) {
    printf("Size matches\n");
  } else {
    printf("*** Data error size does NOT match\n");
  }
  for (i = 0; i < num_points; i++) {
    memcpy(&tmp, buf + (i * 2) + 7, 2);
    swap16(&tmp);
    printf("value %d: %04hx, addr: %d\n", i, tmp, start_point + i);
    write_register(start_point + i, tmp);
  }
  add_CRC(buf, 8, 0xffff);
  return 8;
}
```