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

```asm
<main>:
  endbr64
  push   %r12
  lea    D60(%rip),%rsi
  lea    D24(%rip),%rdi
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  mov    %rax,%rdi
  lea    0x14(%rsp),%r8
  lea    D42(%rip),%rsi
  mov    %rax,%rbp
  xor    %eax,%eax
  call   <fscanf@plt>
  mov    0x10(%rsp),%edi
  imul   0xc(%rsp),%edi
  mov    %edi,0x10(%rsp)
  shl    $0x2,%edi
  call   <malloc@plt>
  movl   $0x0,0x14(%rsp)
  mov    %rax,%rbx
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L34
  xor    %eax,%eax
  lea    D45(%rip),%r12
  nopl   0x0(%rax,%rax,1)
L0:
  cltq
  mov    %r12,%rsi
  mov    %rbp,%rdi
  lea    (%rbx,%rax,4),%rdx
  xor    %eax,%eax
  call   <fscanf@plt>
  mov    0x14(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x14(%rsp)
  cmp    0x10(%rsp),%eax
  jl     L0
L34:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    (%rbx),%ebp
  mov    0x10(%rsp),%eax
  movl   $0x1,0x14(%rsp)
  mov    %ebp,0xc(%rsp)
  cmp    $0x1,%eax
  jle    L30
  lea    0x1(%rax),%ecx
  mov    %ebp,%esi
  mov    $0x2,%eax
  nopl   (%rax)
L59:
  mov    -0x4(%rbx,%rax,4),%edx
  cmp    %esi,%edx
  jle    L22
L1:
  mov    %eax,0x14(%rsp)
  add    $0x1,%rax
  mov    %edx,0xc(%rsp)
  cmp    %rax,%rcx
  je     L15
  mov    %edx,%esi
  mov    -0x4(%rbx,%rax,4),%edx
  cmp    %esi,%edx
  jg     L1
L22:
  mov    %eax,0x14(%rsp)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L59
L15:
  movl   $0x1,0x14(%rsp)
  mov    $0x2,%eax
  nopl   (%rax)
L44:
  mov    -0x4(%rbx,%rax,4),%edx
  mov    %eax,0x14(%rsp)
  cmp    %edx,%ebp
  cmovg  %edx,%ebp
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L44
L30:
  lea    D10(%rip),%rsi
  lea    D6(%rip),%rdi
  call   <fopen@plt>
  mov    0xc(%rsp),%edx
  lea    D1(%rip),%rsi
  mov    %rax,%r12
  mov    %rax,%rdi
  sub    %ebp,%edx
  call   <fprintf@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  add    $0x20,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L53:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D60
datatype: string
name: disassemble_data
arguments: tag: D24
datatype: string
name: disassemble_data
arguments: tag: D42
datatype: string
name: disassemble_data
arguments: tag: D45
datatype: string
name: disassemble_data
arguments: tag: D10
datatype: string
name: disassemble_data
arguments: tag: D6
datatype: string
name: disassemble_data
arguments: tag: D1
datatype: string

tool: D60: r

tool: D24: INP.TXT

tool: D42: %d %d %d

tool: D45: %d

tool: D10: w

tool: D6: OUT.TXT

tool: D1: %d


assistant: ```c
int main() {
  FILE *f = fopen("INP.TXT", "r");
  int m, n, *a, i, l;
  fscanf(f, "%d %d %d", &m, &n, &i);
  n *= m;
  a = malloc(n * sizeof(int));
  for (i = 0; i < n; i++)
    fscanf(f, "%d", a + i);
  fclose(f);
  l = m = *a;
  for (i = 1; i < n; i++)
    if (a[i] > m)
      m = a[i];
  for (i = 1; i < n; i++)
    if (a[i] < l)
      l = a[i];
  f = fopen("OUT.TXT", "w");
  fprintf(f, "%d\n", m - l);
  fclose(f);
  return 0;
}
```