// File: /workspace/github_cpp_makefile_star2_O2/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::check_disk_and_snapshot_contents()
bool Tester::check_disk_and_snapshot_contents() {
	
	// we will check only the last checkpoint
	// so the oracle is the record device, and the replay device
	// will be tested against it
	ofstream diff_file;
	diff_file.open("diff", std::fstream::out | std::fstream::app);
	DiskContents disk1(record_device_path, fs), disk2(replay_device_path, fs);
	disk1.set_mount_point(MNT_POINT_RECORD);
	disk2.set_mount_point(MNT_POINT_REPLAY);

	int num_mods = mods_.size() - 1;
	cout << "Num mods " << num_mods << endl;
	// get the file/dir corresponding to the last checkpoint operation
	for (auto last_mod : mods_.at(num_mods-1)) {
		cout << "last mod" << last_mod.mod_type << endl;
		if (last_mod.mod_type == DiskMod::kFsyncMod) {
			string path(last_mod.path);
			cout << "Last checkpoint was fsync to " << path << endl;
			path.erase(0, 10);
			std::cout << "File path : " << path << std::endl;
			bool ret = disk1.compare_entries_at_path(disk2, path, diff_file);
			cout << "Compare entries returned " << ret << endl;
			if (ret) {
				if (disk1.sanity_checks(diff_file) == false) {
					std::cout << "Failed: Sanity checks on " << replay_device_path << endl;
					return false;
				}
			}
			return ret;
		}
		else if (last_mod.mod_type == DiskMod::kSyncMod) {
			cout << "Last checkpoint was sync" << endl;
			bool ret = disk1.compare_disk_contents(disk2, diff_file);
			if (ret) {
				if (disk1.sanity_checks(diff_file) == false) {
					std::cout << "Failed: Sanity checks on " << replay_device_path << endl;
					return false;
				}
			}
			return ret;
		}
		else if (last_mod.mod_type == DiskMod::kDataMod || last_mod.mod_type == DiskMod::kSyncFileRangeMod) {
			string path(last_mod.path);
			cout << "Last checkpoint was fdatasync to " << path << endl;
			path.erase(0, 10);
			bool ret = disk1.compare_file_contents(disk2, path, last_mod.file_mod_location, 
				last_mod.file_mod_len, diff_file);
			if (ret) {
				if (disk1.sanity_checks(diff_file) == false) {
					std::cout << "Failed: Sanity checks on " << replay_device_path << endl;
					return false;
				}
			}
			return ret;
		}
	}
	cout << "ERROR: " << __func__ << endl;	
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x548, %rsp            # imm = 0x548
movq %rdi, %rbx
leaq -0x568(%rbp), %r14
movq %r14, %rdi
callq 0x5760
leaq 0x5486(%rip), %rsi      # 0x1220d
pushq $0x11
popq %rdx
movq %r14, %rdi
callq 0x5060
leaq 0x50(%rbx), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x5580
leaq 0x30(%rbx), %r14
leaq -0xd8(%rbp), %rdi
movq %r14, %rsi
callq 0x5580
leaq -0x1b0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0xe5b6
leaq -0xd8(%rbp), %rdi
callq 0x58a8
leaq -0xf8(%rbp), %rdi
callq 0x58a8
leaq 0x70(%rbx), %rsi
leaq -0xb8(%rbp), %rdi
movq %rsi, -0x30(%rbp)
callq 0x5580
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0x5580
leaq -0x268(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0xe5b6
leaq -0x98(%rbp), %rdi
callq 0x58a8
leaq -0xb8(%rbp), %rdi
callq 0x58a8
leaq 0x536f(%rip), %rsi      # 0x121b2
leaq -0x78(%rbp), %rdi
leaq -0x368(%rbp), %rdx
callq 0x51c0
leaq -0x1b0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xe82e
leaq -0x78(%rbp), %rdi
callq 0x58a8
leaq 0x538f(%rip), %rsi      # 0x12202
leaq -0x58(%rbp), %rdi
leaq -0x368(%rbp), %rdx
callq 0x51c0
leaq -0x268(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xe82e
leaq -0x58(%rbp), %rdi
callq 0x58a8
movq 0x100(%rbx), %rax
subq 0xf8(%rbx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %r14
movq 0xd104(%rip), %rdi      # 0x19fc0
leaq 0x534f(%rip), %rsi      # 0x12212
callq 0x5480
leal -0x1(%r14), %esi
movq %rax, %rdi
callq 0x5770
movq %rax, %rdi
callq 0x5240
addq $0xf8, %rbx
addl $-0x2, %r14d
movslq %r14d, %rsi
movq %rbx, %rdi
callq 0xd98c
movq (%rax), %r14
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
leaq -0x118(%rbp), %rbx
leaq -0x1d0(%rbp), %r15
cmpq -0x38(%rbp), %r14
je 0xd1fa
leaq -0x368(%rbp), %rdi
movq %r14, %rsi
callq 0xae78
movq 0xd095(%rip), %rdi      # 0x19fc0
leaq 0x52ea(%rip), %rsi      # 0x1221c
callq 0x5480
movl -0x348(%rbp), %esi
movq %rax, %rdi
callq 0x5770
movq %rax, %rdi
callq 0x5240
movb $0x1, %r12b
movl -0x348(%rbp), %eax
addl $-0x3, %eax
cmpl $0x6, %eax
ja 0xd1ad
leaq 0x4fd7(%rip), %rcx      # 0x11f40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
leaq -0x368(%rbp), %rsi
callq 0x5580
movq 0xd038(%rip), %rdi      # 0x19fc0
leaq 0x530e(%rip), %rsi      # 0x1229d
callq 0x5480
movq %r15, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x50b0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5580
movl -0x298(%rbp), %ecx
movl -0x290(%rbp), %r8d
leaq -0x1b0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movq %r12, %rdx
leaq -0x568(%rbp), %r9
callq 0xf5aa
movl %eax, %r13d
movq %r12, %rdi
callq 0x58a8
testb %r13b, %r13b
je 0xd19f
leaq -0x1b0(%rbp), %rdi
leaq -0x568(%rbp), %rsi
callq 0xfffe
movb $0x1, %r13b
testb %al, %al
jne 0xd1a2
movq 0xcf9b(%rip), %rdi      # 0x19fc0
leaq 0x523e(%rip), %rsi      # 0x1226a
callq 0x5480
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
jmp 0xd19f
movq 0xcf6f(%rip), %rdi      # 0x19fc0
leaq 0x522c(%rip), %rsi      # 0x12284
callq 0x5480
movq %rax, %rdi
callq 0x5240
leaq -0x1b0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
leaq -0x568(%rbp), %rdx
callq 0xebe8
testb %al, %al
je 0xd1f2
leaq -0x1b0(%rbp), %rdi
leaq -0x568(%rbp), %rsi
callq 0xfffe
testb %al, %al
je 0xd1cb
movb $0x1, %r13b
jmp 0xd1aa
movq %rbx, %rdi
leaq -0x368(%rbp), %rsi
callq 0x5580
movq 0xcf00(%rip), %rdi      # 0x19fc0
leaq 0x515e(%rip), %rsi      # 0x12225
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x50b0
movq 0xcecd(%rip), %rdi      # 0x19fc0
leaq 0x5149(%rip), %rsi      # 0x12243
callq 0x5480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
leaq -0x1b0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movq %rbx, %rdx
leaq -0x568(%rbp), %rcx
callq 0xf14c
movl %eax, %r13d
movq 0xce87(%rip), %rdi      # 0x19fc0
leaq 0x5110(%rip), %rsi      # 0x12250
callq 0x5480
movzbl %r13b, %esi
movq %rax, %rdi
callq 0x5710
movq %rax, %rdi
callq 0x5240
testb %r13b, %r13b
je 0xd19f
leaq -0x1b0(%rbp), %rdi
leaq -0x568(%rbp), %rsi
callq 0xfffe
movb $0x1, %r13b
testb %al, %al
jne 0xd1a2
movq 0xce41(%rip), %rdi      # 0x19fc0
leaq 0x50e4(%rip), %rsi      # 0x1226a
callq 0x5480
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x58a8
xorl %r12d, %r12d
leaq -0x368(%rbp), %rdi
callq 0x7d8e
addq $0x100, %r14            # imm = 0x100
testb %r12b, %r12b
jne 0xcf0b
jmp 0xd227
movq 0xcdee(%rip), %rdi      # 0x19fc0
leaq 0x5091(%rip), %rsi      # 0x1226a
callq 0x5480
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x5410
movq %rax, %rdi
callq 0x5240
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0xd1ad
movq 0xcdbf(%rip), %rdi      # 0x19fc0
leaq 0x50b7(%rip), %rsi      # 0x122bf
callq 0x5480
leaq 0x50b3(%rip), %rsi      # 0x122c7
movq %rax, %rdi
callq 0x5480
movq %rax, %rdi
callq 0x5240
xorl %r13d, %r13d
leaq -0x268(%rbp), %rdi
callq 0xe680
leaq -0x1b0(%rbp), %rdi
callq 0xe680
leaq -0x568(%rbp), %rdi
callq 0x5630
andb $0x1, %r13b
movl %r13d, %eax
addq $0x548, %rsp            # imm = 0x548
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd2f2
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
jmp 0xd27b
jmp 0xd2f2
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x58a8
jmp 0xd31b
jmp 0xd2f2
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x58a8
jmp 0xd29b
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x58a8
jmp 0xd327
movq %rax, %rbx
jmp 0xd327
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x58a8
jmp 0xd2c2
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x58a8
jmp 0xd333
jmp 0xd2d2
movq %rax, %rbx
jmp 0xd333
jmp 0xd30c
jmp 0xd2f2
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x58a8
jmp 0xd2fe
jmp 0xd30c
jmp 0xd30c
jmp 0xd2fb
movq %rax, %rbx
jmp 0xd31b
jmp 0xd2fb
jmp 0xd2fb
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x58a8
jmp 0xd30f
movq %rax, %rbx
leaq -0x368(%rbp), %rdi
callq 0x7d8e
leaq -0x268(%rbp), %rdi
callq 0xe680
leaq -0x1b0(%rbp), %rdi
callq 0xe680
leaq -0x568(%rbp), %rdi
callq 0x5630
movq %rbx, %rdi
callq 0x5780
nop