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

```asm
<pjf_rmdir>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  lea    -0x38(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <lstat@plt>
  test   %rax,%rax
  jns    L91
  mov    $0x0,%eax
  jmp    L118
L91:
  mov    -0x38(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L104
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  jne    L2
  mov    $0x0,%eax
  jmp    L118
L175:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  lea    D5(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L122
  jmp    L2
L122:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L52
  jmp    L2
L52:
  cmpq   $0x0,-0x50(%rbp)
  je     L127
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x50(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L127
  jmp    L2
L127:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %rbx,%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <pjf_malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x20(%rbp),%rax
  lea    D25(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x50(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <pjf_rmdir>
  mov    %eax,-0x34(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  cmpl   $0x0,-0x34(%rbp)
  jne    L2
  mov    $0x0,%eax
  jmp    L118
L2:
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L175
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <rmdir@plt>
  test   %rax,%rax
  je     L134
  cmpq   $0x0,-0x50(%rbp)
  jne    L134
  mov    $0x0,%eax
  jmp    L118
L104:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <unlink@plt>
  test   %rax,%rax
  je     L134
  mov    $0x0,%eax
  jmp    L118
L134:
  mov    $0x1,%eax
L118:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L44
  call   <__stack_chk_fail@plt>
L44:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D5
type_guessed: string
name: unpack_data
arguments: label: D2
type_guessed: string
name: unpack_data
arguments: label: D25
type_guessed: string

tool: D5: .

tool: D2: ..

tool: D25: /

assistant: ```c
int pjf_rmdir(const char *path, const char *skip) {
  struct stat statbuf;
  struct dirent *dirp;
  DIR *subd;
  char *newpath;
  int upret;
  if (lstat(path, &statbuf) < 0)
    return 0;
  if (S_ISDIR(statbuf.st_mode)) {
    subd = opendir(path);
    if (!subd)
      return 0;
    while ((dirp = readdir(subd))) {
      if ((strcmp((dirp->d_name), (".")) == 0))
        continue;
      if ((strcmp((dirp->d_name), ("..")) == 0))
        continue;
      if (skip && (strcmp((dirp->d_name), (skip)) == 0))
        continue;
      newpath = pjf_malloc(strlen(path) + strlen(dirp->d_name) + 2);
      strcpy(newpath, path);
      strcat(newpath, "/");
      strcat(newpath, dirp->d_name);
      upret = pjf_rmdir(newpath, skip);
      free(newpath);
      if (!upret)
        return 0;
    }
    closedir(subd);
    if (rmdir(path) != 0 && !skip)
      return 0;
  } else {
    if (unlink(path) != 0)
      return 0;
  }
  return 1;
}
```