// File: /workspace/github_cpp_makefile_star2_O3/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Address_Mapping_Unit_Page_Level::Remove_barrier_for_accessing_lpa(unsigned short, unsigned long)
inline void Address_Mapping_Unit_Page_Level::Remove_barrier_for_accessing_lpa(stream_id_type stream_id, LPA_type lpa)
	{
		auto itr = domains[stream_id]->Locked_LPAs.find(lpa);
		if (itr == domains[stream_id]->Locked_LPAs.end()) {
			PRINT_ERROR("Illegal operation: Unlocking an LPA that has not been locked!");
		}
		domains[stream_id]->Locked_LPAs.erase(itr);

		//If there are read requests waiting behind the barrier, then MQSim assumes they can be serviced with the actual page data that is accessed during GC execution
		auto read_tr = domains[stream_id]->Read_transactions_behind_LPA_barrier.find(lpa);
		while (read_tr != domains[stream_id]->Read_transactions_behind_LPA_barrier.end()) {
			handle_transaction_serviced_signal_from_PHY((*read_tr).second);
			delete (*read_tr).second;
			domains[stream_id]->Read_transactions_behind_LPA_barrier.erase(read_tr);
			read_tr = domains[stream_id]->Read_transactions_behind_LPA_barrier.find(lpa);
		}

		//If there are write requests waiting behind the barrier, then MQSim assumes they can be serviced with the actual page data that is accessed during GC execution. This may not be 100% true for all write requests, but, to avoid more complexity in the simulation, we accept this assumption.
		auto write_tr = domains[stream_id]->Write_transactions_behind_LPA_barrier.find(lpa);
		while (write_tr != domains[stream_id]->Write_transactions_behind_LPA_barrier.end()) {
			handle_transaction_serviced_signal_from_PHY((*write_tr).second);
			delete (*write_tr).second;
			domains[stream_id]->Write_transactions_behind_LPA_barrier.erase(write_tr);
			write_tr = domains[stream_id]->Write_transactions_behind_LPA_barrier.find(lpa);
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xa8(%rdi), %rax
movl %esi, %r12d
movq (%rax,%r12,8), %rax
movq 0xf8(%rax), %rcx
testq %rcx, %rcx
je 0x2ff1a
movq %rdx, %rbx
movq %rdi, %r14
leaq 0xe8(%rax), %rdi
addq $0xf0, %rax
movq %rax, %rsi
xorl %edx, %edx
cmpq %rbx, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rsi
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x2fd5f
cmpq %rax, %rsi
je 0x2ff1a
cmpq %rbx, 0x20(%rsi)
ja 0x2ff1a
callq 0x30840
movq 0xa8(%r14), %rax
movq (%rax,%r12,8), %rax
movq 0x158(%rax), %rcx
testq %rcx, %rcx
je 0x2fe57
leaq 0x150(%rax), %rdx
movq %rdx, %r15
xorl %esi, %esi
cmpq %rbx, 0x20(%rcx)
setb %sil
cmovaeq %rcx, %r15
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x2fdb3
cmpq %rdx, %r15
je 0x2fe57
cmpq %rbx, 0x20(%r15)
ja 0x2fe57
leal (,%r12,8), %r13d
movl $0x148, %ebp            # imm = 0x148
movq 0x28(%r15), %rdi
callq 0x2f234
movq 0x28(%r15), %rdi
callq 0x7370
movq 0xa8(%r14), %rax
movq (%rax,%r13), %rdi
addq %rbp, %rdi
movq %r15, %rsi
callq 0x30d8a
movq 0xa8(%r14), %rax
movq (%rax,%r13), %rax
movq 0x158(%rax), %rdx
testq %rdx, %rdx
je 0x2fe57
leaq 0x150(%rax), %r15
movq %r15, %rcx
xorl %esi, %esi
cmpq %rbx, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x2fe30
cmpq %r15, %rcx
je 0x2fe57
cmpq %rbx, 0x20(%rcx)
cmovbeq %rcx, %r15
jbe 0x2fde7
movq 0x188(%rax), %rcx
testq %rcx, %rcx
je 0x2ff0b
addq $0x180, %rax            # imm = 0x180
movq %rax, %r15
xorl %edx, %edx
cmpq %rbx, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %r15
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x2fe70
cmpq %rax, %r15
je 0x2ff0b
cmpq %rbx, 0x20(%r15)
ja 0x2ff0b
shll $0x3, %r12d
movl $0x178, %r13d           # imm = 0x178
movq 0x28(%r15), %rdi
callq 0x2f234
movq 0x28(%r15), %rdi
callq 0x7370
movq 0xa8(%r14), %rax
movq (%rax,%r12), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x30d8a
movq 0xa8(%r14), %rax
movq (%rax,%r12), %r15
movq 0x188(%r15), %rax
testq %rax, %rax
je 0x2ff0b
addq $0x180, %r15            # imm = 0x180
movq %r15, %rcx
xorl %edx, %edx
cmpq %rbx, 0x20(%rax)
setb %dl
cmovaeq %rax, %rcx
movq 0x10(%rax,%rdx,8), %rax
testq %rax, %rax
jne 0x2fee5
cmpq %r15, %rcx
je 0x2ff0b
cmpq %rbx, 0x20(%rcx)
cmovbeq %rcx, %r15
jbe 0x2fe9c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3f0cf(%rip), %rbx     # 0x6eff0
leaq 0x26680(%rip), %rsi     # 0x565a8
movq %rbx, %rdi
callq 0x7390
leaq 0x28e9d(%rip), %rsi     # 0x58dd4
movq %rbx, %rdi
callq 0x7390
movq %rax, %rdi
callq 0x71c0
movq 0x3f082(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
nop