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

```asm
<send_data>:
  endbr64
  push   %r15
  movd   %esi,%xmm2
  movd   %ecx,%xmm3
  mov    $0x4,%esi
  push   %r14
  lea    0x7(%rcx),%r14d
  punpckldq %xmm3,%xmm2
  push   %r13
  mov    %rdi,%r13
  mov    %r14d,%edi
  movq   %xmm2,%r15
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x8,%rsp
  call   <calloc@plt>
  test   %rax,%rax
  je     L56
  mov    %rax,%rbp
  mov    D10(%rip),%rax
  mov    %r15,0x8(%rbp)
  mov    %rax,0x0(%rbp)
  test   %r12d,%r12d
  jle    L23
  mov    %rbp,%rax
  sub    %rbx,%rax
  add    $0xc,%rax
  cmp    $0x8,%rax
  jbe    L60
  lea    -0x1(%r12),%eax
  cmp    $0x3,%eax
  jbe    L60
  mov    %r12d,%edx
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  shr    $0x2,%edx
  shl    $0x4,%rdx
  nopl   0x0(%rax,%rax,1)
L1:
  movdqu (%rbx,%rax,1),%xmm1
  movups %xmm1,0x10(%rbp,%rax,1)
  add    $0x10,%rax
  pxor   %xmm1,%xmm0
  cmp    %rax,%rdx
  jne    L1
  movdqa %xmm0,%xmm1
  mov    %r12d,%edx
  lea    0x4(%r12),%ecx
  psrldq $0x8,%xmm1
  and    $0xfffffffc,%edx
  pxor   %xmm1,%xmm0
  lea    0x4(%rdx),%esi
  movdqa %xmm0,%xmm1
  psrldq $0x4,%xmm1
  pxor   %xmm1,%xmm0
  movd   %xmm0,%eax
  cmp    %edx,%r12d
  je     L44
  mov    %edx,%edi
  lea    0x0(,%rsi,4),%r8
  lea    0x0(,%rdi,4),%r9
  mov    (%rbx,%rdi,4),%edi
  mov    %edi,0x0(%rbp,%rsi,4)
  lea    0x1(%rdx),%esi
  xor    %edi,%eax
  cmp    %esi,%r12d
  jle    L44
  mov    0x4(%rbx,%r9,1),%esi
  add    $0x2,%edx
  mov    %esi,0x4(%rbp,%r8,1)
  xor    %esi,%eax
  cmp    %edx,%r12d
  jle    L44
  mov    0x8(%rbx,%r9,1),%edx
  mov    %edx,0x8(%rbp,%r8,1)
  xor    %edx,%eax
L44:
  mov    %ecx,%edx
  shl    $0x2,%rdx
  lea    0x4(%rdx),%rsi
  lea    0x8(%rdx),%rcx
L135:
  mov    %eax,0x0(%rbp,%rdx,1)
  mov    %r13,%rdi
  mov    %r14d,%edx
  movl   $0xd,0x0(%rbp,%rsi,1)
  mov    %rbp,%rsi
  movl   $0xa,0x0(%rbp,%rcx,1)
  call   <serial_write@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  js     L110
L130:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %rbx,%rax
  sar    $0x3f,%rax
  and    $0x1,%eax
L107:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L110:
  mov    %rax,%rdi
  call   <serial_error_string@plt>
  mov    %rbx,%rsi
  lea    D16(%rip),%rdi
  mov    %eax,%edx
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L130
  nopl   (%rax)
L60:
  lea    0x4(%r12),%edi
  xor    %eax,%eax
  mov    $0x4,%edx
  mov    %rdi,%rcx
  nop
L38:
  mov    -0x10(%rbx,%rdx,4),%esi
  add    $0x1,%rdx
  mov    %esi,-0x4(%rbp,%rdx,4)
  xor    %esi,%eax
  cmp    %rdi,%rdx
  jne    L38
  jmp    L44
  nopl   0x0(%rax,%rax,1)
L23:
  mov    $0x18,%ecx
  mov    $0x14,%esi
  mov    $0x10,%edx
  xor    %eax,%eax
  jmp    L135
  cs nopw 0x0(%rax,%rax,1)
L56:
  lea    D11(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L107
```

tool_calls: name: unpack_data
arguments: data_label: D10
type_infered: byte[8]
name: unpack_data
arguments: data_label: D16
type_infered: string
name: unpack_data
arguments: data_label: D11
type_infered: string

tool: {"D10": [0x24,0x00,0x00,0x00,0x24,0x00,0x00,0x00]}

tool: D16: Connection error %zd: %s


tool: D11: Allocation failure

assistant: ```c
int send_data(struct serial_port *port, uint8_t type, const void *data, uint8_t length) {
  uint8_t *packet = calloc(length + 7, sizeof(uint8_t));
  if (!packet) {
    printf("Allocation failure\n");
    return 1;
  }
  size_t i = 0;
  packet[i++] = '$';
  packet[i++] = '$';
  packet[i++] = type;
  packet[i++] = length;
  uint8_t checksum = 0;
  for (uint8_t j = 0; j < length; j++) {
    uint8_t b = ((uint8_t *)data)[j];
    packet[i++] = b;
    checksum ^= b;
  }
  packet[i++] = checksum;
  packet[i++] = '\r';
  packet[i++] = '\n';
  ssize_t error = serial_write(port, packet, length + 7);
  if (error < 0)
    printf("Connection error %zd: %s\n", error, serial_error_string(error));
  free(packet);
  return error < 0 ? 1 : 0;
}
```