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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x798,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x3788(%rsp)
  xor    %eax,%eax
  lea    0x1c(%rsp),%rsi
  lea    D12(%rip),%rdi
  call   <scanf@plt>
  mov    0x1c(%rsp),%r8d
  test   %r8d,%r8d
  jle    L140
  lea    0x20(%rsp),%r15
  lea    0x470(%rsp),%r14
  movl   $0x0,0xc(%rsp)
  lea    D21(%rip),%rbx
  jmp    L6
L88:
  movzbl 0x1b(%rsp),%eax
  mov    %al,(%r15,%rbp,1)
  movl   $0x0,(%r14,%rbp,4)
  add    $0x1,%rbp
  cmp    %ebp,0x1c(%rsp)
  jle    L14
L84:
  lea    0x1b(%rsp),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  test   %rax,%rax
  je     L88
  cmpb   $0xa,0x1b(%rsp)
  je     L84
  jmp    L88
L14:
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  mov    0x1c(%rsp),%r8d
  add    $0x21,%r15
  add    $0x84,%r14
  cmp    %eax,%r8d
  jle    L140
L6:
  mov    $0x0,%ebp
  cmpl   $0x0,0x1c(%rsp)
  jg     L84
  jmp    L14
L140:
  movl   $0x1,0x470(%rsp)
  movl   $0x0,0x1580(%rsp)
  movl   $0x0,0x1584(%rsp)
  lea    -0x1(%r8),%eax
  movslq %eax,%rcx
  mov    %rcx,%rdx
  shl    $0x4,%rdx
  add    %rcx,%rdx
  movl   $0x1,0x470(%rsp,%rdx,8)
  mov    %eax,0x1588(%rsp)
  mov    %eax,0x158c(%rsp)
  mov    $0x0,%edi
  mov    $0x2,%r11d
  jmp    L198
L42:
  cmp    $0x1,%eax
  cmove  %r9d,%r13d
  cmove  %esi,%r12d
L63:
  cmp    %r13d,%r12d
  mov    %r13d,%edx
  cmovge %r12d,%edx
  cmp    %edx,%r8d
  jg     L124
L66:
  add    $0x1,%edi
L163:
  add    $0x1,%eax
  cmp    $0x4,%eax
  je     L113
L94:
  cmp    $0x2,%eax
  je     L81
  jg     L44
  test   %eax,%eax
  jne    L42
  mov    %ebx,%r13d
  mov    %esi,%r12d
  jmp    L63
L44:
  cmp    $0x3,%eax
  cmove  %r10d,%r12d
  cmove  %ecx,%r13d
  jmp    L63
L81:
  mov    %ebp,%r12d
  mov    %ecx,%r13d
  jmp    L63
L124:
  mov    %r12d,%edx
  or     %r13d,%edx
  js     L66
  movslq %r13d,%r14
  movslq %r12d,%r15
  mov    %r15,%rdx
  shl    $0x5,%rdx
  add    %r15,%rdx
  lea    0x3790(%rdx),%rdx
  add    %rsp,%rdx
  cmpb   $0x23,-0x3770(%r14,%rdx,1)
  je     L66
  movslq %r13d,%r14
  movslq %r12d,%r15
  mov    %r15,%rdx
  shl    $0x5,%rdx
  add    %r15,%rdx
  add    %r14,%rdx
  cmpl   $0x0,0x470(%rsp,%rdx,4)
  jne    L163
  mov    %r15,%rdx
  shl    $0x5,%rdx
  add    %r15,%rdx
  add    %r14,%rdx
  movl   $0x1,0x470(%rsp,%rdx,4)
  movslq %r11d,%rdx
  mov    %r12d,0x1580(%rsp,%rdx,8)
  mov    %r13d,0x1584(%rsp,%rdx,8)
  add    $0x1,%r11d
  jmp    L163
L113:
  test   %r11d,%r11d
  jle    L205
L198:
  sub    $0x1,%r11d
  movslq %r11d,%rax
  mov    0x1580(%rsp,%rax,8),%esi
  mov    0x1584(%rsp,%rax,8),%ecx
  mov    $0x0,%eax
  lea    -0x1(%rsi),%ebp
  lea    0x1(%rsi),%r10d
  lea    0x1(%rcx),%ebx
  lea    -0x1(%rcx),%r9d
  jmp    L94
L205:
  lea    -0x24(%rdi,%rdi,8),%esi
  lea    D29(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x3788(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L125
  mov    $0x0,%eax
  add    $0x3798,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L125:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D12
type_infered: string
name: read_data
arguments: tag: D21
type_infered: string
name: read_data
arguments: tag: D29
type_infered: string

tool: D12: %d

tool: D21: %c

tool: D29: %d


assistant: ```c
int main() {
  int check[33][33], pilha[1089][2], atual[2];
  int n, nparedes, topo;
  int lin, col;
  char a[33][33];
  char ch;
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      while (scanf("%c", &ch) && ch == '\n')
        ;
      a[i][j] = ch;
      check[i][j] = 0;
    }
  if (0) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++)
        printf("(%c ", a[i][j]);
      printf("\n");
    }
  }
  check[0][0] = 1;
  pilha[0][0] = 0;
  pilha[0][1] = 0;
  check[n - 1][n - 1] = 1;
  pilha[1][0] = n - 1;
  pilha[1][1] = n - 1;
  topo = 2;
  nparedes = 0;
  while (topo > 0) {
    atual[0] = pilha[topo - 1][0];
    atual[1] = pilha[topo - 1][1];
    if (0) {
      printf("%d\n", nparedes);
      for (j = 0; j < topo; j++)
        printf("%d %d, ", pilha[j][0], pilha[j][1]);
      printf(" => atual %d %d\n", atual[0], atual[1]);
    }
    topo--;
    for (j = 0; j < 4; j++) {
      switch (j) {
      case 0:
        lin = atual[0];
        col = atual[1] + 1;
        break;
      case 1:
        lin = atual[0];
        col = atual[1] - 1;
        break;
      case 2:
        lin = atual[0] - 1;
        col = atual[1];
        break;
      case 3:
        lin = atual[0] + 1;
        col = atual[1];
        break;
      }
      if (lin >= n || col >= n || lin < 0 || col < 0 || a[lin][col] == '#')
        nparedes++;
      else if (!check[lin][col]) {
        check[lin][col] = 1;
        pilha[topo][0] = lin;
        pilha[topo][1] = col;
        topo++;
      }
    }
  }
  printf("%d\n", (nparedes - 4) * 9);
  return 0;
}
```