// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::compare_disk_contents(DiskContents&, std::basic_ofstream<char, std::char_traits<char>>&)
bool DiskContents::compare_disk_contents(DiskContents &compare_disk, ofstream &diff_file) {
  bool retValue = true;

  if (disk_path.compare(compare_disk.disk_path) == 0) {
    return retValue;
  }

  string base_path = "/mnt/pmem0";
  get_contents(base_path.c_str());

 /* if (compare_disk.mount_disk() != 0) {
    cout << "Mounting " << compare_disk.disk_path << " failed" << endl;
  }*/

  compare_disk.get_contents(compare_disk.get_mount_point().c_str());

  // Compare the size of contents
  if (contents.size() != compare_disk.contents.size()) {
    diff_file << "DIFF: Mismatch" << endl;
    diff_file << "Unequal #entries in " << disk_path << ", " << compare_disk.disk_path;
    diff_file << endl << endl;
    diff_file << disk_path << " contains:" << endl;
    for (auto &i : contents) {
      diff_file << i.first << endl;
    }
    diff_file << endl;

    diff_file << compare_disk.disk_path << " contains:" << endl;
    for (auto &i : compare_disk.contents) {
      diff_file << i.first << endl;
    }
    diff_file << endl;
    retValue = false;
  }

  // entry-wise comparision
  for (auto &i : contents) {
    fileAttributes i_fa = i.second;
    if (compare_disk.contents.find((i.first)) == compare_disk.contents.end()) {
      diff_file << "DIFF: Missing " << i.first << endl;
      diff_file << "Found in " << disk_path << " only" << endl;
      diff_file << i_fa << endl << endl;
      retValue = false;
      continue;
    }
    fileAttributes j_fa = compare_disk.contents[(i.first)];
    if (!(i_fa.compare_dir_attr(j_fa.dir_attr)) ||
          !(i_fa.compare_stat_attr(j_fa.stat_attr))) {
        diff_file << "DIFF: Content Mismatch " << i.first << endl << endl;
        diff_file << disk_path << ":" << endl;
        diff_file << i_fa << endl << endl;
        diff_file << compare_disk.disk_path << ":" << endl;
        diff_file << j_fa << endl << endl;
        retValue = false;
        continue;
    }
    // compare user data if the entry corresponds to a regular files
    if (i_fa.is_regular_file()) {
      // check md5sum of the file contents
      if (i_fa.compare_md5sum(j_fa.md5sum) != 0) {
        diff_file << "DIFF : Data Mismatch of " << (i.first) << endl;
        diff_file << disk_path << " has md5sum " << i_fa.md5sum << endl;
        diff_file << compare_disk.disk_path << " has md5sum " << j_fa.md5sum;
        diff_file << endl << endl;
        retValue = false;
      }
    }
  }
  //compare_disk.unmount_and_delete_mount_point();
  return retValue;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x538, %rsp            # imm = 0x538
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
addq $0x8, %rdi
addq $0x8, %rsi
movq %rdi, -0x38(%rbp)
movq %rsi, -0x48(%rbp)
callq 0x5040
testl %eax, %eax
je 0xed42
leaq 0x3589(%rip), %rsi      # 0x121b2
leaq -0x90(%rbp), %rbx
leaq -0x278(%rbp), %rdx
movq %rbx, %rdi
callq 0x51c0
movq (%rbx), %rsi
movq %r13, %rdi
callq 0xe83c
leaq 0x28(%r12), %rsi
leaq -0x278(%rbp), %rdi
callq 0x5580
movq -0x278(%rbp), %rsi
movq %r12, %rdi
callq 0xe83c
leaq -0x278(%rbp), %rdi
callq 0x58a8
movq 0x90(%r13), %rax
cmpq 0x90(%r12), %rax
sete %al
movl %eax, -0x3c(%rbp)
je 0xedaf
leaq 0x39a7(%rip), %rsi      # 0x1263f
movq %r15, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq 0x399f(%rip), %rsi      # 0x1264e
movq %r15, %rdi
callq 0x5480
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x5410
leaq 0x3999(%rip), %rsi      # 0x12663
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0x5410
movq %r15, %rdi
callq 0x5240
movq %rax, %rdi
callq 0x5240
movq %r15, %rdi
movq -0x38(%rbp), %rsi
callq 0x5410
leaq 0x3965(%rip), %rsi      # 0x12666
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq 0x80(%r13), %rbx
leaq 0x70(%r13), %r14
cmpq %r14, %rbx
je 0xed49
leaq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
callq 0x5330
movq %rax, %rbx
jmp 0xed1c
movb $0x1, %al
jmp 0xf00a
movq %r15, %rdi
callq 0x5240
movq %r15, %rdi
movq -0x48(%rbp), %rsi
callq 0x5410
leaq 0x3902(%rip), %rsi      # 0x12666
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
movq 0x80(%r12), %rbx
leaq 0x70(%r12), %r14
cmpq %r14, %rbx
je 0xeda7
leaq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
callq 0x5330
movq %rax, %rbx
jmp 0xed81
movq %r15, %rdi
callq 0x5240
movq %r15, -0x30(%rbp)
leaq 0x68(%r12), %rcx
movq %rcx, -0x58(%rbp)
movq 0x80(%r13), %r15
addq $0x70, %r13
movq %r13, -0x70(%rbp)
addq $0x70, %r12
movq %r12, -0x68(%rbp)
movl $0x1a8, %eax            # imm = 0x1A8
leaq -0x440(%rbp), %rcx
addq %rax, %rcx
movq %rcx, -0x50(%rbp)
leaq -0x278(%rbp), %r14
addq %r14, %rax
movq %rax, -0x60(%rbp)
leaq -0xb0(%rbp), %r13
cmpq -0x70(%rbp), %r15
je 0xeffb
leaq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x10230
leaq 0x20(%r15), %rbx
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x1075a
cmpq -0x68(%rbp), %rax
je 0xf07d
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x10188
leaq -0x440(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x10230
pushq $0x23
popq %rcx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0xe296
testb %al, %al
je 0xf01e
movq -0x158(%rbp), %rax
cmpq -0x320(%rbp), %rax
jne 0xf01e
movl -0x310(%rbp), %eax
cmpl %eax, -0x148(%rbp)
jne 0xf01e
movq -0x318(%rbp), %rcx
cmpq %rcx, -0x150(%rbp)
jne 0xf01e
movl -0x30c(%rbp), %ecx
cmpl %ecx, -0x144(%rbp)
jne 0xf01e
movl -0x308(%rbp), %ecx
cmpl %ecx, -0x140(%rbp)
jne 0xf01e
movq -0x2f8(%rbp), %rcx
cmpq %rcx, -0x130(%rbp)
jne 0xf01e
movq -0x2f0(%rbp), %rcx
cmpq %rcx, -0x128(%rbp)
jne 0xf01e
movq -0x2e8(%rbp), %rcx
cmpq %rcx, -0x120(%rbp)
jne 0xf01e
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xefd7
movq %r13, %rdi
movq -0x50(%rbp), %rsi
callq 0x5580
movq %r14, %rdi
movq %r13, %r12
movq %r13, %rsi
callq 0xe326
movl %eax, %r14d
movq %r12, %rdi
callq 0x58a8
testb %r14b, %r14b
leaq -0x278(%rbp), %r14
je 0xefd7
movq -0x30(%rbp), %rdi
leaq 0x3759(%rip), %rsi      # 0x126a8
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
leaq 0x3743(%rip), %rsi      # 0x126c1
callq 0x5480
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
leaq 0x3713(%rip), %rsi      # 0x126c1
callq 0x5480
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x5410
movq -0x30(%rbp), %rdi
callq 0x5240
movq %rax, %rdi
callq 0x5240
movl $0x0, -0x3c(%rbp)
leaq -0x440(%rbp), %rdi
callq 0xe164
movq %r14, %rdi
callq 0xe164
movq %r15, %rdi
callq 0x5330
movq %rax, %r15
jmp 0xedfb
leaq -0x90(%rbp), %rdi
callq 0x58a8
movl -0x3c(%rbp), %eax
andb $0x1, %al
addq $0x538, %rsp            # imm = 0x538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x366b(%rip), %rsi      # 0x12690
movq -0x30(%rbp), %rdi
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq %rax, %rdi
callq 0x5240
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5410
leaq 0x3612(%rip), %rsi      # 0x1266f
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq -0x278(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xe357
leaq 0x35ed(%rip), %rsi      # 0x12671
movq -0x30(%rbp), %rdi
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
leaq 0x35d9(%rip), %rsi      # 0x12680
movq -0x30(%rbp), %rdi
callq 0x5480
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x5410
leaq 0x35c7(%rip), %rsi      # 0x1268a
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq -0x278(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xe357
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
callq 0x58a8
jmp 0xf138
jmp 0xf111
jmp 0xf111
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x58a8
jmp 0xf120
jmp 0xf111
jmp 0xf116
jmp 0xf116
jmp 0xf111
movq %rax, %rbx
jmp 0xf138
movq %rax, %rbx
jmp 0xf12c
jmp 0xf11d
movq %rax, %rbx
leaq -0x440(%rbp), %rdi
callq 0xe164
leaq -0x278(%rbp), %rdi
callq 0xe164
leaq -0x90(%rbp), %rdi
callq 0x58a8
movq %rbx, %rdi
callq 0x5780