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

```asm
<read_6>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x3c(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %al,-0x3d(%rbp)
  cmpb   $0x20,-0x3d(%rbp)
  je     L60
  lea    D36(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xffffffff,%eax
  jmp    L64
L60:
  lea    -0x20(%rbp),%rcx
  mov    -0x48(%rbp),%rax
  mov    $0x14,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <getval@plt>
  mov    %eax,-0x38(%rbp)
  cmpl   $0xffffffff,-0x38(%rbp)
  jne    L103
  mov    -0x38(%rbp),%eax
  mov    %eax,%esi
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L64
L103:
  lea    -0x20(%rbp),%rcx
  mov    -0x48(%rbp),%rax
  mov    $0x14,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <getval@plt>
  mov    %eax,-0x34(%rbp)
  cmpl   $0xffffffff,-0x34(%rbp)
  jne    L126
  mov    -0x34(%rbp),%eax
  mov    %eax,%esi
  lea    D33(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L64
L126:
  lea    -0x20(%rbp),%rcx
  mov    -0x48(%rbp),%rax
  mov    $0x14,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <getval@plt>
  mov    %eax,-0x30(%rbp)
  cmpl   $0xffffffff,-0x30(%rbp)
  jne    L110
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L64
L110:
  mov    -0x30(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  mov    -0x38(%rbp),%eax
  mov    %eax,%esi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x38(%rbp),%eax
  imul   -0x34(%rbp),%eax
  mov    %eax,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L53
  lea    D59(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xffffffff,%eax
  jmp    L64
L53:
  mov    -0x48(%rbp),%rcx
  mov    -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    %eax,-0x2c(%rbp)
  je     L20
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  movq   $0x0,-0x28(%rbp)
  mov    $0xffffffff,%eax
  jmp    L64
L20:
  mov    -0x50(%rbp),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x58(%rbp),%rax
  mov    -0x38(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x60(%rbp),%rax
  mov    -0x34(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x2c(%rbp),%eax
L64:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L85
  call   <__stack_chk_fail@plt>
L85:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D36
type_infered: string
name: parse_data
arguments: data_label: D58
type_infered: string
name: parse_data
arguments: data_label: D33
type_infered: string
name: parse_data
arguments: data_label: D48
type_infered: string
name: parse_data
arguments: data_label: D18
type_infered: string
name: parse_data
arguments: data_label: D59
type_infered: string
name: parse_data
arguments: data_label: D13
type_infered: string

tool: D36: Invalid File

tool: D58: Invalid Width %d


tool: D33: Invalid Height %d


tool: D48: Invalid Maximum %d


tool: D18: Width = %d, Height = %d, Max = %d


tool: D59: You are out of memory. 

tool: D13: Failed to read file.

assistant: ```c
int read_6(FILE *fp, char **image_data, int *width, int *height) {
  int arrsize;
  char *localdata;
  char rtp;
  char buff[20];
  int imgwid;
  int imght;
  int maxval;
  int idx = 0;
  rtp = fgetc(fp);
  if (rtp != ' ') {
    printf("Invalid File\n");
    return -1;
  }
  imgwid = getval(fp, buff, 20);
  if (imgwid == -1) {
    printf("Invalid Width %d\n", imgwid);
    return -1;
  }
  imght = getval(fp, buff, 20);
  if (imght == -1) {
    printf("Invalid Height %d\n", imght);
    return -1;
  }
  maxval = getval(fp, buff, 20);
  if (maxval == -1) {
    printf("Invalid Maximum %d\n", maxval);
    return -1;
  }
  printf("Width = %d, Height = %d, Max = %d\n", imgwid, imght, maxval);
  arrsize = imgwid * imght * 3;
  localdata = malloc(arrsize * sizeof(char));
  if (localdata == NULL) {
    printf("You are out of memory. \n");
    return -1;
  }
  if (fread(localdata, sizeof(char), arrsize, fp) != (arrsize * sizeof(char))) {
    printf("Failed to read file.\n");
    free(localdata);
    localdata = NULL;
    return -1;
  }
  *image_data = localdata;
  *width = imgwid;
  *height = imght;
  return arrsize;
}
```