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

```asm
<check2dsurface>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8d,-0x44(%rbp)
  mov    %r9d,-0x48(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L120
L17:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x40(%rbp),%rax
  add    %rax,%rcx
  mov    %edx,%eax
  sub    -0x44(%rbp),%eax
  mov    %eax,(%rcx)
L120:
  mov    -0xc(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L17
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <libaft_malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x8(%rbp),%rdx
  mov    -0x30(%rbp),%rcx
  mov    -0x10(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <check_xyz@plt>
  test   %rax,%rax
  jne    L9
  cmpl   $0x0,0x10(%rbp)
  je     L28
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <libaft_3d_warn@plt>
  jmp    L28
L9:
  cmpl   $0x0,-0x48(%rbp)
  je     L144
  mov    -0x8(%rbp),%rdi
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <fix_xyz@plt>
  test   %rax,%rax
  jne    L144
  cmpl   $0x0,0x10(%rbp)
  je     L28
  lea    D34(%rip),%rax
  mov    %rax,%rdi
  call   <libaft_3d_warn@plt>
  jmp    L28
L144:
  addl   $0x1,-0x14(%rbp)
L28:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x44(%rbp),%edx
  mov    -0x40(%rbp),%rsi
  mov    -0xc(%rbp),%eax
  mov    0x10(%rbp),%ecx
  mov    %eax,%edi
  call   <check_tri@plt>
  test   %rax,%rax
  jne    L113
  cmpl   $0x0,0x10(%rbp)
  je     L172
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <libaft_3d_warn@plt>
  jmp    L172
L113:
  cmpl   $0x0,-0x48(%rbp)
  je     L145
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <fix_tri@plt>
  test   %rax,%rax
  jne    L145
  cmpl   $0x0,0x10(%rbp)
  je     L172
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  call   <libaft_3d_warn@plt>
  jmp    L172
L145:
  addl   $0x1,-0x14(%rbp)
L172:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <libaft_free@plt>
  movl   $0x0,-0x18(%rbp)
  jmp    L121
L103:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%ecx
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    -0x44(%rbp),%edx
  add    %ecx,%edx
  mov    %edx,(%rax)
L121:
  mov    -0xc(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L103
  mov    -0x14(%rbp),%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D4
type: string
name: read_data
arguments: label: D34
type: string
name: read_data
arguments: label: D5
type: string
name: read_data
arguments: label: D24
type: string

tool: D4: Check: xyz coords - OK


tool: D34: Check: updated xyz coords and topology


tool: D5: Check: surface topology - OK


tool: D24: Check: updated surface topology


assistant: ```c
int check2dsurface(int *pnV, double *vertex, int *pnF, int *face, int indshift, int autofix, int verbose) {
  int nV = *pnV, nF = *pnF, i;
  int *index;
  int result;
  for (i = 0; i < 3 * nF; face[i++] -= indshift)
    ;
  index = (int *)libaft_malloc(sizeof(int) * nV);
  result = 0;
  if (check_xyz(nV, vertex, index) == 0) {
    if (verbose)
      libaft_3d_warn("Check: xyz coords - OK\n");
  } else if ((autofix) && (fix_xyz(pnV, vertex, pnF, face, index) == 0)) {
    if (verbose)
      libaft_3d_warn("Check: updated xyz coords and topology\n");
  } else {
    result++;
  }
  nV = *pnV;
  nF = *pnF;
  if (check_tri(nF, face, indshift, verbose) == 0) {
    if (verbose)
      libaft_3d_warn("Check: surface topology - OK\n");
  } else if ((autofix) && (fix_tri(pnV, vertex, pnF, face) == 0)) {
    if (verbose)
      libaft_3d_warn("Check: updated surface topology\n");
  } else {
    result++;
  }
  libaft_free(index);
  for (i = 0; i < 3 * nF; face[i++] += indshift)
    ;
  return result;
}
```