user: Please show me the C implementation that matches the assembly code listed below:

```asm
<check2dsurface>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %rdx,%r12
  mov    %rcx,%rbp
  mov    %r8d,%ebx
  mov    %r9d,0x14(%rsp)
  mov    (%rdi),%r14d
  mov    (%rdx),%eax
  lea    (%rax,%rax,2),%edx
  test   %edx,%edx
  jle    L60
  mov    %rcx,%rax
  lea    -0x1(%rdx),%edx
  lea    0x4(%rcx,%rdx,4),%rdx
L237:
  sub    %ebx,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L237
L60:
  lea    0x0(,%r14,4),%edi
  call   <libaft_malloc@plt>
  mov    %rax,%r13
  mov    %rax,%rdx
  mov    0x8(%rsp),%rsi
  mov    %r14d,%edi
  call   <check_xyz@plt>
  test   %rax,%rax
  jne    L246
  cmpl   $0x0,0x60(%rsp)
  jne    L228
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  mov    0x60(%rsp),%r15d
  test   %rax,%rax
  je     L90
L269:
  cmpl   $0x0,0x14(%rsp)
  je     L78
  mov    $0x0,%r15d
  jmp    L173
L228:
  lea    D36(%rip),%rdi
  call   <libaft_3d_warn@plt>
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  mov    $0x0,%r15d
  test   %rax,%rax
  jne    L269
L181:
  lea    D39(%rip),%rdi
  call   <libaft_3d_warn@plt>
  jmp    L90
L246:
  cmpl   $0x0,0x14(%rsp)
  jne    L175
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  test   %rax,%rax
  je     L46
  mov    $0x1,%r15d
L147:
  add    $0x1,%r15d
L90:
  mov    %r13,%rdi
  call   <libaft_free@plt>
  lea    (%r14,%r14,2),%edx
  test   %edx,%edx
  jle    L258
  mov    %rbp,%rax
  lea    -0x1(%rdx),%edx
  lea    0x4(%rbp,%rdx,4),%rdx
L137:
  add    %ebx,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L137
L258:
  mov    %r15d,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L175:
  mov    %r13,%r8
  mov    %rbp,%rcx
  mov    %r12,%rdx
  mov    0x8(%rsp),%rsi
  mov    0x18(%rsp),%rdi
  call   <fix_xyz@plt>
  test   %rax,%rax
  jne    L91
  cmpl   $0x0,0x60(%rsp)
  jne    L124
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  mov    0x60(%rsp),%r15d
  test   %rax,%rax
  je     L90
  jmp    L173
L124:
  lea    D15(%rip),%rdi
  call   <libaft_3d_warn@plt>
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  mov    $0x0,%r15d
  test   %rax,%rax
  je     L181
  jmp    L173
L46:
  cmpl   $0x0,0x60(%rsp)
  je     L84
  mov    $0x1,%r15d
  jmp    L181
L78:
  mov    0x14(%rsp),%r15d
  jmp    L147
L84:
  mov    $0x1,%r15d
  jmp    L90
L91:
  mov    (%r12),%r14d
  mov    0x60(%rsp),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r14d,%edi
  call   <check_tri@plt>
  test   %rax,%rax
  je     L46
  mov    $0x1,%r15d
L173:
  mov    %rbp,%rcx
  mov    %r12,%rdx
  mov    0x8(%rsp),%rsi
  mov    0x18(%rsp),%rdi
  call   <fix_tri@plt>
  test   %rax,%rax
  jne    L147
  cmpl   $0x0,0x60(%rsp)
  je     L90
  lea    D11(%rip),%rdi
  call   <libaft_3d_warn@plt>
  jmp    L90
```

tool_calls: name: unpack_data
arguments: tag: D36
type_infered: string
name: unpack_data
arguments: tag: D39
type_infered: string
name: unpack_data
arguments: tag: D15
type_infered: string
name: unpack_data
arguments: tag: D11
type_infered: string

tool: D36: Check: xyz coords - OK


tool: D39: Check: surface topology - OK


tool: D15: Check: updated xyz coords and topology


tool: D11: 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;
}
```