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

```asm
<check_realpath_recurse>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x40,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%r12
  mov    D34(%rip),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%ebx
  movslq %ebx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x38(%rbp)
  movslq %ebx,%rax
  mov    %rax,%r10
  mov    $0x0,%r11d
  movslq %ebx,%rax
  mov    %rax,%r8
  mov    $0x0,%r9d
  movslq %ebx,%rax
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L136:
  cmp    %rdx,%rsp
  je     L121
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L136
L121:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L14
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L14:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x48(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <check_realpath_step_by_step@plt>
  cmpl   $0x0,-0x4c(%rbp)
  jle    L122
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L33
  mov    D20(%rip),%rax
  mov    (%rax),%rdx
  mov    D5(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L39
  mov    D20(%rip),%rax
  mov    (%rax),%rdx
  mov    D46(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L39
  mov    $0xe7,%edi
  call   <e@plt>
  jmp    L39
L44:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x48(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %ebx,%esi
  mov    %rax,%rdi
  call   <pathncat@plt>
  test   %eax,%eax
  jne    L131
  mov    $0xef,%edi
  call   <e@plt>
  jmp    L33
L131:
  mov    -0x4c(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <check_realpath_recurse>
L33:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L44
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  test   %rax,%rax
  jns    L138
  mov    $0xf6,%edi
  call   <e@plt>
L138:
  mov    %r12,%rsp
  jmp    L93
L39:
  nop
L122:
  mov    %r12,%rsp
L93:
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L22
  call   <__stack_chk_fail@plt>
L22:
  lea    -0x10(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

assistant: ```c
void check_realpath_recurse(const char *path, int depth) {
  DIR *dir;
  struct dirent *dirent;
  char pathsub[PATH_MAX + 1];
  check_realpath_step_by_step(path, 0);
  if (depth < 1)
    return;
  if (!(dir = opendir(path))) {
    if (errno != ENOENT && errno != ENOTDIR)
      (e(231));
    return;
  }
  while (dirent = readdir(dir)) {
    if (!pathncat(pathsub, sizeof(pathsub), path, dirent->d_name)) {
      (e(239));
      continue;
    }
    check_realpath_recurse(pathsub, depth - 1);
  }
  if (closedir(dir) < 0)
    (e(246));
}
```