// File: /workspace/github_cpp_makefile_star2_O3/williewillus[P]panda_scratchpad/src/utils/Tester.cpp
// Function: Tester::test_check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_ofstream<char, std::char_traits<char>>&)
vector<milliseconds> Tester::test_check(const string device_path, ofstream &log) {
	assert(current_test_suite_ != NULL);
	vector<milliseconds> res(3, duration<int, std::milli>(-1));
	SingleTestInfo test_info;
	unsigned int test_num = 1;
	test_info.test_num = test_num++;

	// This funstion will be called after the replay i.e. 
	// the replay_device is in an unmounted state.
	//
	// So first check if the filesystem is mountable
	
	time_point<steady_clock> mount_start_time = steady_clock::now();
	if (mount_device(device_path, MNT_POINT_REPLAY) != SUCCESS) {
		test_info.fs_test.SetError(FileSystemTestResult::kKernelMount);
		return res;
	}

	if (mount_device(record_device_path, MNT_POINT_RECORD) != SUCCESS) {
		test_info.fs_test.SetError(FileSystemTestResult::kKernelMount);
		return res;
	}

	cout << "Mounted both record and replay device for checks" << endl;
	system("mount | grep pmem");
	system("ls /mnt/pmem0");
	system("ls /mnt/pmem1");
	cout << "Checking using system diff command" << endl;
	system("diff -qr /mnt/pmem0 /mnt/pmem1");


	time_point<steady_clock> mount_end_time = steady_clock::now();
	res.at(2) = duration_cast<milliseconds>(mount_end_time - mount_start_time);	

	// Once mounted, begin testing
	time_point<steady_clock> test_case_start_time = steady_clock::now();
	bool retVal = check_disk_and_snapshot_contents();
	if (!retVal) {
		test_info.data_test.SetError(tests::DataTestResult::kAutoCheckFailed);
	} 
	time_point<steady_clock> test_case_end_time = steady_clock::now();
	res.at(1) = duration_cast<milliseconds>(test_case_end_time - test_case_start_time);

	test_info.PrintResults(log);
	current_test_suite_->TallyTimingResult(test_info);
	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
cmpq $0x0, 0x98(%rsi)
je 0xef67
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq %rcx, -0x40(%rbp)
movl $0x18, %edi
callq 0x54a0
movq %rax, (%r14)
leaq 0x18(%rax), %rcx
movq %rcx, 0x10(%r14)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rax)
movq %rax, -0x30(%rbp)
movq $-0x1, 0x10(%rax)
movq %rcx, 0x8(%r14)
leaq -0x138(%rbp), %rdi
callq 0x8f54
movl $0x1, -0x138(%rbp)
callq 0x5560
movq %rax, -0x38(%rbp)
leaq -0xb0(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x7fc8
leaq -0x90(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x654a(%rip), %rsi      # 0x15232
leaq 0x654d(%rip), %rdx      # 0x1523c
leaq -0xa0(%rbp), %rdi
callq 0x8066
leaq -0xc0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
movq %r15, %rdi
callq 0xea90
movl %eax, %r12d
movq -0xa0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xed25
callq 0x5460
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0xed36
callq 0x5460
testl %r12d, %r12d
jne 0xedaa
leaq -0x70(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x7fc8
leaq -0x50(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x647c(%rip), %rsi      # 0x151e2
leaq 0x647f(%rip), %rdx      # 0x151ec
leaq -0x60(%rbp), %rdi
callq 0x8066
leaq -0x80(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0xea90
movl %eax, %r12d
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0xed97
callq 0x5460
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0xeda5
callq 0x5460
testl %r12d, %r12d
je 0xee0f
leaq -0x108(%rbp), %rdi
movl $0x80, %esi
callq 0x8db6
leaq -0xd8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xedd0
callq 0x5460
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xede5
callq 0x5460
leaq -0x120(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xedfa
callq 0x5460
movq %r14, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd1b2(%rip), %r12      # 0x1bfc8
leaq 0x6391(%rip), %rsi      # 0x151ae
movl $0x30, %edx
movq %r12, %rdi
callq 0x54f0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq 0xd17f(%rip), %rdi      # 0x1bfc8
callq 0x5040
movq %rax, %rdi
callq 0x5300
leaq 0x54d0(%rip), %rdi      # 0x1432d
callq 0x53e0
leaq 0x6376(%rip), %rdi      # 0x151df
callq 0x53e0
leaq 0x6378(%rip), %rdi      # 0x151ed
callq 0x53e0
movq 0xd147(%rip), %r12      # 0x1bfc8
leaq 0x6373(%rip), %rsi      # 0x151fb
movl $0x22, %edx
movq %r12, %rdi
callq 0x54f0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x5470
movsbl %al, %esi
movq 0xd114(%rip), %rdi      # 0x1bfc8
callq 0x5040
movq %rax, %rdi
callq 0x5300
leaq 0x6356(%rip), %rdi      # 0x1521e
callq 0x53e0
callq 0x5560
subq -0x38(%rbp), %rax
movabsq $0x431bde82d7b634db, %r13 # imm = 0x431BDE82D7B634DB
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x12, %rdx
addq %rax, %rdx
movq -0x30(%rbp), %rax
movq %rdx, 0x10(%rax)
callq 0x5560
movq %rax, %r12
movq %r15, %rdi
callq 0xeff8
testb %al, %al
jne 0xef1e
leaq -0x130(%rbp), %rdi
movl $0x40, %esi
callq 0x8c52
callq 0x5560
subq %r12, %rax
imulq %r13
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x12, %rdx
addq %rax, %rdx
movq -0x30(%rbp), %rax
movq %rdx, 0x8(%rax)
leaq -0x138(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x9038
movq 0x98(%r15), %rdi
leaq -0x138(%rbp), %rsi
callq 0x9378
jmp 0xedbb
leaq 0x61e2(%rip), %rdi      # 0x15150
leaq 0x60e0(%rip), %rsi      # 0x15055
leaq 0x61f0(%rip), %rcx      # 0x1516c
movl $0xa4, %edx
callq 0x52e0
jmp 0xefd7
jmp 0xefd7
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0xefa0
callq 0x5460
jmp 0xefa0
movq %rax, %r14
movq -0x80(%rbp), %rdi
jmp 0xefc6
movq %rax, %r14
movq -0xa0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xefbf
callq 0x5460
jmp 0xefbf
movq %rax, %r14
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0xefda
callq 0x5460
jmp 0xefda
movq %rax, %r14
jmp 0xefe6
movq %rax, %r14
leaq -0x138(%rbp), %rdi
callq 0xff7c
movq -0x30(%rbp), %rdi
callq 0x5460
movq %r14, %rdi
callq 0x57c0
nop