// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::deleteFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_ofstream<char, std::char_traits<char>>&)
bool DiskContents::deleteFiles(string path, ofstream &diff_file) {
  if (path.empty()) {
    return true;
  }

  if (isEmptyDirOrFile(path) == true) {
    if (path.compare("/mnt/pmem0") == 0) {
      return true;
    }
    if (isFile(path) == true) {
      return (unlink(path.c_str()) == 0);
    } else {
      return (rmdir(path.c_str()) == 0);
    }
  }

  DIR *directory = opendir(path.c_str());
  if (directory == NULL) {
    cout << "Couldn't open the directory " << path << endl;
    diff_file << "Couldn't open the directory " << path << endl;
    return false;
  }

  struct dirent *dir_entry;
  while (dir_entry = readdir(directory)) {
    if ((strcmp(dir_entry->d_name, ".") == 0) ||
        (strcmp(dir_entry->d_name, "..") == 0)) {
      continue;
    }

    string subpath = path + "/" + string(dir_entry->d_name);
    bool subpathIsFile = isFile(subpath);
    bool res = deleteFiles(subpath, diff_file);
    if (!res) {
      closedir(directory);
      diff_file << "Couldn't remove directory " << subpath << " " << strerror(errno) << endl;
      cout << "Couldn't remove directory " << subpath << " " << strerror(errno) << endl;
      return res;
    }

    if (!subpathIsFile) {
      if (rmdir(subpath.c_str()) < 0) {
        diff_file << "Couldn't remove directory " << subpath << " "  << strerror(errno) << endl;
        cout << "Couldn't remove directory " << subpath << " " << strerror(errno) << endl;
        return false;
      }
    }
  }
  closedir(directory);
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, -0x38(%rbp)
movq %rdi, -0x70(%rbp)
movb $0x1, %r15b
cmpq $0x0, 0x8(%rsi)
je 0xfe09
movq %rsi, %rbx
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
callq 0x5580
movq %r14, %rdi
callq 0xf9cb
movl %eax, %r14d
leaq -0xb0(%rbp), %rdi
callq 0x58a8
testb %r14b, %r14b
je 0xfb46
leaq 0x26bb(%rip), %rsi      # 0x121b2
movq %rbx, %rdi
callq 0x5140
testl %eax, %eax
je 0xfe09
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5580
movq %r14, %rdi
callq 0xfa23
movl %eax, %r14d
leaq -0x90(%rbp), %rdi
callq 0x58a8
movq (%rbx), %rdi
testb %r14b, %r14b
je 0xfcb8
callq 0x5230
jmp 0xfcbd
movq (%rbx), %rdi
callq 0x5640
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0xfc6b
movq %rbx, -0x68(%rbp)
leaq -0xf0(%rbp), %r13
leaq -0xd0(%rbp), %r12
movq -0x40(%rbp), %rdi
callq 0x5670
testq %rax, %rax
je 0xfcc8
movq %rax, %r14
cmpb $0x2e, 0x13(%rax)
jne 0xfb9d
cmpb $0x0, 0x14(%r14)
je 0xfb6d
cmpb $0x2e, 0x14(%r14)
jne 0xfb9d
cmpb $0x0, 0x15(%r14)
je 0xfb6d
movq %r13, %rbx
addq $0x13, %r14
leaq -0x130(%rbp), %r15
movq %r15, %rdi
movq -0x68(%rbp), %rsi
leaq 0x2a61(%rip), %rdx      # 0x1261a
callq 0x1014f
leaq -0x110(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq -0x29(%rbp), %rdx
callq 0x51c0
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xd833
movq %r13, %rdi
callq 0x58a8
movq %r15, %rdi
callq 0x58a8
movq %rbx, %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5580
movq %r13, %rdi
callq 0xfa23
movl %eax, %r14d
movq %r13, %rdi
callq 0x58a8
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
callq 0x5580
movq -0x70(%rbp), %rdi
movq %r12, %rsi
movq -0x38(%rbp), %rdx
callq 0xfa98
movl %eax, %r15d
movq %r12, %rdi
callq 0x58a8
testb %r15b, %r15b
je 0xfcd9
testb %r14b, %r14b
jne 0xfc5d
movq -0x60(%rbp), %rdi
callq 0x51e0
testl %eax, %eax
js 0xfd62
leaq -0x60(%rbp), %rdi
callq 0x58a8
jmp 0xfb6d
movq 0xa34e(%rip), %rdi      # 0x19fc0
leaq 0x2af8(%rip), %r14      # 0x12771
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
jmp 0xfe06
callq 0x51e0
testl %eax, %eax
sete %r15b
jmp 0xfe09
movq -0x40(%rbp), %rdi
callq 0x56d0
movb $0x1, %r15b
jmp 0xfe09
movq -0x40(%rbp), %rdi
callq 0x56d0
leaq 0x2aa5(%rip), %rsi      # 0x1278e
movq -0x38(%rbp), %rdi
callq 0x5480
leaq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x5410
leaq 0x295f(%rip), %rsi      # 0x12664
movq %rax, %rdi
callq 0x5480
movq %rax, %r14
callq 0x5050
movq %rax, %rbx
movl (%rax), %edi
callq 0x5180
movq %r14, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq 0xa287(%rip), %rdi      # 0x19fc0
leaq 0x2a4e(%rip), %rsi      # 0x1278e
callq 0x5480
leaq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x5410
leaq 0x290c(%rip), %rsi      # 0x12664
movq %rax, %rdi
callq 0x5480
jmp 0xfde0
leaq 0x2a25(%rip), %rsi      # 0x1278e
movq -0x38(%rbp), %rdi
callq 0x5480
leaq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x5410
leaq 0x28df(%rip), %rsi      # 0x12664
movq %rax, %rdi
callq 0x5480
movq %rax, %r14
callq 0x5050
movq %rax, %rbx
movl (%rax), %edi
callq 0x5180
movq %r14, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq 0xa207(%rip), %rdi      # 0x19fc0
leaq 0x29ce(%rip), %rsi      # 0x1278e
callq 0x5480
leaq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x5410
leaq 0x288c(%rip), %rsi      # 0x12664
movq %rax, %rdi
callq 0x5480
movq %rax, %r14
movl (%rbx), %edi
callq 0x5180
movq %r14, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq -0x60(%rbp), %rdi
callq 0x58a8
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0xfe7b
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
jmp 0xfe7b
jmp 0xfe63
jmp 0xfe63
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x58a8
jmp 0xfe5a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0xfe72
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0xfe7b
movq %rax, %rbx
jmp 0xfe77
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x58a8
leaq -0x60(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780