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

```asm
<readppm>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x128,%rsp
  mov    %rsi,%r12
  mov    %rdx,%rbp
  mov    %rcx,%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  lea    D8(%rip),%rsi
  call   <fopen@plt>
  mov    $0x1,%edx
  test   %eax,%eax
  jne    L37
L67:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  mov    %edx,%eax
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L37:
  movslq %eax,%rbx
  lea    0x10(%rsp),%rdx
  lea    D11(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  cmpb   $0x50,0x10(%rsp)
  jne    L69
  cmpb   $0x36,0x11(%rsp)
  jne    L69
  cmpb   $0x0,0x12(%rsp)
  jne    L69
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <getint@plt>
  mov    %eax,(%r12)
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <getint@plt>
  mov    %eax,0x0(%rbp)
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <getint@plt>
  mov    %eax,0xc(%rsp)
  lea    0xc(%rsp),%rdi
  mov    %rbx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    $0x0,%eax
  call   <fread@plt>
  mov    (%r12),%eax
  imul   0x0(%rbp),%eax
  lea    (%rax,%rax,2),%r12d
  movslq %r12d,%rbp
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x0(%r13)
  mov    %rbx,%rcx
  mov    %rbp,%rdx
  mov    $0x1,%esi
  mov    $0x0,%eax
  call   <fread@plt>
  mov    %eax,%ebp
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fclose@plt>
  cmp    %r12d,%ebp
  setne  %dl
  movzbl %dl,%edx
  shl    $0x2,%edx
  jmp    L67
L69:
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fclose@plt>
  mov    $0x2,%edx
  jmp    L67
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D8
type: string
name: parse_data
arguments: label: D11
type: string

tool: D8: r

tool: D11: %s

assistant: ```c
signed int readppm(char *name, signed int *xres, signed int *yres, unsigned char **imgdata) {
  char data[256l];
  struct _IO_FILE$link40 *ifp;
  signed int i;
  signed int bytesread;
  signed int datasize;
  ifp = fopen(name, "r");
  if (ifp == ((struct _IO_FILE$link40 *)((void *)0)))
    return 1;
  fscanf(ifp, "%s", (const void *)data);
  signed int tmp_statement_expression$1;
  unsigned long int __s1_len;
  unsigned long int __s2_len;
  _Bool tmp_if_expr$3;
  unsigned int return_value___builtin_strlen$2;
  if ((_Bool)1) {
    if (!((unsigned long int)("P6" + 1l) + -((unsigned long int)"P6") == 1ul))
      goto __CPROVER_DUMP_L2;
    return_value___builtin_strlen$2 = __builtin_strlen("P6");
    __s2_len = (unsigned long int)return_value___builtin_strlen$2;
    tmp_if_expr$3 = __s2_len < (unsigned long int)4 ? (_Bool)1 : (_Bool)0;
  } else {
  __CPROVER_DUMP_L2:;
    tmp_if_expr$3 = (_Bool)0;
  }
  signed int tmp_if_expr$6;
  signed int tmp_statement_expression$4;
  signed int return_value___builtin_strcmp$5;
  if (tmp_if_expr$3) {
    const unsigned char *__s1 = (const unsigned char *)(const char *)data;
    signed int __result = (signed int)__s1[(signed long int)0] - (signed int)((const unsigned char *)(const char *)"P6")[(signed long int)0];
    if (__s2_len > 0ul) {
      if (__result == 0) {
        __result = (signed int)__s1[(signed long int)1] - (signed int)((const unsigned char *)(const char *)"P6")[(signed long int)1];
        if (__s2_len > 1ul) {
          if (__result == 0) {
            __result = (signed int)__s1[(signed long int)2] - (signed int)((const unsigned char *)(const char *)"P6")[(signed long int)2];
            if (__s2_len > 2ul) {
              if (__result == 0)
                __result = (signed int)__s1[(signed long int)3] - (signed int)((const unsigned char *)(const char *)"P6")[(signed long int)3];
            }
          }
        }
      }
    }
    tmp_statement_expression$4 = __result;
    tmp_if_expr$6 = tmp_statement_expression$4;
  } else {
    return_value___builtin_strcmp$5 = __builtin_strcmp(data, "P6");
    tmp_if_expr$6 = return_value___builtin_strcmp$5;
  }
  tmp_statement_expression$1 = tmp_if_expr$6;
  if (!(tmp_statement_expression$1 == 0)) {
    fclose(ifp);
    return 2;
  }
  *xres = getint(ifp);
  *yres = getint(ifp);
  i = getint(ifp);
  fread((void *)&i, (unsigned long int)1, (unsigned long int)1, ifp);
  datasize = 3 * *xres * *yres;
  void *return_value_malloc$7;
  return_value_malloc$7 = malloc((unsigned long int)datasize);
  *imgdata = (unsigned char *)return_value_malloc$7;
  unsigned long int return_value_fread$8;
  return_value_fread$8 = fread((void *)*imgdata, (unsigned long int)1, (unsigned long int)datasize, ifp);
  bytesread = (signed int)return_value_fread$8;
  fclose(ifp);
  if (!(bytesread == datasize))
    return 4;
  return 0;
}
```