LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Link.cpp
// Function: Host_Components::PCIe_Link::Deliver(Host_Components::PCIe_Message*)
void PCIe_Link::Deliver(PCIe_Message* message)
	{
		switch (message->Destination) {
			case PCIe_Destination_Type::HOST://Message from SSD device to the host
				Message_buffer_toward_root_complex.push(message);
				if (Message_buffer_toward_root_complex.size() > 1) {//There are active transfers
					return;
				}
				Simulator->Register_sim_event(Simulator->Time() + estimate_transfer_time(message), this, (void*)(intptr_t)PCIe_Destination_Type::HOST, static_cast<int>(PCIe_Link_Event_Type::DELIVER));
				break;
			case PCIe_Destination_Type::DEVICE://Message from Host to the SSD device
				Message_buffer_toward_ssd_device.push(message);
				if (Message_buffer_toward_ssd_device.size() > 1) {
					return;
				}
				Simulator->Register_sim_event(Simulator->Time() + estimate_transfer_time(message), this, (void*)(intptr_t)PCIe_Destination_Type::DEVICE, static_cast<int>(PCIe_Link_Event_Type::DELIVER));
				break;
			default:
				break;
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
movl (%rsi), %eax
cmpl $0x1, %eax
je 0x24814
testl %eax, %eax
jne 0x24977
movq 0xe0(%rbx), %rax
movq 0xf0(%rbx), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x2483f
movq %rsi, (%rax)
addq $0x8, 0xe0(%rbx)
jmp 0x24850
movq 0x90(%rbx), %rax
movq 0xa0(%rbx), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x248dd
movq %rsi, (%rax)
addq $0x8, 0x90(%rbx)
jmp 0x248eb
leaq 0xb0(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x24d12
movq 0xf8(%rbx), %rax
movq %rax, %rcx
subq 0xd8(%rbx), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0xe0(%rbx), %rax
subq 0xe8(%rbx), %rax
movq 0xd0(%rbx), %rdx
sarq $0x3, %rax
subq 0xc0(%rbx), %rdx
sarq $0x3, %rdx
addq %rax, %rdx
addq %rcx, %rdx
cmpq $0x1, %rdx
ja 0x24977
callq 0x281b4
movq %rax, %r14
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x24b04
addq %rax, %r15
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
jmp 0x2496f
leaq 0x60(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x24d12
movq 0xa8(%rbx), %rax
movq %rax, %rcx
subq 0x88(%rbx), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0x90(%rbx), %rax
subq 0x98(%rbx), %rax
movq 0x80(%rbx), %rdx
sarq $0x3, %rax
subq 0x70(%rbx), %rdx
sarq $0x3, %rdx
addq %rax, %rdx
addq %rcx, %rdx
cmpq $0x1, %rdx
ja 0x24977
callq 0x281b4
movq %rax, %r14
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x24b04
addq %rax, %r15
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x285aa
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Link.cpp
// Function: Host_Components::PCIe_Link::Execute_simulator_event(MQSimEngine::Sim_Event*)
void PCIe_Link::Execute_simulator_event(MQSimEngine::Sim_Event* event)
	{
		PCIe_Message* message = NULL;
		PCIe_Destination_Type destination = (PCIe_Destination_Type)(intptr_t)event->Parameters;
		switch (destination) {
			case PCIe_Destination_Type::HOST:
				message = Message_buffer_toward_root_complex.front();
				Message_buffer_toward_root_complex.pop();
				root_complex->Consume_pcie_message(message);
				if (Message_buffer_toward_root_complex.size() > 0) {//There are active transfers
					Simulator->Register_sim_event(Simulator->Time() + estimate_transfer_time(Message_buffer_toward_root_complex.front()),
						this, (void*)(intptr_t)PCIe_Destination_Type::HOST, static_cast<int>(PCIe_Link_Event_Type::DELIVER));
				}
				break;
			case PCIe_Destination_Type::DEVICE:
				message = Message_buffer_toward_ssd_device.front();
				Message_buffer_toward_ssd_device.pop();
				pcie_switch->Deliver_to_device(message);
				if (Message_buffer_toward_ssd_device.size() > 0) {
					Simulator->Register_sim_event(Simulator->Time() + estimate_transfer_time(Message_buffer_toward_ssd_device.front()),
						this, (void*)(intptr_t)PCIe_Destination_Type::DEVICE, static_cast<int>(PCIe_Link_Event_Type::DELIVER));
				}
				break;
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x10(%rsi), %eax
cmpl $0x1, %eax
je 0x24a52
testl %eax, %eax
jne 0x24ab8
leaq 0xb0(%rbx), %rdi
movq 0xc0(%rbx), %rax
movq (%rax), %r14
callq 0x24f0a
movq 0x30(%rbx), %rdi
movq %r14, %rsi
callq 0x24b6e
movq 0xf8(%rbx), %rax
movq %rax, %rcx
subq 0xd8(%rbx), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0xd0(%rbx), %rax
movq 0xe0(%rbx), %rdx
subq 0xe8(%rbx), %rdx
sarq $0x3, %rdx
addq %rcx, %rdx
subq 0xc0(%rbx), %rax
sarq $0x3, %rax
addq %rdx, %rax
je 0x24ab8
callq 0x281b4
movq %rax, %r14
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
movq 0xc0(%rbx), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x24b04
addq %rax, %r15
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
jmp 0x24af6
leaq 0x60(%rbx), %rdi
movq 0x70(%rbx), %rax
movq (%rax), %r14
callq 0x24f0a
movq 0x38(%rbx), %rdi
movq %r14, %rsi
callq 0x250dc
movq 0xa8(%rbx), %rax
movq %rax, %rcx
subq 0x88(%rbx), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x6, %rcx
movq 0x80(%rbx), %rax
movq 0x90(%rbx), %rdx
subq 0x98(%rbx), %rdx
sarq $0x3, %rdx
addq %rcx, %rdx
subq 0x70(%rbx), %rax
sarq $0x3, %rax
addq %rdx, %rax
jne 0x24abe
popq %rbx
popq %r14
popq %r15
retq
callq 0x281b4
movq %rax, %r14
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
movq 0x70(%rbx), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x24b04
addq %rax, %r15
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %r8d, %r8d
popq %rbx
popq %r14
popq %r15
jmp 0x285aa
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Link.h
// Function: Host_Components::PCIe_Link::estimate_transfer_time(Host_Components::PCIe_Message*)
sim_time_type estimate_transfer_time(PCIe_Message* message)
		{
			switch (message->Type) {
				case PCIe_Message_Type::READ_COMP:
				case PCIe_Message_Type::WRITE_REQ:
				{
					int total_transfered_bytes = (message->Payload_size / tlp_max_payload_size) * (tlp_max_payload_size + packet_overhead)
						+ (message->Payload_size % tlp_max_payload_size == 0 ? 0 : message->Payload_size % tlp_max_payload_size + packet_overhead);
					return (sim_time_type)(((double)((total_transfered_bytes / lane_count) + (total_transfered_bytes % lane_count == 0 ? 0 : 1))) / lane_bandwidth_GBPs);
				}
				case PCIe_Message_Type::READ_REQ:
					return (sim_time_type)((((packet_overhead + 4) / lane_count) + ((packet_overhead + 4) % lane_count == 0 ? 0 : 1)) / lane_bandwidth_GBPs);
			}
			
			return 0;
		}

// Assembly:
movl 0x4(%rsi), %eax
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0x24b2c
movl 0x10(%rsi), %eax
movl 0x50(%rdi), %esi
movl 0x5c(%rdi), %ecx
xorl %edx, %edx
divl %esi
addl %ecx, %esi
imull %esi, %eax
addl %edx, %ecx
testl %edx, %edx
cmovel %edx, %ecx
addl %eax, %ecx
jmp 0x24b36
testl %eax, %eax
jne 0x24b6b
movl 0x5c(%rdi), %ecx
addl $0x4, %ecx
movl %ecx, %eax
cltd
idivl 0x48(%rdi)
cmpl $0x1, %edx
sbbl $-0x1, %eax
cvtsi2sd %eax, %xmm0
divsd 0x40(%rdi), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x304f1(%rip), %xmm0    # 0x55050
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rcx, %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Root_Complex.h
// Function: Host_Components::PCIe_Root_Complex::Consume_pcie_message(Host_Components::PCIe_Message*)
void Consume_pcie_message(PCIe_Message* messages)//Modern processors support DDIO, where all writes to memory are going through LLC
		{
			switch (messages->Type)
			{
			case PCIe_Message_Type::READ_REQ:
				Read_from_memory(messages->Address, (unsigned int)(intptr_t)messages->Payload);
				break;
			case PCIe_Message_Type::WRITE_REQ:
				Write_to_memory(messages->Address, messages->Payload);
				break;
			default:
				break;
			}
			delete messages;
		}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl 0x4(%rsi), %eax
cmpl $0x1, %eax
je 0x24b8c
testl %eax, %eax
jne 0x24b99
movq 0x18(%rbx), %rsi
movl 0x8(%rbx), %edx
callq 0x25030
jmp 0x24b99
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %rsi
callq 0x24f64
testq %rbx, %rbx
je 0x24ba7
movq %rbx, %rdi
popq %rbx
jmp 0x7370
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Root_Complex.cpp
// Function: Host_Components::PCIe_Root_Complex::Write_to_memory(unsigned long, void const*)
void PCIe_Root_Complex::Write_to_memory(const uint64_t address, const void* payload)
	{
		//This is a request to write back a read request data into memory (in modern systems the write is done to LLC)
		if (address >= DATA_MEMORY_REGION) {
			//nothing to do
		} else {
			switch (SSD_device_type) {
				case HostInterface_Types::NVME:
				{
					unsigned int flow_id = QUEUE_ID_TO_FLOW_ID(((Completion_Queue_Entry*)payload)->SQ_ID);
					((*IO_flows)[flow_id])->NVMe_consume_io_request((Completion_Queue_Entry*)payload);
					break;
				}
				case HostInterface_Types::SATA:
					sata_hba->SATA_consume_io_request((Completion_Queue_Entry*)payload);
					break;
				default:
					PRINT_ERROR("Uknown Host Interface type in PCIe_Root_Complex")
			}
		}
	}

// Assembly:
shrq $0x28, %rsi
cmpl $0xfe, %esi
jbe 0x24f71
retq
movl 0x8(%rdi), %eax
testl %eax, %eax
je 0x24f9a
cmpl $0x1, %eax
jne 0x24fa6
movzwl 0xa(%rdx), %eax
decl %eax
movq 0x18(%rdi), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
movq %rdx, %rsi
jmpq *%rax
movq 0x10(%rdi), %rdi
movq %rdx, %rsi
jmp 0x259ea
pushq %rbx
movq 0x4a042(%rip), %rbx     # 0x6eff0
leaq 0x315f3(%rip), %rsi     # 0x565a8
movq %rbx, %rdi
callq 0x7390
leaq 0x3301e(%rip), %rsi     # 0x57fe2
movq %rbx, %rdi
callq 0x7390
movq %rax, %rdi
callq 0x71c0
movq 0x49ff5(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Root_Complex.cpp
// Function: Host_Components::PCIe_Root_Complex::Write_to_device(unsigned long, unsigned short)
void PCIe_Root_Complex::Write_to_device(uint64_t address, uint16_t write_value)
	{
		PCIe_Message* pcie_message = new Host_Components::PCIe_Message;
		pcie_message->Type = PCIe_Message_Type::WRITE_REQ;
		pcie_message->Destination = Host_Components::PCIe_Destination_Type::DEVICE;
		pcie_message->Address = address;
		pcie_message->Payload = (void*)(intptr_t)write_value;
		pcie_message->Payload_size = sizeof(write_value);
		pcie_link->Deliver(pcie_message);
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movl $0x20, %edi
callq 0x73a0
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, (%rax)
movq %r14, 0x18(%rax)
movl %ebx, %ecx
movq %rcx, 0x8(%rax)
movl $0x2, 0x10(%rax)
movq (%r15), %rdi
movq %rax, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x247d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/PCIe_Root_Complex.cpp
// Function: Host_Components::PCIe_Root_Complex::Read_from_memory(unsigned long, unsigned int)
void PCIe_Root_Complex::Read_from_memory(const uint64_t address, const unsigned int read_size)
	{
		PCIe_Message* new_pcie_message = new Host_Components::PCIe_Message;
		new_pcie_message->Type = PCIe_Message_Type::READ_COMP;
		new_pcie_message->Destination = Host_Components::PCIe_Destination_Type::DEVICE;
		new_pcie_message->Address = address;

		//This is a request to read the data of a write request
		if (address >= DATA_MEMORY_REGION) {
			//nothing to do
			new_pcie_message->Payload_size = read_size;
			new_pcie_message->Payload = NULL;//No need to transfer data in the standalone mode of MQSim
		} else {
			switch (SSD_device_type) {
				case HostInterface_Types::NVME:
				{
					uint16_t flow_id = QUEUE_ID_TO_FLOW_ID(uint16_t(address >> NVME_COMP_Q_MEMORY_REGION));
					new_pcie_message->Payload = (*IO_flows)[flow_id]->NVMe_read_sqe(address);
					new_pcie_message->Payload_size = sizeof(Submission_Queue_Entry);
					break;
				}
				case HostInterface_Types::SATA:
					new_pcie_message->Payload = sata_hba->Read_ncq_entry(address);
					new_pcie_message->Payload_size = sizeof(Submission_Queue_Entry);
					break;
			}
		}

		pcie_link->Deliver(new_pcie_message);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movl $0x20, %edi
callq 0x73a0
movq %rax, %r14
movabsq $0x200000001, %rax      # imm = 0x200000001
movq %rax, (%r14)
movq %r15, 0x18(%r14)
movq %r15, %rax
shrq $0x28, %rax
cmpl $0xff, %eax
jb 0x25079
movl %ebp, 0x10(%r14)
movq $0x0, 0x8(%r14)
jmp 0x250b7
movl 0x8(%rbx), %ecx
testl %ecx, %ecx
je 0x2509f
cmpl $0x1, %ecx
jne 0x250b7
decl %eax
movq 0x18(%rbx), %rcx
movzwl %ax, %eax
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
callq 0x1f6a8
jmp 0x250ab
movq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x25ab0
movq %rax, 0x8(%r14)
movl $0x48, 0x10(%r14)
movq (%rbx), %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x247d0
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/SATA_HBA.cpp
// Function: Host_Components::SATA_HBA::~SATA_HBA()
SATA_HBA::~SATA_HBA()
	{
		for (auto &req : sata_ncq.queue) {
			if (req.second) {
				delete req.second;
			}
		}
		for (auto &req : waiting_requests_for_submission) {
			if (req) {
				delete req;
			}
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x48a07(%rip), %rax     # 0x6ddd0
movq %rax, (%rdi)
movq 0x88(%rdi), %r14
testq %r14, %r14
je 0x253eb
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x253e6
callq 0x7370
movq (%r14), %r14
jmp 0x253d3
leaq 0xf8(%rbx), %r14
movq 0xf8(%rbx), %r15
cmpq %r14, %r15
je 0x25411
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x2540c
callq 0x7370
movq (%r15), %r15
jmp 0x253f9
leaq 0x160(%rbx), %rdi
callq 0x25b90
leaq 0x110(%rbx), %rdi
callq 0x25bd4
movq 0xf8(%rbx), %rdi
cmpq %r14, %rdi
je 0x25445
movq (%rdi), %r15
callq 0x7370
movq %r15, %rdi
cmpq %r14, %r15
jne 0x25435
movq 0xe0(%rbx), %rdi
testq %rdi, %rdi
je 0x25456
callq 0x7370
leaq 0xb0(%rbx), %rdi
callq 0x21740
leaq 0x78(%rbx), %rdi
callq 0x216de
leaq 0x485e6(%rip), %rax     # 0x6da58
movq %rax, (%rbx)
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
cmpq %rbx, %rdi
je 0x2548c
popq %rbx
popq %r14
popq %r15
jmp 0x7370
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/SATA_HBA.cpp
// Function: Host_Components::SATA_HBA::Read_ncq_entry(unsigned long)
Submission_Queue_Entry* SATA_HBA::Read_ncq_entry(uint64_t address)
	{
		Submission_Queue_Entry* ncq_entry = new Submission_Queue_Entry;
		Host_IO_Request* request = request_queue_in_memory[(uint16_t)((address - sata_ncq.Submission_queue_memory_base_address) / sizeof(Submission_Queue_Entry))];
		
		if (request == NULL) {
			throw std::invalid_argument("SATA HBA: Request to access an NCQ entry that does not exist.");
		}

		ncq_entry->Command_Identifier = request->IO_queue_info;
		//For simplicity, MQSim's SATA host interface uses NVMe opcodes
		if (request->Type == Host_IO_Request_Type::READ) {
			ncq_entry->Opcode = NVME_READ_OPCODE;
			ncq_entry->Command_specific[0] = (uint32_t)request->Start_LBA;
			ncq_entry->Command_specific[1] = (uint32_t)(request->Start_LBA >> 32);
			ncq_entry->Command_specific[2] = ((uint32_t)((uint16_t)request->LBA_count)) & (uint32_t)(0x0000ffff);
			ncq_entry->PRP_entry_1 = (DATA_MEMORY_REGION);//Dummy addresses, just to emulate data read/write access
			ncq_entry->PRP_entry_2 = (DATA_MEMORY_REGION + 0x1000);//Dummy addresses
		} else {
			ncq_entry->Opcode = NVME_WRITE_OPCODE;
			ncq_entry->Command_specific[0] = (uint32_t)request->Start_LBA;
			ncq_entry->Command_specific[1] = (uint32_t)(request->Start_LBA >> 32);
			ncq_entry->Command_specific[2] = ((uint32_t)((uint16_t)request->LBA_count)) & (uint32_t)(0x0000ffff);
			ncq_entry->PRP_entry_1 = (DATA_MEMORY_REGION);//Dummy addresses, just to emulate data read/write access
			ncq_entry->PRP_entry_2 = (DATA_MEMORY_REGION + 0x1000);//Dummy addresses
		}

		return ncq_entry;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x48, %edi
callq 0x73a0
movq %rax, %rcx
subq 0x58(%r14), %rbx
movabsq $-0x1c71c71c71c71c71, %rdx # imm = 0xE38E38E38E38E38F
movq %rbx, %rax
mulq %rdx
movq 0xe0(%r14), %rax
shrl $0x3, %edx
andl $0x7fff8, %edx          # imm = 0x7FFF8
movq (%rax,%rdx), %rax
testq %rax, %rax
je 0x25b39
movzwl 0x20(%rax), %edx
movw %dx, 0x2(%rcx)
xorl %edx, %edx
cmpl $0x1, 0x1c(%rax)
adcb $0x1, %dl
movb %dl, (%rcx)
movq 0x10(%rax), %rdx
movq %rdx, 0x30(%rcx)
movzwl 0x18(%rax), %eax
movl %eax, 0x38(%rcx)
movabsq $0xff0000000000, %rax   # imm = 0xFF0000000000
movq %rax, 0x20(%rcx)
orq $0x1000, %rax           # imm = 0x1000
movq %rax, 0x28(%rcx)
movq %rcx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x10, %edi
callq 0x71d0
movq %rax, %rbx
leaq 0x32517(%rip), %rsi     # 0x58064
movq %rax, %rdi
callq 0x7680
movq 0x4946c(%rip), %rsi     # 0x6efc8
movq 0x4944d(%rip), %rdx     # 0x6efb0
movq %rbx, %rdi
callq 0x75e0
movq %rax, %r14
movq %rbx, %rdi
callq 0x72c0
movq %r14, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Flash_Chip.cpp
// Function: NVM::FlashMemory::Flash_Chip::~Flash_Chip()
Flash_Chip::~Flash_Chip()
		{
			for (unsigned int dieID = 0; dieID < die_no; dieID++) {
				delete Dies[dieID];
			}
			delete[] Dies;
			delete[] _readLatency;
			delete[] _programLatency;
		}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x4774f(%rip), %rax     # 0x6de28
movq %rax, (%rdi)
cmpl $0x0, 0x48(%rdi)
je 0x2670d
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x26702
movq %r14, %rdi
callq 0x26470
movq %r14, %rdi
callq 0x7370
incq %r15
movl 0x48(%rbx), %eax
cmpq %rax, %r15
jb 0x266e5
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x2671b
callq 0x7480
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x26729
callq 0x7480
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x26737
callq 0x7480
movq 0xf0(%rbx), %rdi
testq %rdi, %rdi
je 0x26748
callq 0x7370
leaq 0x47309(%rip), %rax     # 0x6da58
movq %rax, (%rbx)
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
cmpq %rbx, %rdi
je 0x26769
popq %rbx
popq %r14
popq %r15
jmp 0x7370
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Flash_Chip.cpp
// Function: NVM::FlashMemory::Flash_Chip::Suspend(unsigned int)
void Flash_Chip::Suspend(flash_die_ID_type dieID)
		{
			STAT_totalExecTime += Simulator->Time() - executionStartTime;

			Die* targetDie = Dies[dieID];
			if (targetDie->Suspended) {
				PRINT_ERROR("Flash chip" << ID() << ": suspending a previously suspended flash chip! This is illegal.")
			}

			/*if (targetDie->CurrentCMD & CMD_READ != 0)
			throw "Suspend is not supported for read operations!";*/

			targetDie->RemainingSuspendedExecTime = targetDie->Expected_finish_time - Simulator->Time();
			Simulator->Ignore_sim_event(targetDie->CommandFinishEvent);//The simulator engine should not execute the finish event for the suspended command
			targetDie->CommandFinishEvent = NULL;

			targetDie->SuspendedCMD = targetDie->CurrentCMD;
			targetDie->CurrentCMD = NULL;
			targetDie->Suspended = true;
			STAT_totalSuspensionCount++;

			targetDie->Status = DieStatus::IDLE;
			this->idleDieNo++;
			if (this->idleDieNo == die_no) {
				this->status = Internal_Status::IDLE;
			}

			executionStartTime = INVALID_TIME;
			expectedFinishTime = INVALID_TIME;
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebp
movq %rdi, %rbx
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
subq 0xa0(%rbx), %rax
addq %rax, 0xd8(%rbx)
movq 0x40(%rbx), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %r15
cmpb $0x1, 0x38(%r15)
je 0x270c7
leaq 0xa0(%rbx), %r14
movq 0x18(%r15), %r12
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
subq %rax, %r12
movq %r12, 0x20(%r15)
callq 0x281b4
movq 0x10(%r15), %rsi
movq %rax, %rdi
callq 0x2860a
xorl %eax, %eax
movq %rax, 0x10(%r15)
movq 0x28(%r15), %rcx
movq %rcx, 0x30(%r15)
movq %rax, 0x28(%r15)
movb $0x1, 0x38(%r15)
incq 0xc8(%rbx)
movl $0x1, 0xc(%r15)
movl 0x3c(%rbx), %eax
incl %eax
movl %eax, 0x3c(%rbx)
cmpl 0x48(%rbx), %eax
jne 0x270b1
movl $0x0, 0x38(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%r14)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x47f22(%rip), %r14     # 0x6eff0
leaq 0x2f4d3(%rip), %rsi     # 0x565a8
movl $0x6, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x30ff1(%rip), %rsi     # 0x580da
movl $0xa, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xb036
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x7400
movq %rax, %rbx
leaq 0x3101d(%rip), %rsi     # 0x5814b
movl $0x40, %edx
movq %rax, %rdi
callq 0x7400
movq %rbx, %rdi
callq 0x71c0
movq %rsp, %rdi
callq 0x76b8
movq 0x47e7e(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x27172
callq 0x7370
movq %rbx, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Flash_Chip.cpp
// Function: NVM::FlashMemory::Flash_Chip::Resume(unsigned int)
void Flash_Chip::Resume(flash_die_ID_type dieID)
		{
			Die* targetDie = Dies[dieID];
			if (!targetDie->Suspended) {
				PRINT_ERROR("Flash chip " << ID() << ": resume flash command is requested, but there is no suspended flash command!")
			}

			targetDie->CurrentCMD = targetDie->SuspendedCMD;
			targetDie->SuspendedCMD = NULL;
			targetDie->Suspended = false;
			STAT_totalResumeCount++;

			targetDie->Expected_finish_time = Simulator->Time() + targetDie->RemainingSuspendedExecTime;
			targetDie->CommandFinishEvent = Simulator->Register_sim_event(targetDie->Expected_finish_time,
				this, targetDie->CurrentCMD, static_cast<int>(Chip_Sim_Event_Type::COMMAND_FINISHED));
			if (targetDie->Expected_finish_time > this->expectedFinishTime) {
				this->expectedFinishTime = targetDie->Expected_finish_time;
			}

			targetDie->Status = DieStatus::BUSY;
			this->idleDieNo--;
			this->status = Internal_Status::BUSY;
			executionStartTime = Simulator->Time();
		}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %r14
cmpb $0x0, 0x38(%r14)
je 0x2722f
movq 0x30(%r14), %rax
movq %rax, 0x28(%r14)
movq $0x0, 0x30(%r14)
movb $0x0, 0x38(%r14)
incq 0xd0(%rbx)
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
addq 0x20(%r14), %rax
movq %rax, 0x18(%r14)
callq 0x281b4
movq 0x18(%r14), %rsi
movq 0x28(%r14), %rcx
movq %rax, %rdi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x285aa
movq %rax, 0x10(%r14)
movq 0x18(%r14), %rax
cmpq 0xa8(%rbx), %rax
jbe 0x271ff
movq %rax, 0xa8(%rbx)
movl $0x0, 0xc(%r14)
decl 0x3c(%rbx)
movl $0x1, 0x38(%rbx)
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, 0xa0(%rbx)
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x47dba(%rip), %r14     # 0x6eff0
leaq 0x2f36b(%rip), %rsi     # 0x565a8
movl $0x6, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x30e6e(%rip), %rsi     # 0x580bf
movl $0xb, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xb036
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x7400
movq %rax, %rbx
leaq 0x30ef6(%rip), %rsi     # 0x5818c
movl $0x4d, %edx
movq %rax, %rdi
callq 0x7400
movq %rbx, %rdi
callq 0x71c0
movq %rsp, %rdi
callq 0x76b8
movq 0x47d16(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x272da
callq 0x7370
movq %rbx, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Flash_Chip.h
// Function: NVM::FlashMemory::Flash_Chip::Get_command_execution_latency(unsigned long, unsigned int)
sim_time_type Get_command_execution_latency(command_code_type CMDCode, flash_page_ID_type pageID)
			{
				int latencyType = 0;
				if (flash_technology == Flash_Technology_Type::MLC) {
					latencyType = pageID % 2;
				} else if (flash_technology == Flash_Technology_Type::TLC) {
					//From: Yaakobi et al., "Characterization and Error-Correcting Codes for TLC Flash Memories", ICNC 2012
					latencyType = (pageID <= 5) ? 0 : ((pageID <= 7) ? 1 : (((pageID - 8) >> 1) % 3));;
				}

				switch (CMDCode)
				{
					case CMD_READ_PAGE:
					case CMD_READ_PAGE_MULTIPLANE:
					case CMD_READ_PAGE_COPYBACK:
					case CMD_READ_PAGE_COPYBACK_MULTIPLANE:
						return _readLatency[latencyType] + _RBSignalDelayRead;
					case CMD_PROGRAM_PAGE:
					case CMD_PROGRAM_PAGE_MULTIPLANE:
					case CMD_PROGRAM_PAGE_COPYBACK:
					case CMD_PROGRAM_PAGE_COPYBACK_MULTIPLANE:
						return _programLatency[latencyType] + _RBSignalDelayWrite;
					case CMD_ERASE_BLOCK:
					case CMD_ERASE_BLOCK_MULTIPLANE:
						return _eraseLatency + _RBSignalDelayErase;
					default:
						throw std::invalid_argument("Unsupported command for flash chip.");
				}
			}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x34(%rdi), %ecx
xorl %eax, %eax
cmpl $0x3, %ecx
je 0x27e96
cmpl $0x2, %ecx
jne 0x27ea9
andl $0x1, %edx
movl %edx, %eax
jmp 0x27ea9
cmpl $0x6, %edx
jb 0x27ea9
movl $0x1, %eax
cmpl $0x8, %edx
jae 0x27f39
cmpq $0x800f, %rsi           # imm = 0x800F
jg 0x27ed0
cmpq $0x35, %rsi
jbe 0x27f00
leaq -0x60d0(%rsi), %rcx
cmpq $0x2, %rcx
jae 0x27f12
leaq 0x68(%rdi), %rcx
movl $0x90, %eax
jmp 0x27f2a
leaq -0x8010(%rsi), %rcx
cmpq $0x2, %rcx
jb 0x27eef
cmpq $0x8510, %rsi           # imm = 0x8510
je 0x27eef
cmpq $0x85111, %rsi          # imm = 0x85111
jne 0x27f53
movl %eax, %ecx
shlq $0x3, %rcx
addq 0x60(%rdi), %rcx
movl $0x88, %eax
jmp 0x27f2a
movabsq $0x25000000000000, %rcx # imm = 0x25000000000000
btq %rsi, %rcx
jb 0x27f1b
jmp 0x27eb8
cmpq $0x321, %rsi            # imm = 0x321
jne 0x27f53
movl %eax, %ecx
shlq $0x3, %rcx
addq 0x58(%rdi), %rcx
movl $0x80, %eax
movq (%rdi,%rax), %rax
addq (%rcx), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
addl $-0x8, %edx
shrl %edx
imulq $0x55555556, %rdx, %rax # imm = 0x55555556
shrq $0x20, %rax
leal (%rax,%rax,2), %eax
subl %eax, %edx
jmp 0x27e92
movl $0x10, %edi
callq 0x71d0
movq %rax, %rbx
leaq 0x302fb(%rip), %rsi     # 0x58262
movq %rax, %rdi
callq 0x7680
movq 0x47052(%rip), %rsi     # 0x6efc8
movq 0x47033(%rip), %rdx     # 0x6efb0
movq %rbx, %rdi
callq 0x75e0
movq %rax, %r14
movq %rbx, %rdi
callq 0x72c0
movq %r14, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Plane.cpp
// Function: NVM::FlashMemory::Plane::Plane(unsigned int, unsigned int)
Plane::Plane(unsigned int BlocksNoPerPlane, unsigned int PagesNoPerBlock) :
			Read_count(0), Progam_count(0), Erase_count(0)
		{
			Healthy_block_no = BlocksNoPerPlane;
			Blocks = new Block*[BlocksNoPerPlane];
			for (unsigned int i = 0; i < BlocksNoPerPlane; i++) {
				Blocks[i] = new Block(PagesNoPerBlock, i);
			}
			Allocated_streams = NULL;
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movq $0x0, 0x20(%rdi)
movl %esi, 0x8(%rdi)
movl %esi, %r13d
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, (%r14)
testl %ebp, %ebp
je 0x28137
xorl %r15d, %r15d
movl $0x10, %edi
callq 0x73a0
movq %rax, %r12
movq %rax, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x2636c
movq (%r14), %rax
movq %r12, (%rax,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x2810e
movq $0x0, 0x28(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r12, %rdi
callq 0x7370
movq %rbx, %rdi
callq 0x7620
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/Engine.cpp
// Function: MQSimEngine::Engine::Reset()
void Engine::Reset()
	{
		_EventList->Clear();
		_ObjectList.clear();
		_sim_time = 0;
		stop = false;
		started = false;
		Utils::Logical_Address_Partitioning_Unit::Reset();
	}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x2927a
leaq 0x10(%rbx), %rdi
callq 0x286a4
movq $0x0, (%rbx)
movw $0x0, 0x48(%rbx)
popq %rbx
jmp 0x52c80
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/Engine.cpp
// Function: MQSimEngine::Engine::GetObject(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Sim_Object* Engine::GetObject(sim_object_id_type object_id)
	{
		auto itr = _ObjectList.find(object_id);
		if (itr == _ObjectList.end()) {
			return NULL;
		}

		return (*itr).second;
	}

// Assembly:
pushq %rax
addq $0x10, %rdi
callq 0x2871c
testq %rax, %rax
je 0x28419
movq 0x28(%rax), %rax
jmp 0x2841b
xorl %eax, %eax
popq %rcx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/Engine.cpp
// Function: MQSimEngine::Engine::RemoveObject(MQSimEngine::Sim_Object*)
void Engine::RemoveObject(Sim_Object* obj)
	{
		std::unordered_map<sim_object_id_type, Sim_Object*>::iterator it = _ObjectList.find(obj->ID());
		if (it == _ObjectList.end()) {
			throw std::invalid_argument("Removing an unregistered object.");
		}
		_ObjectList.erase(it);
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
addq $0x10, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsi), %rax
movq 0x10(%rsi), %rdx
addq %rax, %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0xb036
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2871c
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2846c
callq 0x7370
testq %r14, %r14
je 0x28486
movq %rbx, %rdi
movq %r14, %rsi
callq 0x28b48
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x71d0
movq %rax, %r14
leaq 0x2fe33(%rip), %rsi     # 0x582cd
movq %rax, %rdi
callq 0x7680
movq 0x46b1f(%rip), %rsi     # 0x6efc8
movq 0x46b00(%rip), %rdx     # 0x6efb0
movq %r14, %rdi
callq 0x75e0
movq %rax, %rbx
movq %r14, %rdi
callq 0x72c0
jmp 0x284d6
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x284d6
callq 0x7370
movq %rbx, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/Engine.cpp
// Function: MQSimEngine::Engine::Start_simulation()
void Engine::Start_simulation()
	{
		started = true;

		for(std::unordered_map<sim_object_id_type, Sim_Object*>::iterator obj = _ObjectList.begin();
			obj != _ObjectList.end();
			++obj) {
			if (!obj->second->IsTriggersSetUp()) {
				obj->second->Setup_triggers();
			}
		}

		for (std::unordered_map<sim_object_id_type, Sim_Object*>::iterator obj = _ObjectList.begin();
			obj != _ObjectList.end();
			++obj) {
			obj->second->Validate_simulation_config();
		}
		
		for (std::unordered_map<sim_object_id_type, Sim_Object*>::iterator obj = _ObjectList.begin();
			obj != _ObjectList.end();
			++obj) {
			obj->second->Start_simulation();
		}
		
		Sim_Event* ev = NULL;
		while (true) {
			if (_EventList->Count == 0 || stop) {
				break;
			}

			EventTreeNode* minNode = _EventList->Get_min_node();
			ev = minNode->FirstSimEvent;

			_sim_time = ev->Fire_time;

			while (ev != NULL) {
				if(!ev->Ignore) {
					ev->Target_sim_object->Execute_simulator_event(ev);
				}
				Sim_Event* consumed_event = ev;
				ev = ev->Next_event;
				delete consumed_event;
			}
			_EventList->Remove(minNode);
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb $0x1, 0x49(%rdi)
movq 0x20(%rdi), %r14
testq %r14, %r14
je 0x2850b
movq 0x28(%r14), %rdi
cmpb $0x0, 0x28(%rdi)
jne 0x28506
movq (%rdi), %rax
callq *0x10(%rax)
movq (%r14), %r14
jmp 0x284f1
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x28523
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq (%r14), %r14
jmp 0x2850f
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x28586
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *(%rax)
movq (%r14), %r14
jmp 0x28527
cmpb $0x0, 0x48(%rbx)
jne 0x2858f
callq 0x28fc8
movq %rax, %r14
movq 0x8(%rax), %r15
movq (%r15), %rax
movq %rax, (%rbx)
cmpb $0x0, 0x28(%r15)
jne 0x28566
movq 0x8(%r15), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
movq 0x20(%r15), %r12
movq %r15, %rdi
callq 0x7370
movq %r12, %r15
testq %r12, %r12
jne 0x28552
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x290cc
movq 0x8(%rbx), %rdi
cmpl $0x0, (%rdi)
jne 0x2853a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/Engine.cpp
// Function: MQSimEngine::Engine::Register_sim_event(unsigned long, MQSimEngine::Sim_Object*, void*, int)
Sim_Event* Engine::Register_sim_event(sim_time_type fireTime, Sim_Object* targetObject, void* parameters, int type)
	{
		Sim_Event* ev = new Sim_Event(fireTime, targetObject, parameters, type);
		DEBUG("RegisterEvent " << fireTime << " " << targetObject)
		_EventList->Insert_sim_event(ev);
		return ev;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x30, %edi
callq 0x73a0
movq %rax, %rbp
movq %r12, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movl %ebx, 0x18(%rax)
movq $0x0, 0x20(%rax)
movb $0x0, 0x28(%rax)
movq 0x8(%r13), %rdi
movq %rax, %rsi
callq 0x28efe
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/EventTree.cpp
// Function: MQSimEngine::EventTree::EventTree()
EventTree::EventTree()
	{
		// set up the sentinel node. the sentinel node is the key to a successfull
		// implementation and for understanding the red-black tree properties.
		SentinelNode = new EventTreeNode();
		SentinelNode->Left = NULL;
		SentinelNode->Right = NULL;
		SentinelNode->Parent = NULL;
		SentinelNode->Color = 1;
		rbTree = SentinelNode;
		lastNodeFound = SentinelNode;
	}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x38, %edi
callq 0x73a0
movl $0x0, 0x18(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
xorl %ecx, %ecx
movq %rcx, 0x30(%rax)
movq %rax, 0x469a7(%rip)     # 0x6f5f0
movq %rcx, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movl $0x1, 0x18(%rax)
movq %rax, 0x8(%rbx)
movq %rax, 0x10(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/EventTree.cpp
// Function: MQSimEngine::EventTree::Add(unsigned long, MQSimEngine::Sim_Event*)
void EventTree::Add(sim_time_type key, Sim_Event* data)
	{
		// traverse tree - find where node belongs
		// create new node
		EventTreeNode* node = new EventTreeNode();
		// grab the rbTree node of the tree
		EventTreeNode* temp = rbTree;

		while (temp != SentinelNode) {
			// find Parent
			node->Parent = temp;
			
			if (key > temp->Key)
				temp = temp->Right;
			else
				temp = temp->Left;
		}

		// setup node
		node->Key = key;
		node->FirstSimEvent = data;
		node->LastSimEvent = data;
		node->Left = SentinelNode;
		node->Right = SentinelNode;

		// insert node into tree starting at parent's location
		if (node->Parent != NULL) {
			if (node->Key > (node->Parent->Key)) {
				node->Parent->Right = node;
			} else {
				node->Parent->Left = node;
			}
		} else {
			// first node added
			rbTree = node;
		}

		// restore red-black properities
		RestoreAfterInsert(node);
		lastNodeFound = node;
		Count++;
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movl $0x38, %edi
callq 0x73a0
movq %rax, %r14
movl $0x0, 0x18(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movq $0x0, 0x30(%rax)
movq 0x46941(%rip), %rax     # 0x6f5f0
movq 0x8(%rbx), %rcx
cmpq %rax, %rcx
je 0x28ccb
movq %rcx, 0x30(%r14)
xorl %edx, %edx
cmpq %r15, (%rcx)
setb %dl
movq 0x20(%rcx,%rdx,8), %rcx
jmp 0x28cb3
movq %r15, (%r14)
movq %r12, 0x8(%r14)
movq %r12, 0x10(%r14)
movq %rax, 0x20(%r14)
movq %rax, 0x28(%r14)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x28cf2
cmpq %r15, (%rax)
jae 0x28cf8
addq $0x28, %rax
jmp 0x28cfc
leaq 0x8(%rbx), %rax
jmp 0x28cfc
addq $0x20, %rax
movq %r14, (%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x28d1c
movq %r14, 0x10(%rbx)
incl (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/sim/EventTree.cpp
// Function: MQSimEngine::EventTree::Insert_sim_event(MQSimEngine::Sim_Event*)
void EventTree::Insert_sim_event(Sim_Event* event)
	{
		if (event->Fire_time < Engine::Instance()->Time()) {
			PRINT_ERROR("Illegal request to register a simulation event before Now!")
		}

		sim_time_type key = event->Fire_time;
		EventTreeNode* treeNode = rbTree;     // begin at root

												// traverse tree until node is found
		while (treeNode != SentinelNode)
		{
			if (key == treeNode->Key) {
				treeNode->LastSimEvent->Next_event = event;
				treeNode->LastSimEvent = event;
				return;
			}
			if (key < (treeNode->Key)) {
				treeNode = treeNode->Left;
			} else {
				treeNode = treeNode->Right;
			}
		}
		Add(event->Fire_time, event);
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %r15
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
cmpq %rax, %r15
jb 0x28f65
movq (%rbx), %rsi
movq 0x466c8(%rip), %rcx     # 0x6f5f0
movq 0x8(%r14), %rax
cmpq %rcx, %rax
je 0x28f43
cmpq (%rax), %rsi
je 0x28f53
setae %dl
movzbl %dl, %edx
movq 0x20(%rax,%rdx,8), %rax
jmp 0x28f2c
movq %r14, %rdi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x28c74
movq 0x10(%rax), %rcx
movq %rbx, 0x20(%rcx)
movq %rbx, 0x10(%rax)
popq %rbx
popq %r14
popq %r15
retq
movq 0x46084(%rip), %rbx     # 0x6eff0
leaq 0x2d635(%rip), %rsi     # 0x565a8
movq %rbx, %rdi
callq 0x7390
leaq 0x2f36c(%rip), %rsi     # 0x582ee
movq %rbx, %rdi
callq 0x7390
movq %rax, %rdi
callq 0x71c0
movq 0x46037(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::~Cached_Mapping_Table()
Cached_Mapping_Table::~Cached_Mapping_Table()
	{
		std::unordered_map<LPA_type, CMTSlotType*> addressMap;
		std::list<std::pair<LPA_type, CMTSlotType*>> lruList;

		auto entry = addressMap.begin();
		while (entry != addressMap.end()) {
			delete (*entry).second;
			addressMap.erase(entry++);
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0x48(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq %rsp, %r12
movq %r12, 0x8(%r12)
movq %r12, (%r12)
movq $0x0, 0x10(%r12)
movq -0x20(%rax), %r15
leaq 0x18(%rsp), %r14
testq %r15, %r15
je 0x295a1
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x2958e
callq 0x7370
movq (%r15), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x311a2
movq %r13, %r15
jmp 0x2957b
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x295ba
movq (%rdi), %r14
callq 0x7370
movq %r14, %rdi
cmpq %r12, %r14
jne 0x295aa
leaq 0x18(%rsp), %rdi
callq 0x30cc0
leaq 0x38(%rbx), %r14
movq 0x38(%rbx), %rdi
cmpq %r14, %rdi
je 0x295e1
movq (%rdi), %r15
callq 0x7370
movq %r15, %rdi
cmpq %r14, %r15
jne 0x295d1
movq %rbx, %rdi
callq 0x30cc0
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0xaf65
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::Retrieve_ppa(unsigned short, unsigned long)
PPA_type Cached_Mapping_Table::Retrieve_ppa(const stream_id_type streamID, const LPA_type lpn)
	{
		LPA_type key = LPN_TO_UNIQUE_KEY(streamID, lpn);
		auto it = addressMap.find(key);
		assert(it != addressMap.end());
		assert(it->second->Status == CMTEntryStatus::VALID);
		lruList.splice(lruList.begin(), lruList, it->second->listPtr);
		
		return it->second->PPA;
	}

// Assembly:
pushq %rbx
shlq $0x38, %rsi
orq %rdx, %rsi
movq (%rdi), %r8
movq 0x8(%rdi), %r9
xorl %r11d, %r11d
movq %rsi, %rax
xorl %edx, %edx
divq %r9
movq (%r8,%rdx,8), %rax
testq %rax, %rax
je 0x29661
movq (%rax), %r10
movq %rax, %r11
cmpq 0x8(%r10), %rsi
je 0x29661
movq %rdx, %rcx
movq %r10, %rbx
movq (%r10), %r10
testq %r10, %r10
je 0x2965e
movq 0x8(%r10), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r9
movl $0x0, %r11d
cmpq %rcx, %rdx
jne 0x29661
movq %rbx, %r11
cmpq %r8, %rsi
jne 0x29632
jmp 0x29661
xorl %r11d, %r11d
testq %r11, %r11
je 0x2966b
movq (%r11), %rbx
jmp 0x2966d
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x29699
movq 0x10(%rbx), %rax
cmpl $0x2, 0x14(%rax)
jne 0x296b8
movq 0x38(%rdi), %rsi
addq $0x38, %rdi
movq 0x18(%rax), %rcx
movq %rdi, %rdx
callq 0x312ae
movq 0x10(%rbx), %rax
movq (%rax), %rax
popq %rbx
retq
leaq 0x2eea0(%rip), %rdi     # 0x58540
leaq 0x2eeb0(%rip), %rsi     # 0x58557
leaq 0x2eed5(%rip), %rcx     # 0x58583
movl $0x30, %edx
callq 0x7270
leaq 0x2ef26(%rip), %rdi     # 0x585e5
leaq 0x2ee91(%rip), %rsi     # 0x58557
leaq 0x2eeb6(%rip), %rcx     # 0x58583
movl $0x31, %edx
callq 0x7270
nop
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::Get_bitmap_vector_of_written_sectors(unsigned short, unsigned long)
page_status_type Cached_Mapping_Table::Get_bitmap_vector_of_written_sectors(const stream_id_type streamID, const LPA_type lpn)
	{
		LPA_type key = LPN_TO_UNIQUE_KEY(streamID, lpn);
		auto it = addressMap.find(key);
		assert(it != addressMap.end());
		assert(it->second->Status == CMTEntryStatus::VALID);

		return it->second->WrittenStateBitmap;
	}

// Assembly:
pushq %rax
shlq $0x38, %rsi
orq %rdx, %rsi
movq (%rdi), %r9
movq 0x8(%rdi), %r8
xorl %r10d, %r10d
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq (%r9,%rdx,8), %rax
testq %rax, %rax
je 0x29739
movq (%rax), %r9
movq %rax, %r10
cmpq 0x8(%r9), %rsi
je 0x29739
movq %rdx, %rcx
movq %r9, %r11
movq (%r9), %r9
testq %r9, %r9
je 0x29736
movq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %r10d
cmpq %rcx, %rdx
jne 0x29739
movq %r11, %r10
cmpq %rdi, %rsi
jne 0x2970a
jmp 0x29739
xorl %r10d, %r10d
testq %r10, %r10
je 0x29743
movq (%r10), %rax
jmp 0x29745
xorl %eax, %eax
testq %rax, %rax
je 0x2975a
movq 0x10(%rax), %rax
cmpl $0x2, 0x14(%rax)
jne 0x29779
movq 0x8(%rax), %rax
popq %rcx
retq
leaq 0x2eddf(%rip), %rdi     # 0x58540
leaq 0x2edef(%rip), %rsi     # 0x58557
leaq 0x2eea2(%rip), %rcx     # 0x58611
movl $0x3b, %edx
callq 0x7270
leaq 0x2ee65(%rip), %rdi     # 0x585e5
leaq 0x2edd0(%rip), %rsi     # 0x58557
leaq 0x2ee83(%rip), %rcx     # 0x58611
movl $0x3c, %edx
callq 0x7270
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::Update_mapping_info(unsigned short, unsigned long, unsigned long, unsigned long)
void Cached_Mapping_Table::Update_mapping_info(const stream_id_type streamID, const LPA_type lpa, const PPA_type ppa, const page_status_type pageWriteState)
	{
		LPA_type key = LPN_TO_UNIQUE_KEY(streamID, lpa);
		auto it = addressMap.find(key);
		assert(it != addressMap.end());
		assert(it->second->Status == CMTEntryStatus::VALID);
		it->second->PPA = ppa;
		it->second->WrittenStateBitmap = pageWriteState;
		it->second->Dirty = true;
		it->second->Stream_id = streamID;
		DEBUG("Address mapping table update entry - Stream ID:" << streamID << ", LPA:" << lpa << ", PPA:" << ppa)
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r11
shlq $0x38, %r11
orq %rdx, %r11
movq (%rdi), %r10
movq 0x8(%rdi), %rdi
xorl %r14d, %r14d
movq %r11, %rax
xorl %edx, %edx
divq %rdi
movq (%r10,%rdx,8), %rax
testq %rax, %rax
je 0x29800
movq (%rax), %rbx
movq %rax, %r14
cmpq 0x8(%rbx), %r11
je 0x29800
movq %rdx, %r9
movq %rbx, %r15
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x297fd
movq 0x8(%rbx), %r10
movq %r10, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r14d
cmpq %r9, %rdx
jne 0x29800
movq %r15, %r14
cmpq %r10, %r11
jne 0x297d1
jmp 0x29800
xorl %r14d, %r14d
testq %r14, %r14
je 0x2980a
movq (%r14), %rax
jmp 0x2980c
xorl %eax, %eax
testq %rax, %rax
je 0x29830
movq 0x10(%rax), %rax
cmpl $0x2, 0x14(%rax)
jne 0x2984f
movq %rcx, (%rax)
movq %r8, 0x8(%rax)
movb $0x1, 0x10(%rax)
movw %si, 0x20(%rax)
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2ed09(%rip), %rdi     # 0x58540
leaq 0x2ed19(%rip), %rsi     # 0x58557
leaq 0x2ee4e(%rip), %rcx     # 0x58693
movl $0x45, %edx
callq 0x7270
leaq 0x2ed8f(%rip), %rdi     # 0x585e5
leaq 0x2ecfa(%rip), %rsi     # 0x58557
leaq 0x2ee2f(%rip), %rcx     # 0x58693
movl $0x46, %edx
callq 0x7270
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::Insert_new_mapping_info(unsigned short, unsigned long, unsigned long, unsigned long long)
void Cached_Mapping_Table::Insert_new_mapping_info(const stream_id_type streamID, const LPA_type lpa, const PPA_type ppa, const unsigned long long pageWriteState)
	{
		LPA_type key = LPN_TO_UNIQUE_KEY(streamID, lpa);
		auto it = addressMap.find(key);
		if (it == addressMap.end()) {
			throw std::logic_error("No slot is reserved!");
		}

		it->second->Status = CMTEntryStatus::VALID;
		it->second->PPA = ppa;
		it->second->WrittenStateBitmap = pageWriteState;
		it->second->Dirty = false;
		it->second->Stream_id = streamID;
		DEBUG("Address mapping table insert entry - Stream ID:" << streamID << ", LPA:" << lpa << ", PPA:" << ppa)
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r11
shlq $0x38, %r11
orq %rdx, %r11
movq (%rdi), %r10
movq 0x8(%rdi), %rdi
xorl %r14d, %r14d
movq %r11, %rax
xorl %edx, %edx
divq %rdi
movq (%r10,%rdx,8), %rax
testq %rax, %rax
je 0x298d6
movq (%rax), %rbx
movq %rax, %r14
cmpq 0x8(%rbx), %r11
je 0x298d6
movq %rdx, %r9
movq %rbx, %r15
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x298d3
movq 0x8(%rbx), %r10
movq %r10, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r14d
cmpq %r9, %rdx
jne 0x298d6
movq %r15, %r14
cmpq %r10, %r11
jne 0x298a7
jmp 0x298d6
xorl %r14d, %r14d
testq %r14, %r14
je 0x298e0
movq (%r14), %rax
jmp 0x298e2
xorl %eax, %eax
testq %rax, %rax
je 0x29907
movq 0x10(%rax), %rax
movl $0x2, 0x14(%rax)
movq %rcx, (%rax)
movq %r8, 0x8(%rax)
movb $0x0, 0x10(%rax)
movw %si, 0x20(%rax)
popq %rbx
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x71d0
movq %rax, %rbx
leaq 0x2ee05(%rip), %rsi     # 0x58720
movq %rax, %rdi
callq 0x7500
movq 0x45696(%rip), %rsi     # 0x6efc0
movq 0x45657(%rip), %rdx     # 0x6ef88
movq %rbx, %rdi
callq 0x75e0
movq %rax, %r14
movq %rbx, %rdi
callq 0x72c0
movq %r14, %rdi
callq 0x7620
// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Page_Level.cpp
// Function: SSD_Components::Cached_Mapping_Table::Is_slot_reserved_for_lpn_and_waiting(unsigned short, unsigned long)
bool Cached_Mapping_Table::Is_slot_reserved_for_lpn_and_waiting(const stream_id_type streamID, const LPA_type lpn)
	{
		LPA_type key = LPN_TO_UNIQUE_KEY(streamID, lpn);
		auto it = addressMap.find(key);
		if (it != addressMap.end()) {
			if (it->second->Status == CMTEntryStatus::WAITING) {
				return true;
			}
		}

		return false;
	}

// Assembly:
shlq $0x38, %rsi
orq %rdx, %rsi
movq (%rdi), %r9
movq 0x8(%rdi), %r8
xorl %r10d, %r10d
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq (%r9,%rdx,8), %rax
testq %rax, %rax
je 0x299ac
movq (%rax), %r9
movq %rax, %r10
cmpq 0x8(%r9), %rsi
je 0x299ac
movq %rdx, %rcx
movq %r9, %r11
movq (%r9), %r9
testq %r9, %r9
je 0x299a9
movq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %r10d
cmpq %rcx, %rdx
jne 0x299ac
movq %r11, %r10
cmpq %rdi, %rsi
jne 0x2997d
jmp 0x299ac
xorl %r10d, %r10d
testq %r10, %r10
je 0x299b6
movq (%r10), %rax
jmp 0x299b8
xorl %eax, %eax
testq %rax, %rax
je 0x299c9
movq 0x10(%rax), %rcx
movb $0x1, %al
cmpl $0x1, 0x14(%rcx)
je 0x299cb
xorl %eax, %eax
retq