// File: 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
subq $0x6a0, %rsp            # imm = 0x6A0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x5c0(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x6870
movl $0x10, %edi
movl $0x1, %esi
callq 0x1c700
movl %eax, -0x5b4(%rbp)
jmp 0x1a8dd
movl -0x5b4(%rbp), %edx
leaq 0xab14(%rip), %rsi      # 0x253fe
leaq -0x210(%rbp), %rdi
callq 0x6080
jmp 0x1a8f8
movq -0x5c0(%rbp), %rsi
addq $0x50, %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x6240
jmp 0x1a911
movq -0x5c0(%rbp), %rsi
addq $0x30, %rsi
leaq -0x2f8(%rbp), %rdi
callq 0x6240
jmp 0x1a92a
leaq -0x2b8(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x2f8(%rbp), %rdx
callq 0x1f570
jmp 0x1a946
leaq -0x2f8(%rbp), %rdi
callq 0x69d8
leaq -0x2d8(%rbp), %rdi
callq 0x69d8
movq -0x5c0(%rbp), %rsi
addq $0x70, %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x6240
jmp 0x1a977
movq -0x5c0(%rbp), %rsi
addq $0x30, %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x6240
jmp 0x1a990
leaq -0x390(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
leaq -0x3d0(%rbp), %rdx
callq 0x1f570
jmp 0x1a9ac
leaq -0x3d0(%rbp), %rdi
callq 0x69d8
leaq -0x3b0(%rbp), %rdi
callq 0x69d8
leaq -0x3f1(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x68b0
movq -0x5c8(%rbp), %rdx
leaq 0xa9be(%rip), %rsi      # 0x253a3
leaq -0x3f0(%rbp), %rdi
callq 0x6670
jmp 0x1a9f3
leaq -0x2b8(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x1f940
jmp 0x1aa08
leaq -0x3f0(%rbp), %rdi
callq 0x69d8
leaq -0x3f1(%rbp), %rdi
callq 0x6590
leaq -0x419(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x68b0
movq -0x5d0(%rbp), %rdx
leaq 0xa9b2(%rip), %rsi      # 0x253f3
leaq -0x418(%rbp), %rdi
callq 0x6670
jmp 0x1aa4f
leaq -0x390(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x1f940
jmp 0x1aa64
leaq -0x418(%rbp), %rdi
callq 0x69d8
leaq -0x419(%rbp), %rdi
callq 0x6590
movq -0x5c0(%rbp), %rdi
addq $0xf8, %rdi
callq 0x1c720
decl %eax
movl %eax, -0x420(%rbp)
movq 0x1a522(%rip), %rdi     # 0x34fc0
leaq 0xa95e(%rip), %rsi      # 0x25403
callq 0x6520
movq %rax, -0x5d8(%rbp)
jmp 0x1aab3
movq -0x5d8(%rbp), %rdi
movl -0x420(%rbp), %esi
callq 0x6890
movq %rax, -0x5e0(%rbp)
jmp 0x1aace
movq -0x5e0(%rbp), %rdi
movq 0x1a4bc(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1aae3
movq -0x5c0(%rbp), %rdi
addq $0xf8, %rdi
movl -0x420(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x1c750
movq %rax, -0x5e8(%rbp)
jmp 0x1ab0a
movq -0x5e8(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x428(%rbp), %rdi
callq 0x14320
movq %rax, -0x430(%rbp)
movq -0x428(%rbp), %rdi
callq 0x14350
movq %rax, -0x438(%rbp)
leaq -0x430(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0x14380
testb $0x1, %al
jne 0x1ab5a
jmp 0x1b2dc
leaq -0x430(%rbp), %rdi
callq 0x143c0
movq %rax, %rsi
leaq -0x538(%rbp), %rdi
callq 0x15320
jmp 0x1ab77
movq 0x1a442(%rip), %rdi     # 0x34fc0
leaq 0xa888(%rip), %rsi      # 0x2540d
callq 0x6520
movq %rax, -0x5f0(%rbp)
jmp 0x1ab93
movq -0x5f0(%rbp), %rdi
movl -0x518(%rbp), %esi
callq 0x6890
movq %rax, -0x5f8(%rbp)
jmp 0x1abae
movq -0x5f8(%rbp), %rdi
movq 0x1a3dc(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1abc3
cmpl $0x7, -0x518(%rbp)
jne 0x1af70
leaq -0x558(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x6240
jmp 0x1abe5
movq 0x1a3d4(%rip), %rdi     # 0x34fc0
leaq 0xa823(%rip), %rsi      # 0x25416
callq 0x6520
movq %rax, -0x600(%rbp)
jmp 0x1ac01
movq -0x600(%rbp), %rdi
leaq -0x558(%rbp), %rsi
callq 0x64a0
movq %rax, -0x608(%rbp)
jmp 0x1ac1d
movq -0x608(%rbp), %rdi
movq 0x1a36d(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1ac32
xorl %eax, %eax
movl %eax, %esi
leaq -0x558(%rbp), %rdi
movl $0xa, %edx
callq 0x60e0
jmp 0x1ac49
movq 0x1a370(%rip), %rdi     # 0x34fc0
leaq 0xa7dd(%rip), %rsi      # 0x25434
callq 0x6520
movq %rax, -0x610(%rbp)
jmp 0x1ac65
movq -0x610(%rbp), %rdi
leaq -0x558(%rbp), %rsi
callq 0x64a0
movq %rax, -0x618(%rbp)
jmp 0x1ac81
movq -0x618(%rbp), %rdi
movq 0x1a309(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1ac96
leaq -0x2b8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
leaq -0x558(%rbp), %rdx
leaq -0x210(%rbp), %rcx
callq 0x20a60
movb %al, -0x619(%rbp)
jmp 0x1acbf
movb -0x619(%rbp), %al
andb $0x1, %al
movb %al, -0x559(%rbp)
movq 0x1a2ec(%rip), %rdi     # 0x34fc0
leaq 0xa766(%rip), %rsi      # 0x25441
callq 0x6520
movq %rax, -0x628(%rbp)
jmp 0x1ace9
movq -0x628(%rbp), %rdi
movzbl -0x559(%rbp), %esi
andl $0x1, %esi
callq 0x68d0
movq %rax, -0x630(%rbp)
jmp 0x1ad08
movq -0x630(%rbp), %rdi
movq 0x1a282(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1ad1d
testb $0x1, -0x559(%rbp)
je 0x1af4a
leaq -0x2b8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x223a0
movb %al, -0x631(%rbp)
jmp 0x1ad45
movb -0x631(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1af48
movq 0x1a260(%rip), %rdi     # 0x34fc0
leaq 0xa6f4(%rip), %rsi      # 0x2545b
callq 0x6520
movq %rax, -0x640(%rbp)
jmp 0x1ad75
movq -0x640(%rbp), %rdi
movq -0x5c0(%rbp), %rsi
addq $0x70, %rsi
callq 0x64a0
movq %rax, -0x648(%rbp)
jmp 0x1ad95
movq -0x648(%rbp), %rdi
movq 0x1a1f5(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1adaa
movb $0x0, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
jmp 0x1af5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1b381
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1ae06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x69d8
leaq -0x2d8(%rbp), %rdi
callq 0x69d8
jmp 0x1b381
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1b375
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1ae60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x69d8
leaq -0x3b0(%rbp), %rdi
callq 0x69d8
jmp 0x1b375
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1aea3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x69d8
leaq -0x3f1(%rbp), %rdi
callq 0x6590
jmp 0x1b369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1aee6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x418(%rbp), %rdi
callq 0x69d8
leaq -0x419(%rbp), %rdi
callq 0x6590
jmp 0x1b369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1b369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1b2cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x69d8
jmp 0x1b2cb
jmp 0x1af4a
movb -0x559(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x69d8
jmp 0x1b29c
cmpl $0x8, -0x518(%rbp)
jne 0x1b096
movq 0x1a03c(%rip), %rdi     # 0x34fc0
leaq 0xa4ea(%rip), %rsi      # 0x25475
callq 0x6520
movq %rax, -0x650(%rbp)
jmp 0x1af99
movq -0x650(%rbp), %rdi
movq 0x19ff1(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1afae
leaq -0x2b8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
leaq -0x210(%rbp), %rdx
callq 0x1ff80
movb %al, -0x651(%rbp)
jmp 0x1afd0
movb -0x651(%rbp), %al
andb $0x1, %al
movb %al, -0x561(%rbp)
testb $0x1, -0x561(%rbp)
je 0x1b07c
leaq -0x2b8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x223a0
movb %al, -0x652(%rbp)
jmp 0x1b006
movb -0x652(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1b07a
movq 0x19fa3(%rip), %rdi     # 0x34fc0
leaq 0xa437(%rip), %rsi      # 0x2545b
callq 0x6520
movq %rax, -0x660(%rbp)
jmp 0x1b032
movq -0x660(%rbp), %rdi
movq -0x5c0(%rbp), %rsi
addq $0x70, %rsi
callq 0x64a0
movq %rax, -0x668(%rbp)
jmp 0x1b052
movq -0x668(%rbp), %rdi
movq 0x19f38(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1b067
movb $0x0, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
jmp 0x1b29c
jmp 0x1b07c
movb -0x561(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
jmp 0x1b29c
cmpl $0x3, -0x518(%rbp)
je 0x1b0ac
cmpl $0x9, -0x518(%rbp)
jne 0x1b28e
leaq -0x588(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x6240
jmp 0x1b0c1
movq 0x19ef8(%rip), %rdi     # 0x34fc0
leaq 0xa3bf(%rip), %rsi      # 0x2548e
callq 0x6520
movq %rax, -0x670(%rbp)
jmp 0x1b0dd
movq -0x670(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0x64a0
movq %rax, -0x678(%rbp)
jmp 0x1b0f9
movq -0x678(%rbp), %rdi
movq 0x19e91(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1b10e
xorl %eax, %eax
movl %eax, %esi
leaq -0x588(%rbp), %rdi
movl $0xa, %edx
callq 0x60e0
jmp 0x1b125
leaq -0x5b0(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0x6240
jmp 0x1b13a
movl -0x468(%rbp), %ecx
movl -0x460(%rbp), %r8d
leaq -0x2b8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
leaq -0x5b0(%rbp), %rdx
leaq -0x210(%rbp), %r9
callq 0x211a0
movb %al, -0x679(%rbp)
jmp 0x1b170
leaq -0x5b0(%rbp), %rdi
callq 0x69d8
movb -0x679(%rbp), %al
andb $0x1, %al
movb %al, -0x589(%rbp)
testb $0x1, -0x589(%rbp)
je 0x1b25d
leaq -0x2b8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x223a0
movb %al, -0x67a(%rbp)
jmp 0x1b1b2
movb -0x67a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1b25b
movq 0x19df3(%rip), %rdi     # 0x34fc0
leaq 0xa287(%rip), %rsi      # 0x2545b
callq 0x6520
movq %rax, -0x688(%rbp)
jmp 0x1b1e2
movq -0x688(%rbp), %rdi
movq -0x5c0(%rbp), %rsi
addq $0x70, %rsi
callq 0x64a0
movq %rax, -0x690(%rbp)
jmp 0x1b202
movq -0x690(%rbp), %rdi
movq 0x19d88(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1b217
movb $0x0, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
jmp 0x1b272
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x1b280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x5b0(%rbp), %rdi
callq 0x69d8
jmp 0x1b280
jmp 0x1b25d
movb -0x589(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
leaq -0x588(%rbp), %rdi
callq 0x69d8
jmp 0x1b29c
leaq -0x588(%rbp), %rdi
callq 0x69d8
jmp 0x1b2cb
jmp 0x1b290
jmp 0x1b292
movl $0x0, -0x560(%rbp)
leaq -0x538(%rbp), %rdi
callq 0xbf60
movl -0x560(%rbp), %eax
testl %eax, %eax
jne 0x1b337
jmp 0x1b2b8
jmp 0x1b2ba
leaq -0x430(%rbp), %rdi
callq 0x14440
jmp 0x1ab3e
leaq -0x538(%rbp), %rdi
callq 0xbf60
jmp 0x1b369
movq 0x19cdd(%rip), %rdi     # 0x34fc0
leaq 0xa1c6(%rip), %rsi      # 0x254b0
callq 0x6520
movq %rax, -0x698(%rbp)
jmp 0x1b2f8
movq -0x698(%rbp), %rdi
leaq 0xa1b2(%rip), %rsi      # 0x254b8
callq 0x6520
movq %rax, -0x6a0(%rbp)
jmp 0x1b314
movq -0x6a0(%rbp), %rdi
movq 0x19c76(%rip), %rsi     # 0x34f98
callq 0x6580
jmp 0x1b329
movb $0x0, -0x1(%rbp)
movl $0x1, -0x560(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x1f640
leaq -0x2b8(%rbp), %rdi
callq 0x1f640
leaq -0x210(%rbp), %rdi
callq 0x6730
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbp
retq
leaq -0x390(%rbp), %rdi
callq 0x1f640
leaq -0x2b8(%rbp), %rdi
callq 0x1f640
leaq -0x210(%rbp), %rdi
callq 0x6730
movq -0x218(%rbp), %rdi
callq 0x68a0
nopl (%rax)