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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x3d0000(%rsp),%r11
L124:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L124
  sub    $0xd10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x3d0d04(%rbp)
  lea    D40(%rip),%rax
  mov    %rax,-0x3d0d00(%rbp)
  movl   $0x0,-0x3d0d0c(%rbp)
  jmp    L22
L127:
  movl   $0x0,-0x3d0d08(%rbp)
  jmp    L132
L11:
  mov    -0x3d0d08(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x3d0d0c(%rbp),%eax
  cltq
  imul   $0x3e8,%rax,%rax
  add    %rdx,%rax
  movl   $0x0,-0x3d0cf0(%rbp,%rax,4)
  addl   $0x1,-0x3d0d08(%rbp)
L132:
  cmpl   $0x3e7,-0x3d0d08(%rbp)
  jle    L11
  addl   $0x1,-0x3d0d0c(%rbp)
L22:
  cmpl   $0x3e7,-0x3d0d0c(%rbp)
  jle    L127
  mov    -0x3d0d00(%rbp),%rax
  lea    D23(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x3d0cf8(%rbp)
  cmpq   $0x0,-0x3d0cf8(%rbp)
  jne    L122
  mov    -0x3d0d00(%rbp),%rax
  mov    %rax,%rsi
  lea    D44(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L122
L134:
  lea    -0x3d0cf0(%rbp),%rcx
  lea    -0x3f0(%rbp),%rax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <parse@plt>
L122:
  mov    -0x3d0cf8(%rbp),%rdx
  lea    -0x3f0(%rbp),%rax
  mov    $0x3e8,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L134
  mov    -0x3d0cf8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  movl   $0x0,-0x3d0d0c(%rbp)
  jmp    L137
L143:
  movl   $0x0,-0x3d0d08(%rbp)
  jmp    L81
L106:
  mov    -0x3d0d08(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x3d0d0c(%rbp),%eax
  cltq
  imul   $0x3e8,%rax,%rax
  add    %rdx,%rax
  mov    -0x3d0cf0(%rbp,%rax,4),%eax
  cmp    $0x1,%eax
  jle    L89
  addl   $0x1,-0x3d0d04(%rbp)
L89:
  addl   $0x1,-0x3d0d08(%rbp)
L81:
  cmpl   $0x3e7,-0x3d0d08(%rbp)
  jle    L106
  addl   $0x1,-0x3d0d0c(%rbp)
L137:
  cmpl   $0x3e7,-0x3d0d0c(%rbp)
  jle    L143
  mov    -0x3d0d00(%rbp),%rax
  lea    D23(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x3d0cf8(%rbp)
  cmpq   $0x0,-0x3d0cf8(%rbp)
  jne    L101
  mov    -0x3d0d00(%rbp),%rax
  mov    %rax,%rsi
  lea    D44(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L101
L73:
  lea    -0x3d0cf0(%rbp),%rcx
  lea    -0x3f0(%rbp),%rax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <parse@plt>
L101:
  mov    -0x3d0cf8(%rbp),%rdx
  lea    -0x3f0(%rbp),%rax
  mov    $0x3e8,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L73
  mov    -0x3d0d04(%rbp),%eax
  mov    %eax,%esi
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x3d0cf8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L152
  call   <__stack_chk_fail@plt>
L152:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D40
type_guessed: string
name: unpack_data
arguments: tag: D23
type_guessed: string
name: unpack_data
arguments: tag: D44
type_guessed: string
name: unpack_data
arguments: tag: D35
type_guessed: string

tool: D40: input.txt

tool: D23: r

tool: D44: error opening: %s


tool: D35: Claimed squares: %d


assistant: ```c
int main() {
  FILE *fd;
  char str[1000];
  int fabric[1000][1000];
  int i, j, claims = 0;
  char *filename = "input.txt";
  for (i = 0; i < 1000; i++) {
    for (j = 0; j < 1000; j++) {
      fabric[i][j] = 0;
    }
  }
  fd = fopen(filename, "r");
  if (fd == NULL) {
    printf("error opening: %s\n", filename);
  }
  while (fgets(str, 1000, fd) != NULL) {
    parse(str, fabric, 0);
  }
  fclose(fd);
  for (i = 0; i < 1000; i++) {
    for (j = 0; j < 1000; j++) {
      if (fabric[i][j] >= 2) {
        claims++;
      }
    }
  }
  fd = fopen(filename, "r");
  if (fd == NULL) {
    printf("error opening: %s\n", filename);
  }
  while (fgets(str, 1000, fd) != NULL) {
    parse(str, fabric, 1);
  }
  printf("Claimed squares: %d\n", claims);
  fclose(fd);
  return 0;
}
```