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

```asm
<read_graphics>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %r8d,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x38,%rsp
  mov    %rsi,0x10(%rsp)
  lea    D35(%rip),%rsi
  mov    %edx,0x8(%rsp)
  mov    %ecx,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L18
  nopl   0x0(%rax,%rax,1)
L112:
  mov    %r15,%rdi
  call   <fgetc@plt>
  cmp    $0xa,%al
  sete   %al
  movzbl %al,%eax
  add    %eax,%ebx
  cmp    $0x3,%ebx
  jne    L112
  test   %r13d,%r13d
  jne    L55
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jle    L75
  mov    (%rsp),%ecx
  test   %ecx,%ecx
  jle    L75
  movslq %ecx,%rax
  mov    $0xfffffffffffffffc,%rdx
  lea    0x24(%rsp),%rbp
  shl    $0x2,%rax
  lea    D36(%rip),%rbx
  mov    %rax,(%rsp)
  lea    -0x1(%rcx),%eax
  mov    0x10(%rsp),%rcx
  shl    $0x2,%rax
  sub    %rax,%rdx
  lea    0x4(%rcx,%rax,1),%r12
  mov    %rdx,0x10(%rsp)
  xchg   %ax,%ax
L39:
  mov    0x10(%rsp),%rax
  lea    (%rax,%r12,1),%r14
  nopl   0x0(%rax)
L103:
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  mov    %r15,%rdi
  add    $0x4,%r14
  call   <fscanf@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x24(%rsp),%xmm0
  movss  %xmm0,-0x4(%r14)
  cmp    %r14,%r12
  jne    L103
  add    $0x1,%r13d
  add    (%rsp),%r12
  cmp    %r13d,0x8(%rsp)
  jne    L39
L75:
  mov    %r15,%rdi
  call   <fclose@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L135
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L55:
  movslq 0x8(%rsp),%rax
  test   %eax,%eax
  jle    L75
  mov    (%rsp),%edx
  test   %edx,%edx
  jle    L75
  mov    %rax,0x18(%rsp)
  lea    0x0(,%rax,4),%r13
  lea    0x24(%rsp),%rbp
  movq   $0x0,0x8(%rsp)
  lea    D36(%rip),%rbx
  nopw   0x0(%rax,%rax,1)
L69:
  mov    0x10(%rsp),%rax
  mov    0x8(%rsp),%rcx
  xor    %r14d,%r14d
  lea    (%rax,%rcx,4),%r12
  nopl   0x0(%rax)
L64:
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  mov    %r15,%rdi
  add    $0x1,%r14d
  call   <fscanf@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x24(%rsp),%xmm0
  movss  %xmm0,(%r12)
  add    %r13,%r12
  cmp    %r14d,(%rsp)
  jne    L64
  addq   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%rax
  cmp    0x18(%rsp),%rax
  jne    L69
  jmp    L75
L18:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L135
  add    $0x38,%rsp
  lea    D4(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <printf@plt>
L135:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D35
type_guessed: string
name: unpack_data
arguments: data_label: D36
type_guessed: string
name: unpack_data
arguments: data_label: D4
type_guessed: string

tool: D35: r

tool: D36: %d

tool: D4: The file was not opened for reading


assistant: ```c
void read_graphics(char *filename, float *input, int data_rows, int data_cols, int major) {
  FILE *fid;
  int i, j;
  char c;
  int temp;
  fid = fopen(filename, "r");
  if (fid == NULL) {
    printf("The file was not opened for reading\n");
    return;
  }
  i = 0;
  while (i < 3) {
    c = fgetc(fid);
    if (c == '\n') {
      i = i + 1;
    }
  };
  if (major == 0) {
    for (i = 0; i < data_rows; i++) {
      for (j = 0; j < data_cols; j++) {
        fscanf(fid, "%d", &temp);
        input[i * data_cols + j] = (float)temp;
      }
    }
  } else {
    for (i = 0; i < data_rows; i++) {
      for (j = 0; j < data_cols; j++) {
        fscanf(fid, "%d", &temp);
        input[j * data_rows + i] = (float)temp;
      }
    }
  }
  fclose(fid);
}
```