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    L45
  lea    0x10(%rsp),%r13
  mov    $0x14,%edx
  mov    %r12,%rdi
  mov    %r13,%rsi
  call   <getval@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L28
  mov    $0x14,%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <getval@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L85
  mov    %r13,%rsi
  mov    $0x14,%edx
  mov    %r12,%rdi
  call   <getval@plt>
  mov    %eax,%r13d
  cmp    $0xffffffff,%eax
  je     L22
  mov    %eax,%ecx
  lea    D29(%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     L8
  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    L20
  mov    (%rsp),%rax
  mov    %r9,(%r15)
  mov    %ebx,(%r14)
  mov    %ebp,(%rax)
L126:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  add    $0x38,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L45:
  lea    D21(%rip),%rdi
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  jmp    L126
L20:
  lea    D20(%rip),%rdi
  mov    %r9,(%rsp)
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  jmp    L126
L85:
  mov    $0xffffffff,%esi
  lea    D19(%rip),%rdi
  xor    %eax,%eax
  mov    $0xffffffff,%r13d
  call   <printf@plt>
  jmp    L126
L28:
  mov    $0xffffffff,%esi
  lea    D50(%rip),%rdi
  xor    %eax,%eax
  mov    $0xffffffff,%r13d
  call   <printf@plt>
  jmp    L126
L22:
  mov    $0xffffffff,%esi
  lea    D4(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L126
L8:
  lea    D58(%rip),%rdi
  mov    $0xffffffff,%r13d
  call   <puts@plt>
  jmp    L126
L12:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D29
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D21
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D20
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D19
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D50
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D4
type_guessed: string
name: extract_symbolic_data
arguments: data_tag: D58
type_guessed: string

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


tool: D21: Invalid File

tool: D20: Failed to read file.

tool: D19: Invalid Height %d


tool: D50: Invalid Width %d


tool: D4: Invalid Maximum %d


tool: D58: 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;
}
```