user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<read_6>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rcx,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <fgetc@plt>
  cmp    $0x20,%al
  jne    L97
  lea    0x10(%rsp),%r13
  mov    $0x14,%edx
  mov    %r12,%rdi
  mov    %r13,%rsi
  call   <getval@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L43
  mov    $0x14,%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <getval@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L112
  mov    %r13,%rsi
  mov    $0x14,%edx
  mov    %r12,%rdi
  call   <getval@plt>
  mov    %eax,%r13d
  cmp    $0xffffffff,%eax
  je     L83
  mov    %eax,%ecx
  lea    D5(%rip),%rdi
  xor    %eax,%eax
  mov    %ebp,%edx
  mov    %ebx,%esi
  call   <printf@plt>
  mov    %ebx,%eax
  imul   %ebp,%eax
  lea    (%rax,%rax,2),%r13d
  mov    %r13d,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L120
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <fread@plt>
  mov    0x8(%rsp),%r9
  cmp    %r13d,%eax
  jne    L22
  mov    (%rsp),%rax
  mov    %r9,(%r15)
  mov    %ebx,(%r14)
  mov    %ebp,(%rax)
L109:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L121
  add    $0x38,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L97:
  lea    D8(%rip),%rdi
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  jmp    L109
L22:
  lea    D33(%rip),%rdi
  mov    %r9,(%rsp)
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  jmp    L109
L112:
  mov    $0xffffffff,%esi
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  mov    $0xffffffff,%r13d
  call   <printf@plt>
  jmp    L109
L43:
  mov    $0xffffffff,%esi
  lea    D20(%rip),%rdi
  xor    %eax,%eax
  mov    $0xffffffff,%r13d
  call   <printf@plt>
  jmp    L109
L83:
  mov    $0xffffffff,%esi
  lea    D35(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L109
L120:
  lea    D50(%rip),%rdi
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  jmp    L109
L121:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D5
type_guessed: string
name: read_data
arguments: data_tag: D8
type_guessed: string
name: read_data
arguments: data_tag: D33
type_guessed: string
name: read_data
arguments: data_tag: D10
type_guessed: string
name: read_data
arguments: data_tag: D20
type_guessed: string
name: read_data
arguments: data_tag: D35
type_guessed: string
name: read_data
arguments: data_tag: D50
type_guessed: string

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


tool: D8: Invalid File

tool: D33: Failed to read file.

tool: D10: Invalid Height %d


tool: D20: Invalid Width %d


tool: D35: Invalid Maximum %d


tool: D50: You are out of memory. 

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