user: What would the C source look like for the assembly code provided here?

```asm
<ReadPBM1>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  lea    D17(%rip),%rsi
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  movq   $0x0,0x0(%r13)
  mov    %rax,%rbp
  xor    %eax,%eax
  mov    %ax,0x16(%rsp)
  mov    $0xffffffff,%eax
  test   %rbp,%rbp
  je     L45
  lea    0x16(%rsp),%rdi
  mov    %rbp,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  call   <fread@plt>
  cmpb   $0x50,0x16(%rsp)
  je     L113
L149:
  mov    0x0(%r13),%rdi
  test   %rdi,%rdi
  je     L114
  call   <free@plt>
  movq   $0x0,0x0(%r13)
L114:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    $0xffffffff,%eax
L45:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L154
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L113:
  cmpb   $0x31,0x17(%rsp)
  jne    L149
  movl   $0x0,(%r12)
  mov    %rbp,%rdi
  lea    0xf(%rsp),%r14
  movl   $0x0,(%rbx)
  call   <getc@plt>
  mov    %rbp,%rsi
  mov    %r14,%rdi
  mov    %al,0xf(%rsp)
  call   <PPM_scan_ws@plt>
  movzbl 0xf(%rsp),%eax
  jmp    L98
  nopl   0x0(%rax,%rax,1)
L72:
  mov    (%rbx),%eax
  mov    %rbp,%rdi
  lea    (%rax,%rax,4),%edx
  movzbl 0xf(%rsp),%eax
  lea    -0x30(%rax,%rdx,2),%eax
  mov    %eax,(%rbx)
  call   <getc@plt>
  mov    %al,0xf(%rsp)
L98:
  movzbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L72
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <PPM_scan_ws@plt>
  movzbl 0xf(%rsp),%eax
  jmp    L170
  nopl   0x0(%rax,%rax,1)
L150:
  mov    (%r12),%eax
  mov    %rbp,%rdi
  lea    (%rax,%rax,4),%edx
  movzbl 0xf(%rsp),%eax
  lea    -0x30(%rax,%rdx,2),%eax
  mov    %eax,(%r12)
  call   <getc@plt>
  mov    %al,0xf(%rsp)
L170:
  movzbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L150
  movzbl 0xf(%rsp),%edi
  call   <isspace@plt>
  test   %eax,%eax
  je     L149
  mov    (%rbx),%edi
  test   %edi,%edi
  jle    L149
  mov    (%r12),%eax
  test   %eax,%eax
  jle    L149
  imul   %eax,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%r13)
  test   %rax,%rax
  je     L40
  mov    (%r12),%eax
  imul   (%rbx),%eax
  xor    %r14d,%r14d
  lea    0x10(%rsp),%r15
  test   %eax,%eax
  jg     L39
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L110:
  mov    0x10(%rsp),%eax
  cmp    $0x1,%eax
  ja     L70
  mov    0x0(%r13),%rdx
  xor    $0x1,%eax
  neg    %eax
  mov    %al,(%rdx,%r14,1)
  mov    (%rbx),%eax
  add    $0x1,%r14
  imul   (%r12),%eax
  cmp    %r14d,%eax
  jle    L84
L39:
  mov    %r15,%rdx
  lea    D19(%rip),%rsi
  mov    %rbp,%rdi
  call   <fscanf@plt>
  cmp    $0x1,%eax
  je     L110
L70:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    $0xfffffffe,%eax
  jmp    L45
  nop
L84:
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
  jmp    L45
L154:
  call   <__stack_chk_fail@plt>
L40:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    $0xfffffffd,%eax
  jmp    L45
```

tool_calls: name: parse_data
arguments: data_label: D17
type_guessed: string
name: parse_data
arguments: data_label: D19
type_guessed: string

tool: D17: r

tool: D19: %d

assistant: ```c
int ReadPBM1(const char *fname, unsigned char **data, int *w, int *h) {
  FILE *fp = fopen(fname, "r");
  unsigned char buf[2] = {0};
  unsigned char c;
  int i, g;
  *data = NULL;
  if (!fp)
    goto close_fail;
  fread(buf, 1, 2, fp);
  if (buf[0] != 'P' || buf[1] != '1')
    goto close_fail;
  *w = *h = 0;
  c = getc(fp);
  PPM_scan_ws(&c, fp);
  while (isdigit(c)) {
    *w = 10 * (*w) + c - '0';
    c = getc(fp);
  }
  PPM_scan_ws(&c, fp);
  while (isdigit(c)) {
    *h = 10 * (*h) + c - '0';
    c = getc(fp);
  }
  if (!isspace(c))
    goto close_fail;
  if (*w <= 0 || *h <= 0)
    goto close_fail;
  *data = malloc((*w) * (*h) * sizeof **data);
  if (*data == NULL)
    goto nospace_fail;
  for (i = 0; i < (*w) * (*h); ++i) {
    if (fscanf(fp, "%d", &g) != 1)
      goto corrupt_fail;
    if (g < 0 || g > 1)
      goto corrupt_fail;
    (*data)[i] = (g ? 0 : 255);
  }
  fclose(fp);
  return 0;
close_fail:
  if (*data)
    free(*data);
  *data = NULL;
  if (fp)
    fclose(fp);
  return -1;
corrupt_fail:
  fclose(fp);
  return -2;
nospace_fail:
  fclose(fp);
  return -3;
}
```