// File: /workspace/github_cpp_makefile_star2_O1/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, -0x2c(%rbp)
movq %rdx, %r12
movq %rsi, %r13
addq $0x8, %rdi
addq $0x8, %rsi
callq 0x5050
testl %eax, %eax
je 0x12908
leaq 0x2abf(%rip), %rsi      # 0x151f2
leaq -0x80(%rbp), %rdi
movq %r12, %rdx
callq 0xd239
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x28(%r13), %rsi
movq 0x30(%r13), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x8052
leaq -0x60(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movq %r12, %rdx
callq 0x13a79
leaq -0x960(%rbp), %rdi
callq 0x10770
leaq -0x798(%rbp), %rdi
callq 0x10770
movq -0x80(%rbp), %rdi
leaq -0x5d0(%rbp), %rsi
callq 0x5410
movl %eax, %r13d
cmpl $-0x1, %eax
jne 0x127f2
leaq 0x2f26(%rip), %rsi      # 0x156d1
movl $0x18, %edx
movq %rbx, %rdi
callq 0x54f0
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq %rbx, %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
movq -0x60(%rbp), %rdi
leaq -0x540(%rbp), %rsi
callq 0x5410
cmpl $-0x1, %eax
je 0x12910
cmpl $-0x1, %r13d
je 0x1295e
leaq -0x4b0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x4, %edx
callq 0x5700
leaq -0x2a8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x4, %edx
callq 0x5700
movq -0x4b0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x490(%rbp,%rax)
jne 0x1286d
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x288(%rbp,%rax)
je 0x129ca
movq 0x9754(%rip), %rdi      # 0x1bfc8
leaq 0x2e6f(%rip), %rsi      # 0x156ea
movl $0x21, %edx
callq 0x54f0
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq 0x9734(%rip), %rdi      # 0x1bfc8
callq 0x54f0
leaq 0x2e6c(%rip), %rsi      # 0x1570c
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq 0x970c(%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 %r13d, %r13d
leaq -0x2a8(%rbp), %rdi
callq 0x5100
leaq -0x4b0(%rbp), %rdi
callq 0x5100
jmp 0x12961
movb $0x1, %r13b
jmp 0x129b5
leaq 0x2dba(%rip), %rsi      # 0x156d1
movl $0x18, %edx
movq %rbx, %rdi
callq 0x54f0
movq -0x60(%rbp), %rsi
movq -0x58(%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 %r13d, %r13d
leaq -0x798(%rbp), %rdi
callq 0x10812
leaq -0x960(%rbp), %rdi
callq 0x10812
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1298b
callq 0x5460
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x129a3
callq 0x5460
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x129b5
callq 0x5460
movl %r13d, %eax
addq $0x938, %rsp            # imm = 0x938
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq -0x2c(%rbp), %r15
leaq -0x4b0(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5590
leaq -0x2a8(%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, -0x40(%rbp)
movq %r15, %rdi
callq 0x5030
movq %rax, -0x38(%rbp)
movslq %r14d, %r13
leaq -0x4b0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x5530
leaq -0x2a8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %r13, %rdx
callq 0x5530
leaq -0x4b0(%rbp), %rdi
callq 0x50b0
leaq -0x2a8(%rbp), %rdi
callq 0x50b0
xorl %eax, %eax
movq -0x40(%rbp), %rdi
movb %al, (%rdi,%r13)
movq -0x38(%rbp), %rsi
movb %al, (%rsi,%r13)
callq 0x55c0
testl %eax, %eax
sete %r13b
je 0x128ee
leaq 0x2c8c(%rip), %rsi      # 0x15712
movl $0x15, %edx
movq %rbx, %rdi
callq 0x54f0
leaq 0x2b95(%rip), %rsi      # 0x1562f
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 0x2c53(%rip), %rsi      # 0x15728
movl $0x19, %edx
movq %rbx, %rdi
callq 0x54f0
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x54f0
leaq 0x2c48(%rip), %rsi      # 0x15742
movl $0x6, %edx
movq %rax, %rdi
callq 0x54f0
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x57a0
movq %rax, %r15
leaq 0x2c2d(%rip), %rsi      # 0x15749
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 -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %r14
leaq 0x2bdd(%rip), %rsi      # 0x15755
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x40(%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 -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %rbx, %rdi
callq 0x54f0
movq %rax, %rbx
leaq 0x2b75(%rip), %rsi      # 0x15755
movl $0x5, %edx
movq %rax, %rdi
callq 0x54f0
movq -0x38(%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 0x128eb
jmp 0x12c52
movq %rax, %rbx
jmp 0x12c61
jmp 0x12c6f
movq %rax, %rbx
jmp 0x12c7e
movq %rax, %rbx
jmp 0x12c8a
movq %rax, %rbx
jmp 0x12c9c
movq %rax, %rbx
jmp 0x12cb4
jmp 0x12c52
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x5100
leaq -0x4b0(%rbp), %rdi
callq 0x5100
jmp 0x12c72
movq %rax, %rbx
leaq -0x798(%rbp), %rdi
callq 0x10812
leaq -0x960(%rbp), %rdi
callq 0x10812
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12c9c
callq 0x5460
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x12cb4
callq 0x5460
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12cc6
callq 0x5460
movq %rbx, %rdi
callq 0x57c0