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

```asm
<printer_print>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x28(%rbp)
  mov    $0x80,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L29
  lea    D69(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x0,%eax
  call   <abort@plt>
L29:
  mov    -0x20(%rbp),%rax
  lea    D12(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x20(%rbp),%rax
  lea    D64(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L15
  lea    D100(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  call   <abort@plt>
L15:
  mov    -0x18(%rbp),%rcx
  mov    -0x28(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  je     L2
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  call   <abort@plt>
L2:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  test   %rax,%rax
  je     L38
  lea    D73(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L35
L38:
  mov    $0x0,%eax
  call   <connect_to_server@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x48(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  lea    D96(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x20(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  lea    D1(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  cmpq   $0x0,-0x50(%rbp)
  je     L44
  mov    -0x50(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  lea    D97(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
L44:
  mov    -0x40(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  lea    D28(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x6,%edx
  mov    $0x1,%esi
  lea    D77(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L35:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D69
type_guessed: string
name: unpack_data
arguments: data_label: D12
type_guessed: string
name: unpack_data
arguments: data_label: D64
type_guessed: string
name: unpack_data
arguments: data_label: D100
type_guessed: string
name: unpack_data
arguments: data_label: D13
type_guessed: string
name: unpack_data
arguments: data_label: D73
type_guessed: string
name: unpack_data
arguments: data_label: D9
type_guessed: string
name: unpack_data
arguments: data_label: D96
type_guessed: string
name: unpack_data
arguments: data_label: D1
type_guessed: string
name: unpack_data
arguments: data_label: D97
type_guessed: string
name: unpack_data
arguments: data_label: D28
type_guessed: string
name: unpack_data
arguments: data_label: D77
type_guessed: string
name: unpack_data
arguments: data_label: D43
type_guessed: string

tool: D69: malloc

tool: D12: /tmp/print_job_

tool: D64: w

tool: D100: fopen

tool: D13: fwrite

tool: D73: fclose

tool: D9: NEW


tool: D96: NAME:%s


tool: D1: FILE:%s


tool: D97: DESCRIPTION:%s


tool: D28: PRINTER:%s


tool: D77: PRINT


tool: D43: EXIT


assistant: ```c
int printer_print(int *handle __attribute__((unused)), char *driver, char *job_name, char *description, char *data) {
  size_t datasize = strlen(data);
  char *tmpfile_name = malloc(128);
  if (tmpfile_name == NULL) {
    perror("malloc");
    abort();
  }
  strcpy(tmpfile_name, "/tmp/print_job_");
  strcat(tmpfile_name, job_name);
  FILE *tmpfile = fopen(tmpfile_name, "w");
  if (tmpfile == NULL) {
    perror("fopen");
    free(tmpfile_name);
    abort();
  }
  size_t count = fwrite(data, 1, datasize, tmpfile);
  if (count != datasize) {
    perror("fwrite");
    fclose(tmpfile);
    free(tmpfile_name);
    abort();
  }
  if (fclose(tmpfile)) {
    perror("fclose");
    fclose(tmpfile);
    free(tmpfile_name);
    return -1;
  }
  FILE *conn = connect_to_server();
  fprintf(conn, "NEW\n");
  fprintf(conn, "NAME:%s\n", job_name);
  fprintf(conn, "FILE:%s\n", tmpfile_name);
  if (description != NULL) {
    fprintf(conn, "DESCRIPTION:%s\n", description);
  }
  fprintf(conn, "PRINTER:%s\n", driver);
  fprintf(conn, "PRINT\n");
  fprintf(conn, "EXIT\n");
  free(tmpfile_name);
  fclose(conn);
  return 0;
}
```