user: What is the c source code of the assembly code below:

```asm
<send_data>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  mov    -0x40(%rbp),%eax
  add    $0x7,%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L33
  lea    D14(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L25
L33:
  movq   $0x0,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movl   $0x24,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movl   $0x24,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x3c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x40(%rbp),%eax
  mov    %eax,(%rdx)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L49
L9:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%eax
  xor    %eax,-0x24(%rbp)
  addl   $0x1,-0x20(%rbp)
L49:
  mov    -0x20(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L9
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movl   $0xd,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movl   $0xa,(%rax)
  mov    -0x40(%rbp),%eax
  lea    0x7(%rax),%edx
  mov    -0x10(%rbp),%rcx
  mov    -0x38(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <serial_write@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jns    L31
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <serial_error_string@plt>
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L31:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  sar    $0x3f,%rax
  and    $0x1,%eax
L25:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D14
type_infered: string
name: disassemble_data
arguments: label: D0
type_infered: string

tool: D14: Allocation failure

tool: D0: Connection error %zd: %s


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;
}
```