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

```asm
<totalNQueens>:
  endbr64
  movslq %edi,%rdx
  push   %r15
  push   %r14
  mov    %rdx,%rdi
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  lea    (%r12,%r12,1),%ebx
  lea    -0x1(%rbx),%r15d
  movslq %r15d,%r14
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %rdx,0x8(%rsp)
  movl   $0x0,0x14(%rsp)
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,%r13
  call   <malloc@plt>
  mov    %rax,%r14
  test   %r12d,%r12d
  jle    L35
  mov    0x8(%rsp),%rdx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  test   %r15d,%r15d
  jle    L47
  lea    -0x2(%rbx),%r15d
  mov    $0x1,%eax
  mov    %r14,%rdi
  add    $0x1,%r15
  cmp    $0x1,%ebx
  cmovle %rax,%r15
  xor    %esi,%esi
  mov    %r15,%rdx
  call   <memset@plt>
  mov    %r15,%rdx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <memset@plt>
L47:
  mov    %r12d,%edi
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <init_board@plt>
  mov    %r12d,%esi
  movslq %eax,%r15
  xor    %eax,%eax
  mov    %r15,%rdi
  call   <clear_board@plt>
  lea    0x14(%rsp),%rdi
  sub    $0x8,%rsp
  xor    %eax,%eax
  push   $0x0
  mov    %r12d,%edx
  mov    %r14,%r9
  mov    %r13,%r8
  mov    %rbp,%rcx
  mov    %r15,%rsi
  call   <aux@plt>
  pop    %rax
  pop    %rdx
  nopl   0x0(%rax,%rax,1)
L44:
  mov    (%r15,%rbx,8),%rdi
  add    $0x1,%rbx
  call   <free@plt>
  cmp    %ebx,%r12d
  jg     L44
L10:
  mov    %r15,%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x14(%rsp),%eax
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L56
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L35:
  test   %r15d,%r15d
  jle    L31
  lea    -0x2(%rbx),%r15d
  mov    $0x1,%eax
  mov    %r14,%rdi
  add    $0x1,%r15
  cmp    $0x1,%ebx
  cmovle %rax,%r15
  xor    %esi,%esi
  mov    %r15,%rdx
  call   <memset@plt>
  mov    %r15,%rdx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <memset@plt>
L31:
  mov    %r12d,%edi
  xor    %eax,%eax
  call   <init_board@plt>
  mov    %r12d,%esi
  movslq %eax,%r15
  xor    %eax,%eax
  mov    %r15,%rdi
  call   <clear_board@plt>
  lea    0x14(%rsp),%rdi
  sub    $0x8,%rsp
  xor    %eax,%eax
  push   $0x0
  mov    %rbp,%rcx
  mov    %r15,%rsi
  mov    %r14,%r9
  mov    %r13,%r8
  mov    %r12d,%edx
  call   <aux@plt>
  pop    %rcx
  pop    %rsi
  jmp    L10
L56:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int totalNQueens(int n) {
  int num;
  char *col_mask;
  char *diag_mask;
  char *anti_diag_mask;
  char **board;
  num = 0;
  col_mask = malloc(sizeof(char) * n);
  diag_mask = malloc(sizeof(char) * (2 * n - 1));
  anti_diag_mask = malloc(sizeof(char) * (2 * n - 1));
  int i;
  for (i = 0; i < n; ++i) {
    col_mask[i] = 0;
  }
  for (i = 0; i < 2 * n - 1; ++i) {
    diag_mask[i] = anti_diag_mask[i] = 0;
  }
  board = init_board(n);
  clear_board(board, n);
  aux(&num, board, n, col_mask, diag_mask, anti_diag_mask, 0);
  for (i = 0; i < n; ++i) {
    free(board[i]);
  }
  free(board);
  free(col_mask);
  free(diag_mask);
  free(anti_diag_mask);
  return num;
}
```