// File: /workspace/github_cpp_makefile_star2_O3/williewillus[P]panda_scratchpad/src/checker/DiskContents.cpp
// Function: DiskContents::compare_file_contents(DiskContents&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, std::basic_ofstream<char, std::char_traits<char>>&)
bool DiskContents::compare_file_contents(DiskContents &compare_disk, string path,
    int offset, int length, ofstream &diff_file) {
  bool retValue = true;
  if (disk_path.compare(compare_disk.disk_path) == 0) {
    return retValue;
  }

  string base_path = "/mnt/pmem0" + path;
  /*if (compare_disk.mount_disk() != 0) {
    cout << "Mounting " << compare_disk.disk_path << " failed" << endl;
    return false;
  }*/
  string compare_disk_mount_point(compare_disk.get_mount_point());
  string compare_path = compare_disk_mount_point + path;

  fileAttributes base_fa, compare_fa;
  bool failed_stat = false;
  struct stat base_statbuf, compare_statbuf;
  if (stat(base_path.c_str(), &base_statbuf) == -1) {
    diff_file << "Failed stating the file " << base_path << endl;
    failed_stat = true;
  }
  if (stat(compare_path.c_str(), &compare_statbuf) == -1) {
    diff_file << "Failed stating the file " << compare_path << endl;
    failed_stat = true;
  }

  if (failed_stat) {
    //compare_disk.unmount_and_delete_mount_point();
    return false;
  }

  std::ifstream f1(base_path, std::ios::binary);
  std::ifstream f2(compare_path, std::ios::binary);

  if (!f1 || !f2) {
    cout << "Error opening input file streams " << base_path  << " and ";
    cout << compare_path << endl;
    //compare_disk.unmount_and_delete_mount_point();
    return false;
  }

  f1.seekg(offset, std::ifstream::beg);
  f2.seekg(offset, std::ifstream::beg);

  char * buffer_f1 = new char[length + 1];
  char * buffer_f2 = new char[length + 1];

  f1.read(buffer_f1, length);
  f2.read(buffer_f2, length);
  f1.close();
  f2.close();

  buffer_f1[length] = '\0';
  buffer_f2[length] = '\0';

  if (strcmp(buffer_f1, buffer_f2) == 0) {
    //compare_disk.unmount_and_delete_mount_point();
    return true;
  }

  diff_file << __func__ << " failed" << endl;
  diff_file << "Content Mismatch of file " << path << " from ";
  diff_file << offset << " of length " << length << endl;
  diff_file << base_path << " has " << buffer_f1 << endl;
  diff_file << compare_path << " has " << buffer_f2 << endl;
  //compare_disk.unmount_and_delete_mount_point();
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x938, %rsp            # imm = 0x938
movq %r9, %rbx
movl %r8d, %r14d
movl %ecx, %r12d
movq %rdx, %r13
movq %rsi, %r15
addq $0x8, %rdi
addq $0x8, %rsi
callq 0x5050
testl %eax, %eax
je 0x127bf
leaq 0x2ba3(%rip), %rsi      # 0x151e2
leaq -0x78(%rbp), %rdi
movq %r13, %rdx
callq 0xd1df
leaq -0x88(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rdi
callq 0x7fc8
leaq -0x58(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq %r13, %rdx
callq 0x13967
leaq -0x958(%rbp), %rdi
callq 0x106a4
leaq -0x790(%rbp), %rdi
callq 0x106a4
movq -0x78(%rbp), %rdi
leaq -0x5c8(%rbp), %rsi
callq 0x5410
cmpl $-0x1, %eax
je 0x127c6
movq -0x58(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x5410
cmpl $-0x1, %eax
je 0x12829
leaq -0x4a8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x4, %edx
callq 0x5700
leaq -0x2a0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x4, %edx
callq 0x5700
movq -0x4a8(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x488(%rbp,%rax)
jne 0x12722
movq -0x2a0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x280(%rbp,%rax)
je 0x128e1
movq 0x989f(%rip), %rdi      # 0x1bfc8
leaq 0x2fa7(%rip), %rsi      # 0x156d7
movl $0x21, %edx
callq 0x54f0
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq 0x987f(%rip), %rdi      # 0x1bfc8
callq 0x54f0
leaq 0x2fa4(%rip), %rsi      # 0x156f9
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x9857(%rip), %rdi      # 0x1bfc8
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
xorl %ebx, %ebx
leaq -0x2a0(%rbp), %rdi
callq 0x5100
leaq -0x4a8(%rbp), %rdi
callq 0x5100
jmp 0x12879
movb $0x1, %bl
jmp 0x128cd
leaq 0x2ef1(%rip), %rsi      # 0x156be
movl $0x18, %edx
movq %rbx, %rdi
callq 0x54f0
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %r14
movq (%rax), %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 -0x58(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x5410
cmpl $-0x1, %eax
jne 0x12877
leaq 0x2e8e(%rip), %rsi      # 0x156be
movl $0x18, %edx
movq %rbx, %rdi
callq 0x54f0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rbx, %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
xorl %ebx, %ebx
leaq -0x790(%rbp), %rdi
callq 0x10746
leaq -0x958(%rbp), %rdi
callq 0x10746
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128a3
callq 0x5460
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x128bb
callq 0x5460
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128cd
callq 0x5460
movl %ebx, %eax
addq $0x938, %rsp            # imm = 0x938
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r12d, %r15
leaq -0x4a8(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5590
leaq -0x2a0(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5590
leal 0x1(%r14), %eax
cmpl $-0x1, %r14d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovgel %eax, %ecx
movslq %ecx, %r15
movq %r15, %rdi
callq 0x5030
movq %rax, -0x38(%rbp)
movq %r15, %rdi
callq 0x5030
movq %rax, -0x30(%rbp)
movslq %r14d, %r15
leaq -0x4a8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %r15, %rdx
callq 0x5530
leaq -0x2a0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %r15, %rdx
callq 0x5530
leaq -0x4a8(%rbp), %rdi
callq 0x50b0
leaq -0x2a0(%rbp), %rdi
callq 0x50b0
xorl %eax, %eax
movq -0x38(%rbp), %rdi
movb %al, (%rdi,%r15)
movq -0x30(%rbp), %rsi
movb %al, (%rsi,%r15)
callq 0x55c0
testl %eax, %eax
je 0x12b44
leaq 0x2d67(%rip), %rsi      # 0x156ff
movl $0x15, %edx
movq %rbx, %rdi
callq 0x54f0
leaq 0x2c73(%rip), %rsi      # 0x1561f
movl $0x7, %edx
movq %rbx, %rdi
callq 0x54f0
movq (%rbx), %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
leaq 0x2d2e(%rip), %rsi      # 0x15715
movl $0x19, %edx
movq %rbx, %rdi
callq 0x54f0
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbx, %rdi
callq 0x54f0
leaq 0x2d24(%rip), %rsi      # 0x1572f
movl $0x6, %edx
movq %rax, %rdi
callq 0x54f0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x57a0
movq %rax, %r15
leaq 0x2d09(%rip), %rsi      # 0x15736
movl $0xb, %edx
movq %rax, %rdi
callq 0x54f0
movq %r15, %rdi
movl %r14d, %esi
callq 0x57a0
movq %rax, %r14
movq (%rax), %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 -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %r14
leaq 0x2cb9(%rip), %rsi      # 0x15742
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x51f0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x54f0
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 -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %rbx
leaq 0x2c51(%rip), %rsi      # 0x15742
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x51f0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x54f0
movq (%rbx), %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 0x127a0
movb $0x1, %bl
jmp 0x127a2
jmp 0x12b6a
movq %rax, %rbx
jmp 0x12b79
jmp 0x12b87
movq %rax, %rbx
jmp 0x12b96
movq %rax, %rbx
jmp 0x12ba2
movq %rax, %rbx
jmp 0x12bb4
movq %rax, %rbx
jmp 0x12bcc
jmp 0x12b6a
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x5100
leaq -0x4a8(%rbp), %rdi
callq 0x5100
jmp 0x12b8a
movq %rax, %rbx
leaq -0x790(%rbp), %rdi
callq 0x10746
leaq -0x958(%rbp), %rdi
callq 0x10746
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12bb4
callq 0x5460
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x12bcc
callq 0x5460
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12bde
callq 0x5460
movq %rbx, %rdi
callq 0x57c0