// File: /workspace/github_cpp_makefile_star2_O3/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 $0xf8, %rsp
movq %rdx, %r13
movq %rdi, -0x98(%rbp)
movq 0x8(%rsi), %rdx
movb $0x1, %al
testq %rdx, %rdx
je 0x1332c
movq %rsi, %rbx
leaq -0x108(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rsi), %rsi
addq %rsi, %rdx
leaq -0x118(%rbp), %r14
movq %r14, %rdi
callq 0x7fc8
movq %r14, %rdi
callq 0x12be6
movl %eax, %r14d
movq -0x118(%rbp), %rdi
cmpq %r15, %rdi
je 0x12d50
callq 0x5460
testb %r14b, %r14b
je 0x12dc4
leaq 0x2486(%rip), %rsi      # 0x151e2
movq %rbx, %rdi
callq 0x5130
testl %eax, %eax
movb $0x1, %al
je 0x1332c
leaq -0xe8(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
callq 0x7fc8
movq %r14, %rdi
callq 0x12c34
movl %eax, %r14d
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x12dae
callq 0x5460
movq (%rbx), %rdi
testb %r14b, %r14b
je 0x130d9
callq 0x5210
jmp 0x130de
movq %r13, -0x50(%rbp)
movq (%rbx), %rdi
callq 0x5660
testq %rax, %rax
je 0x13030
movq %rax, %r13
movq %rax, %rdi
callq 0x5690
testq %rax, %rax
je 0x13021
movq %rax, %r14
leaq -0xb8(%rbp), %r12
cmpb $0x2e, 0x13(%r14)
jne 0x12e1b
cmpb $0x0, 0x14(%r14)
je 0x1300d
cmpb $0x2e, 0x14(%r14)
jne 0x12e1b
cmpb $0x0, 0x15(%r14)
je 0x1300d
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x70(%rbp), %r15
movq %r15, %rdi
callq 0x7fc8
movq %r15, %rdi
leaq 0x27c7(%rip), %rsi      # 0x1560a
callq 0x5860
addq $0x13, %r14
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq %r14, %rdi
callq 0x51f0
leaq (%rax,%r14), %rdx
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x8066
movq -0x70(%rbp), %rcx
movl $0xf, %edi
leaq -0x60(%rbp), %rax
cmpq %rax, %rcx
leaq -0xd8(%rbp), %r14
movq %r12, %r15
je 0x12e92
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %r8
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x12ec4
movl $0xf, %edi
leaq -0x80(%rbp), %r9
cmpq %r9, %rsi
je 0x12ebf
movq -0x80(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x12ecf
leaq -0x70(%rbp), %rdi
callq 0x5160
jmp 0x12edf
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x54e0
leaq -0x38(%rbp), %rsi
movq %rsi, -0x48(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x12f00
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x12f06
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x12f37
callq 0x5460
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x12f49
callq 0x5460
leaq -0xc8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x7fc8
movq %r14, %rdi
callq 0x12c34
movl %eax, %r14d
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x12f8d
callq 0x5460
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7fc8
movq -0x98(%rbp), %rdi
movq %r15, %rsi
movq -0x50(%rbp), %rdx
callq 0x12ce4
movl %eax, %r15d
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x12fdc
callq 0x5460
testb %r15b, %r15b
je 0x130e8
testb %r14b, %r14b
jne 0x12ffb
movq -0x48(%rbp), %rdi
callq 0x51e0
testl %eax, %eax
js 0x13169
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1300d
callq 0x5460
movq %r13, %rdi
callq 0x5690
movq %rax, %r14
testq %rax, %rax
jne 0x12df7
movq %r13, %rdi
callq 0x56f0
movb $0x1, %al
jmp 0x1332c
movq 0x8f91(%rip), %r15      # 0x1bfc8
leaq 0x2723(%rip), %r14      # 0x15761
movl $0x1c, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x54f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x54f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
movl $0x1c, %edx
movq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x54f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x54f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
jmp 0x1332a
callq 0x51e0
testl %eax, %eax
sete %al
jmp 0x1332c
movq %r13, %rdi
callq 0x56f0
leaq 0x2687(%rip), %rsi      # 0x1577e
movl $0x1a, %edx
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
leaq -0x38(%rbp), %r12
callq 0x54f0
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %r14
leaq 0x252e(%rip), %rsi      # 0x15654
movl $0x1, %edx
movq %rax, %rdi
callq 0x54f0
callq 0x5060
movq %rax, %rbx
movl (%rax), %edi
callq 0x5190
testq %rax, %rax
je 0x13230
movq %rax, %r15
movq %rax, %rdi
callq 0x51f0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x54f0
jmp 0x1324a
leaq 0x260e(%rip), %rsi      # 0x1577e
movl $0x1a, %edx
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
leaq -0x38(%rbp), %r12
callq 0x54f0
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %r14
leaq 0x24b5(%rip), %rsi      # 0x15654
movl $0x1, %edx
movq %rax, %rdi
callq 0x54f0
callq 0x5060
movq %rax, %rbx
movl (%rax), %edi
callq 0x5190
movq %r14, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5220
movq 0x8df3(%rip), %rdi      # 0x1bfc8
leaq 0x25a2(%rip), %rsi      # 0x1577e
movl $0x1a, %edx
callq 0x54f0
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x8dd3(%rip), %rdi      # 0x1bfc8
callq 0x54f0
movq %rax, %r14
leaq 0x2450(%rip), %rsi      # 0x15654
movl $0x1, %edx
movq %rax, %rdi
callq 0x54f0
movl (%rbx), %edi
callq 0x5190
movq %r14, %rdi
movq %rax, %rsi
callq 0x5480
movq %rax, %rdi
callq 0x5220
jmp 0x1331c
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x5770
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
movq 0x8d50(%rip), %rdi      # 0x1bfc8
leaq 0x24ff(%rip), %rsi      # 0x1577e
movl $0x1a, %edx
callq 0x54f0
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x8d30(%rip), %rdi      # 0x1bfc8
callq 0x54f0
movq %rax, %r14
leaq 0x23ad(%rip), %rsi      # 0x15654
movl $0x1, %edx
movq %rax, %rdi
callq 0x54f0
movl (%rbx), %edi
callq 0x5190
testq %rax, %rax
je 0x132db
movq %rax, %rbx
movq %rax, %rdi
callq 0x51f0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x54f0
jmp 0x132f5
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x5770
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5300
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x1332a
callq 0x5460
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
jmp 0x13354
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r15, %rdi
jne 0x133c8
jmp 0x133cd
jmp 0x133ab
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
jmp 0x13385
jmp 0x133b8
jmp 0x133ab
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x133ae
callq 0x5460
jmp 0x133ae
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x133bb
callq 0x5460
jmp 0x133bb
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
jmp 0x133c3
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x133cd
callq 0x5460
movq %rbx, %rdi
callq 0x57c0
nop