// File: CMU-SAFARI[P]MQSim/src/ssd/NVM_PHY_ONFI_NVDDR2.cpp
// Function: SSD_Components::NVM_PHY_ONFI_NVDDR2::Send_command_to_chip(std::__cxx11::list<SSD_Components::NVM_Transaction_Flash*, std::allocator<SSD_Components::NVM_Transaction_Flash*>>&)
void NVM_PHY_ONFI_NVDDR2::Send_command_to_chip(std::list<NVM_Transaction_Flash*>& transaction_list)
	{
		ONFI_Channel_NVDDR2* target_channel = channels[transaction_list.front()->Address.ChannelID];

		NVM::FlashMemory::Flash_Chip* targetChip = target_channel->Chips[transaction_list.front()->Address.ChipID];
		ChipBookKeepingEntry* chipBKE = &bookKeepingTable[transaction_list.front()->Address.ChannelID][transaction_list.front()->Address.ChipID];
		DieBookKeepingEntry* dieBKE = &chipBKE->Die_book_keeping_records[transaction_list.front()->Address.DieID];

		/*If this is not a die-interleaved command execution, and the channel is already busy,
		* then something illegarl is happening*/
		if (target_channel->GetStatus() == BusChannelStatus::BUSY && chipBKE->OngoingDieCMDTransfers.size() == 0) {
			PRINT_ERROR("Bus " << target_channel->ChannelID << ": starting communication on a busy flash channel!");
		}

		sim_time_type suspendTime = 0;
		if (!dieBKE->Free) {
			if (transaction_list.front()->SuspendRequired) {
				switch (dieBKE->ActiveTransactions.front()->Type) {
					case Transaction_Type::WRITE:
						Stats::IssuedSuspendProgramCMD++;
						suspendTime = target_channel->ProgramSuspendCommandTime + targetChip->GetSuspendProgramTime();
						break;
					case Transaction_Type::ERASE:
						Stats::IssuedSuspendEraseCMD++;
						suspendTime = target_channel->EraseSuspendCommandTime + targetChip->GetSuspendEraseTime();
						break;
					default:
						PRINT_ERROR("Read suspension is not supported!")
				}
				targetChip->Suspend(transaction_list.front()->Address.DieID);
				dieBKE->PrepareSuspend();
				if (chipBKE->OngoingDieCMDTransfers.size()) {
					chipBKE->PrepareSuspend();
				}
			} else {
				PRINT_ERROR("Read suspension is not supported!")
			}
		}

		dieBKE->Free = false;
		dieBKE->ActiveCommand = new NVM::FlashMemory::Flash_Command();
		for (std::list<NVM_Transaction_Flash*>::iterator it = transaction_list.begin();
			it != transaction_list.end(); it++) {
			dieBKE->ActiveTransactions.push_back(*it);
			dieBKE->ActiveCommand->Address.push_back((*it)->Address);
			NVM::FlashMemory::PageMetadata metadata;
			metadata.LPA = (*it)->LPA;
			dieBKE->ActiveCommand->Meta_data.push_back(metadata);
		}

		switch (transaction_list.front()->Type) {
			case Transaction_Type::READ:
				if (transaction_list.size() == 1) {
					Stats::IssuedReadCMD++;
					dieBKE->ActiveCommand->CommandCode = CMD_READ_PAGE;
					DEBUG("Chip " << targetChip->ChannelID << ", " << targetChip->ChipID << ", " << transaction_list.front()->Address.DieID << ": Sending read command to chip for LPA: " << transaction_list.front()->LPA)
				} else {
					Stats::IssuedMultiplaneReadCMD++;
					dieBKE->ActiveCommand->CommandCode = CMD_READ_PAGE_MULTIPLANE;
					DEBUG("Chip " << targetChip->ChannelID << ", " << targetChip->ChipID << ", " << transaction_list.front()->Address.DieID << ": Sending multi-plane read command to chip for LPA: " << transaction_list.front()->LPA)
				}

				for (std::list<NVM_Transaction_Flash*>::iterator it = transaction_list.begin();
					it != transaction_list.end(); it++) {
					(*it)->STAT_transfer_time += target_channel->ReadCommandTime[transaction_list.size()];
				}
				if (chipBKE->OngoingDieCMDTransfers.size() == 0) {
					targetChip->StartCMDXfer();
					chipBKE->Status = ChipStatus::CMD_IN;
					chipBKE->Last_transfer_finish_time = Simulator->Time() + suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
					Simulator->Register_sim_event(Simulator->Time() + suspendTime + target_channel->ReadCommandTime[transaction_list.size()], this,
						dieBKE, (int)NVDDR2_SimEventType::READ_CMD_ADDR_TRANSFERRED);
				} else {
					dieBKE->DieInterleavedTime = suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
					chipBKE->Last_transfer_finish_time += suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
				}
				chipBKE->OngoingDieCMDTransfers.push(dieBKE);

				dieBKE->Expected_finish_time = chipBKE->Last_transfer_finish_time + targetChip->Get_command_execution_latency(dieBKE->ActiveCommand->CommandCode, dieBKE->ActiveCommand->Address[0].PageID);
				if (chipBKE->Expected_command_exec_finish_time < dieBKE->Expected_finish_time) {
					chipBKE->Expected_command_exec_finish_time = dieBKE->Expected_finish_time;
				}
				break;
			case Transaction_Type::WRITE:
				if (((NVM_Transaction_Flash_WR*)transaction_list.front())->ExecutionMode == WriteExecutionModeType::SIMPLE) {
					if (transaction_list.size() == 1) {
						Stats::IssuedProgramCMD++;
						dieBKE->ActiveCommand->CommandCode = CMD_PROGRAM_PAGE;
						DEBUG("Chip " << targetChip->ChannelID << ", " << targetChip->ChipID << ", " << transaction_list.front()->Address.DieID << ": Sending program command to chip for LPA: " << transaction_list.front()->LPA)
					} else {
						Stats::IssuedMultiplaneProgramCMD++;
						dieBKE->ActiveCommand->CommandCode = CMD_PROGRAM_PAGE_MULTIPLANE;
						DEBUG("Chip " << targetChip->ChannelID << ", " << targetChip->ChipID << ", " << transaction_list.front()->Address.DieID << ": Sending multi-plane program command to chip for LPA: " << transaction_list.front()->LPA)
					}

					sim_time_type data_transfer_time = 0;

					for (std::list<NVM_Transaction_Flash*>::iterator it = transaction_list.begin();
						it != transaction_list.end(); it++) {
						(*it)->STAT_transfer_time += target_channel->ProgramCommandTime[transaction_list.size()] + NVDDR2DataInTransferTime((*it)->Data_and_metadata_size_in_byte, target_channel);
						data_transfer_time += NVDDR2DataInTransferTime((*it)->Data_and_metadata_size_in_byte, target_channel);
					}
					if (chipBKE->OngoingDieCMDTransfers.size() == 0) {
						targetChip->StartCMDDataInXfer();
						chipBKE->Status = ChipStatus::CMD_DATA_IN;
						chipBKE->Last_transfer_finish_time = Simulator->Time() + suspendTime + target_channel->ProgramCommandTime[transaction_list.size()] + data_transfer_time;
						Simulator->Register_sim_event(Simulator->Time() + suspendTime + target_channel->ProgramCommandTime[transaction_list.size()] + data_transfer_time,
							this, dieBKE, (int)NVDDR2_SimEventType::PROGRAM_CMD_ADDR_DATA_TRANSFERRED);
					} else {
						dieBKE->DieInterleavedTime = suspendTime + target_channel->ProgramCommandTime[transaction_list.size()] + data_transfer_time;
						chipBKE->Last_transfer_finish_time += suspendTime + target_channel->ProgramCommandTime[transaction_list.size()] + data_transfer_time;
					}
					chipBKE->OngoingDieCMDTransfers.push(dieBKE);

					dieBKE->Expected_finish_time = chipBKE->Last_transfer_finish_time + targetChip->Get_command_execution_latency(dieBKE->ActiveCommand->CommandCode, dieBKE->ActiveCommand->Address[0].PageID);
					if (chipBKE->Expected_command_exec_finish_time < dieBKE->Expected_finish_time) {
						chipBKE->Expected_command_exec_finish_time = dieBKE->Expected_finish_time;
					}
				} else {
					//Copyback write for GC

					if (transaction_list.size() == 1) {
						Stats::IssuedCopybackReadCMD++;
						dieBKE->ActiveCommand->CommandCode = CMD_READ_PAGE_COPYBACK;
					} else {
						Stats::IssuedMultiplaneCopybackProgramCMD++;
						dieBKE->ActiveCommand->CommandCode = CMD_READ_PAGE_COPYBACK_MULTIPLANE;
					}

					for (std::list<NVM_Transaction_Flash*>::iterator it = transaction_list.begin();
						it != transaction_list.end(); it++) {
						(*it)->STAT_transfer_time += target_channel->ReadCommandTime[transaction_list.size()];
					}
					if (chipBKE->OngoingDieCMDTransfers.size() == 0) {
						targetChip->StartCMDXfer();
						chipBKE->Status = ChipStatus::CMD_IN;
						chipBKE->Last_transfer_finish_time = Simulator->Time() + suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
						Simulator->Register_sim_event(Simulator->Time() + suspendTime + target_channel->ReadCommandTime[transaction_list.size()], this,
							dieBKE, (int)NVDDR2_SimEventType::READ_CMD_ADDR_TRANSFERRED);
					} else {
						dieBKE->DieInterleavedTime = suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
						chipBKE->Last_transfer_finish_time += suspendTime + target_channel->ReadCommandTime[transaction_list.size()];
					}
					chipBKE->OngoingDieCMDTransfers.push(dieBKE);

					dieBKE->Expected_finish_time = chipBKE->Last_transfer_finish_time + targetChip->Get_command_execution_latency(dieBKE->ActiveCommand->CommandCode, dieBKE->ActiveCommand->Address[0].PageID);
					if (chipBKE->Expected_command_exec_finish_time < dieBKE->Expected_finish_time) {
						chipBKE->Expected_command_exec_finish_time = dieBKE->Expected_finish_time;
					}
				}
				break;
			case Transaction_Type::ERASE:
				//DEBUG2("Chip " << targetChip->ChannelID << ", " << targetChip->ChipID << ", " << transaction_list.front()->Address.DieID << ": Sending erase command to chip")
				if (transaction_list.size() == 1) {
					Stats::IssuedEraseCMD++;
					dieBKE->ActiveCommand->CommandCode = CMD_ERASE_BLOCK;
				} else {
					Stats::IssuedMultiplaneEraseCMD++;
					dieBKE->ActiveCommand->CommandCode = CMD_ERASE_BLOCK_MULTIPLANE;
				}

				for (std::list<NVM_Transaction_Flash*>::iterator it = transaction_list.begin();
					it != transaction_list.end(); it++) {
					(*it)->STAT_transfer_time += target_channel->EraseCommandTime[transaction_list.size()];
				}
				if (chipBKE->OngoingDieCMDTransfers.size() == 0) {
					targetChip->StartCMDXfer();
					chipBKE->Status = ChipStatus::CMD_IN;
					chipBKE->Last_transfer_finish_time = Simulator->Time() + suspendTime + target_channel->EraseCommandTime[transaction_list.size()];
					Simulator->Register_sim_event(Simulator->Time() + suspendTime + target_channel->EraseCommandTime[transaction_list.size()],
						this, dieBKE, (int)NVDDR2_SimEventType::ERASE_SETUP_COMPLETED);
				} else {
					dieBKE->DieInterleavedTime = suspendTime + target_channel->EraseCommandTime[transaction_list.size()];
					chipBKE->Last_transfer_finish_time += suspendTime + target_channel->EraseCommandTime[transaction_list.size()];
				}
				chipBKE->OngoingDieCMDTransfers.push(dieBKE);

				dieBKE->Expected_finish_time = chipBKE->Last_transfer_finish_time + targetChip->Get_command_execution_latency(dieBKE->ActiveCommand->CommandCode, dieBKE->ActiveCommand->Address[0].PageID);
				if (chipBKE->Expected_command_exec_finish_time < dieBKE->Expected_finish_time) {
					chipBKE->Expected_command_exec_finish_time = dieBKE->Expected_finish_time;
				}
				break;
			default:
				throw std::invalid_argument("NVM_PHY_ONFI_NVDDR2: Unhandled event specified!");
		}

		target_channel->SetStatus(BusChannelStatus::BUSY, targetChip);
	}

// Assembly:
subq $0x318, %rsp            # imm = 0x318
movq %rdi, 0x310(%rsp)
movq %rsi, 0x308(%rsp)
movq 0x310(%rsp), %rax
movq %rax, 0x228(%rsp)
movq 0x88(%rax), %rax
movq %rax, 0x218(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq %rax, %rcx
movq 0x218(%rsp), %rax
movq (%rcx), %rcx
movl 0x38(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x300(%rsp)
movq 0x300(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x220(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq 0x220(%rsp), %rcx
movq %rax, %rdx
movq 0x228(%rsp), %rax
movq (%rdx), %rdx
movl 0x3c(%rdx), %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x2f8(%rsp)
movq 0x90(%rax), %rax
movq %rax, 0x230(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq %rax, %rcx
movq 0x230(%rsp), %rax
movq (%rcx), %rcx
movl 0x38(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x238(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq %rax, %rcx
movq 0x238(%rsp), %rax
movq (%rcx), %rcx
movl 0x3c(%rcx), %ecx
shlq $0x7, %rcx
addq %rcx, %rax
movq %rax, 0x2f0(%rsp)
movq 0x2f0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x240(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq %rax, %rcx
movq 0x240(%rsp), %rax
movq (%rcx), %rcx
movl 0x40(%rcx), %ecx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x2e8(%rsp)
movq 0x300(%rsp), %rdi
callq 0x91a90
cmpl $0x0, %eax
jne 0x8e8d6
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
jne 0x8e8d6
movq 0x4b77f(%rip), %rdi     # 0xd9ff0
leaq 0x1c070(%rip), %rsi     # 0xaa8e8
callq 0x8440
movq 0x4b76c(%rip), %rdi     # 0xd9ff0
leaq 0x1fd99(%rip), %rsi     # 0xae624
callq 0x8440
movq %rax, %rdi
movq 0x300(%rsp), %rax
movl (%rax), %esi
callq 0x85b0
movq %rax, %rdi
leaq 0x1fd7d(%rip), %rsi     # 0xae629
callq 0x8440
movq %rax, %rdi
movq 0x4b69d(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x4b709(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq $0x0, 0x2e0(%rsp)
movq 0x2e8(%rsp), %rax
testb $0x1, 0x48(%rax)
jne 0x8eaea
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq (%rax), %rax
testb $0x1, 0x68(%rax)
je 0x8ea9d
movq 0x2e8(%rsp), %rdi
addq $0x8, %rdi
callq 0x7fe10
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, 0x214(%rsp)
subl $0x1, %eax
je 0x8e944
jmp 0x8e933
movl 0x214(%rsp), %eax
subl $0x2, %eax
je 0x8e99b
jmp 0x8e9ef
leaq 0x4be5d(%rip), %rax     # 0xda7a8
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4be4f(%rip), %rax     # 0xda7a8
movq %rcx, (%rax)
movq 0x300(%rsp), %rax
movq 0xa0(%rax), %rax
movq %rax, 0x208(%rsp)
movq 0x2f8(%rsp), %rdi
callq 0x44b40
movq %rax, %rcx
movq 0x208(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x2e0(%rsp)
jmp 0x8ea3a
leaq 0x4be36(%rip), %rax     # 0xda7d8
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4be28(%rip), %rax     # 0xda7d8
movq %rcx, (%rax)
movq 0x300(%rsp), %rax
movq 0xd0(%rax), %rax
movq %rax, 0x200(%rsp)
movq 0x2f8(%rsp), %rdi
callq 0x44b50
movq %rax, %rcx
movq 0x200(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x2e0(%rsp)
jmp 0x8ea3a
movq 0x4b5fa(%rip), %rdi     # 0xd9ff0
leaq 0x1beeb(%rip), %rsi     # 0xaa8e8
callq 0x8440
movq 0x4b5e7(%rip), %rdi     # 0xd9ff0
leaq 0x1fc4b(%rip), %rsi     # 0xae65b
callq 0x8440
movq %rax, %rdi
movq 0x4b539(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x4b5a5(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq 0x2f8(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq 0x1f8(%rsp), %rdi
movq (%rax), %rax
movl 0x40(%rax), %esi
callq 0x44720
movq 0x2e8(%rsp), %rdi
callq 0x91ab0
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
je 0x8ea9b
movq 0x2f0(%rsp), %rdi
callq 0x91b90
jmp 0x8eae8
movq 0x4b54c(%rip), %rdi     # 0xd9ff0
leaq 0x1be3d(%rip), %rsi     # 0xaa8e8
callq 0x8440
movq 0x4b539(%rip), %rdi     # 0xd9ff0
leaq 0x1fb9d(%rip), %rsi     # 0xae65b
callq 0x8440
movq %rax, %rdi
movq 0x4b48b(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x4b4f7(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
jmp 0x8eaea
movq 0x2e8(%rsp), %rax
movb $0x0, 0x48(%rax)
movl $0x38, %edi
callq 0x8450
movq %rax, %rdi
movq %rdi, 0x1f0(%rsp)
xorl %esi, %esi
movl $0x38, %edx
callq 0x8260
movq 0x1f0(%rsp), %rdi
callq 0x91bb0
movq 0x1f0(%rsp), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, (%rax)
movq 0x308(%rsp), %rdi
callq 0x7ff20
movq %rax, 0x2d8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x5d430
movq %rax, 0x2d0(%rsp)
leaq 0x2d8(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x80030
testb $0x1, %al
jne 0x8eb7f
jmp 0x8ec3c
movq 0x2e8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x1e0(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0x7fda0
movq 0x1e0(%rsp), %rdi
movq %rax, %rsi
callq 0x5d3a0
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, 0x1e8(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0x7fda0
movq 0x1e8(%rsp), %rdi
movq (%rax), %rsi
addq $0x38, %rsi
callq 0x59da0
leaq 0x2d8(%rsp), %rdi
callq 0x7fda0
movq (%rax), %rax
movq 0x58(%rax), %rax
movq %rax, 0x2c8(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rdi
addq $0x20, %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x91be0
leaq 0x2d8(%rsp), %rdi
xorl %esi, %esi
callq 0x91c50
movq %rax, 0x2c0(%rsp)
jmp 0x8eb4c
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq (%rax), %rax
movl 0x8(%rax), %eax
movl %eax, 0x1dc(%rsp)
testl %eax, %eax
je 0x8ec83
jmp 0x8ec5c
movl 0x1dc(%rsp), %eax
subl $0x1, %eax
je 0x8f034
jmp 0x8ec6e
movl 0x1dc(%rsp), %eax
subl $0x2, %eax
je 0x8f871
jmp 0x8fbda
movq 0x308(%rsp), %rdi
callq 0x91c80
cmpq $0x1, %rax
jne 0x8ecc2
leaq 0x4babb(%rip), %rax     # 0xda758
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4baad(%rip), %rax     # 0xda758
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x30, (%rax)
jmp 0x8ecec
leaq 0x4baa7(%rip), %rax     # 0xda770
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4ba99(%rip), %rax     # 0xda770
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x32, (%rax)
movq 0x308(%rsp), %rdi
callq 0x7ff20
movq %rax, 0x2b8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x5d430
movq %rax, 0x2b0(%rsp)
leaq 0x2b8(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0x80030
testb $0x1, %al
jne 0x8ed31
jmp 0x8eda2
movq 0x300(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq %rax, %rcx
movq 0x1c8(%rsp), %rax
movq 0x28(%rax,%rcx,8), %rax
movq %rax, 0x1d0(%rsp)
leaq 0x2b8(%rsp), %rdi
callq 0x7fda0
movq 0x1d0(%rsp), %rcx
movq (%rax), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
leaq 0x2b8(%rsp), %rdi
xorl %esi, %esi
callq 0x91c50
movq %rax, 0x2a8(%rsp)
jmp 0x8ed01
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
jne 0x8eebd
movq 0x2f8(%rsp), %rdi
callq 0x91cb0
movq 0x2f0(%rsp), %rax
movl $0x1, (%rax)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x1a0(%rsp), %rcx
movq %rax, %rdx
movq 0x1a8(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x18(%rax)
callq 0x46500
movq %rax, 0x1b8(%rsp)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x1b0(%rsp), %rsi
movq 0x1b8(%rsp), %rdi
movq 0x228(%rsp), %rdx
movq %rax, %rcx
movq 0x1c0(%rsp), %rax
addq 0x28(%rax,%rcx,8), %rsi
movq 0x2e8(%rsp), %rcx
movl $0x1, %r8d
callq 0x46c60
jmp 0x8ef63
movq 0x2e0(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x180(%rsp), %rcx
movq %rax, %rdx
movq 0x188(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x2e0(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x190(%rsp), %rcx
movq %rax, %rdx
movq 0x198(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x91cf0
movq 0x2f0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x178(%rsp)
movq 0x2f8(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0x170(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x45760
movq 0x168(%rsp), %rdi
movq 0x170(%rsp), %rsi
movl 0x14(%rax), %edx
callq 0x457a0
movq 0x178(%rsp), %rcx
addq %rax, %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x2f0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x2e8(%rsp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x8f02f
movq 0x2e8(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8fc35
movq 0x308(%rsp), %rdi
callq 0x7fe10
movq (%rax), %rax
cmpl $0x0, 0xa8(%rax)
jne 0x8f4be
movq 0x308(%rsp), %rdi
callq 0x91c80
cmpq $0x1, %rax
jne 0x8f090
leaq 0x4b715(%rip), %rax     # 0xda780
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4b707(%rip), %rax     # 0xda780
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x8010, (%rax)         # imm = 0x8010
jmp 0x8f0ba
leaq 0x4b6f9(%rip), %rax     # 0xda790
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4b6eb(%rip), %rax     # 0xda790
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x8011, (%rax)         # imm = 0x8011
movq $0x0, 0x2a0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x7ff20
movq %rax, 0x298(%rsp)
movq 0x308(%rsp), %rdi
callq 0x5d430
movq %rax, 0x290(%rsp)
leaq 0x298(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0x80030
testb $0x1, %al
jne 0x8f10e
jmp 0x8f20c
movq 0x300(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq %rax, %rcx
movq 0x150(%rsp), %rax
movq 0x78(%rax,%rcx,8), %rax
movq %rax, 0x158(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x7fda0
movq (%rax), %rax
movl 0x50(%rax), %eax
movq 0x300(%rsp), %rcx
xorl %edx, %edx
divl 0xd8(%rcx)
movl %eax, %ecx
movq 0x158(%rsp), %rax
shrl %ecx
movl %ecx, %ecx
movq 0x300(%rsp), %rdx
imulq 0x70(%rdx), %rcx
addq %rcx, %rax
movq %rax, 0x160(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x7fda0
movq 0x160(%rsp), %rcx
movq (%rax), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
leaq 0x298(%rsp), %rdi
callq 0x7fda0
movq (%rax), %rax
movl 0x50(%rax), %eax
movq 0x300(%rsp), %rcx
xorl %edx, %edx
divl 0xd8(%rcx)
shrl %eax
movl %eax, %eax
movq 0x300(%rsp), %rcx
imulq 0x70(%rcx), %rax
addq 0x2a0(%rsp), %rax
movq %rax, 0x2a0(%rsp)
leaq 0x298(%rsp), %rdi
xorl %esi, %esi
callq 0x91c50
movq %rax, 0x288(%rsp)
jmp 0x8f0db
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
jne 0x8f337
movq 0x2f8(%rsp), %rdi
callq 0x91d20
movq 0x2f0(%rsp), %rax
movl $0x2, (%rax)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x128(%rsp), %rcx
movq %rax, %rdx
movq 0x130(%rsp), %rax
addq 0x78(%rax,%rdx,8), %rcx
addq 0x2a0(%rsp), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x18(%rax)
callq 0x46500
movq %rax, 0x140(%rsp)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdi
movq 0x228(%rsp), %rdx
movq %rax, %rcx
movq 0x148(%rsp), %rax
addq 0x78(%rax,%rcx,8), %rsi
addq 0x2a0(%rsp), %rsi
movq 0x2e8(%rsp), %rcx
movl $0x2, %r8d
callq 0x46c60
jmp 0x8f3ed
movq 0x2e0(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x108(%rsp), %rcx
movq %rax, %rdx
movq 0x110(%rsp), %rax
addq 0x78(%rax,%rdx,8), %rcx
addq 0x2a0(%rsp), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x2e0(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x118(%rsp), %rcx
movq %rax, %rdx
movq 0x120(%rsp), %rax
addq 0x78(%rax,%rdx,8), %rcx
addq 0x2a0(%rsp), %rcx
movq 0x2f0(%rsp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x91cf0
movq 0x2f0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x2f8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0xf8(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x45760
movq 0xf0(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movl 0x14(%rax), %edx
callq 0x457a0
movq 0x100(%rsp), %rcx
addq %rax, %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x2f0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x2e8(%rsp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x8f4b9
movq 0x2e8(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8f86c
movq 0x308(%rsp), %rdi
callq 0x91c80
cmpq $0x1, %rax
jne 0x8f4fd
leaq 0x4b288(%rip), %rax     # 0xda760
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4b27a(%rip), %rax     # 0xda760
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x35, (%rax)
jmp 0x8f527
leaq 0x4b294(%rip), %rax     # 0xda798
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4b286(%rip), %rax     # 0xda798
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x321, (%rax)          # imm = 0x321
movq 0x308(%rsp), %rdi
callq 0x7ff20
movq %rax, 0x280(%rsp)
movq 0x308(%rsp), %rdi
callq 0x5d430
movq %rax, 0x278(%rsp)
leaq 0x280(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0x80030
testb $0x1, %al
jne 0x8f56c
jmp 0x8f5dd
movq 0x300(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq %rax, %rcx
movq 0xe0(%rsp), %rax
movq 0x28(%rax,%rcx,8), %rax
movq %rax, 0xe8(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x7fda0
movq 0xe8(%rsp), %rcx
movq (%rax), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
leaq 0x280(%rsp), %rdi
xorl %esi, %esi
callq 0x91c50
movq %rax, 0x270(%rsp)
jmp 0x8f53c
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
jne 0x8f6f8
movq 0x2f8(%rsp), %rdi
callq 0x91cb0
movq 0x2f0(%rsp), %rax
movl $0x1, (%rax)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0xb8(%rsp), %rcx
movq %rax, %rdx
movq 0xc0(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x18(%rax)
callq 0x46500
movq %rax, 0xd0(%rsp)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdi
movq 0x228(%rsp), %rdx
movq %rax, %rcx
movq 0xd8(%rsp), %rax
addq 0x28(%rax,%rcx,8), %rsi
movq 0x2e8(%rsp), %rcx
movl $0x1, %r8d
callq 0x46c60
jmp 0x8f79e
movq 0x2e0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x98(%rsp), %rcx
movq %rax, %rdx
movq 0xa0(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x2e0(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0xa8(%rsp), %rcx
movq %rax, %rdx
movq 0xb0(%rsp), %rax
addq 0x28(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x91cf0
movq 0x2f0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x90(%rsp)
movq 0x2f8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0x88(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x45760
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movl 0x14(%rax), %edx
callq 0x457a0
movq 0x90(%rsp), %rcx
addq %rax, %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x2f0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x2e8(%rsp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x8f86a
movq 0x2e8(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8f86c
jmp 0x8fc35
movq 0x308(%rsp), %rdi
callq 0x91c80
cmpq $0x1, %rax
jne 0x8f8b0
leaq 0x4af2d(%rip), %rax     # 0xda7b8
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4af1f(%rip), %rax     # 0xda7b8
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x60d0, (%rax)         # imm = 0x60D0
jmp 0x8f8da
leaq 0x4af11(%rip), %rax     # 0xda7c8
movq (%rax), %rcx
addq $0x1, %rcx
leaq 0x4af03(%rip), %rax     # 0xda7c8
movq %rcx, (%rax)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq $0x60d1, (%rax)         # imm = 0x60D1
movq 0x308(%rsp), %rdi
callq 0x7ff20
movq %rax, 0x268(%rsp)
movq 0x308(%rsp), %rdi
callq 0x5d430
movq %rax, 0x260(%rsp)
leaq 0x268(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x80030
testb $0x1, %al
jne 0x8f91f
jmp 0x8f987
movq 0x300(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq %rax, %rcx
movq 0x70(%rsp), %rax
movq 0xa8(%rax,%rcx,8), %rax
movq %rax, 0x78(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x7fda0
movq 0x78(%rsp), %rcx
movq (%rax), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
leaq 0x268(%rsp), %rdi
xorl %esi, %esi
callq 0x91c50
movq %rax, 0x258(%rsp)
jmp 0x8f8ef
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
callq 0x91aa0
cmpq $0x0, %rax
jne 0x8fa8a
movq 0x2f8(%rsp), %rdi
callq 0x91cb0
movq 0x2f0(%rsp), %rax
movl $0x1, (%rax)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x48(%rsp), %rcx
movq %rax, %rdx
movq 0x50(%rsp), %rax
addq 0xa8(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x18(%rax)
callq 0x46500
movq %rax, 0x60(%rsp)
callq 0x46500
movq %rax, %rdi
callq 0x46c50
addq 0x2e0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdi
movq 0x228(%rsp), %rdx
movq %rax, %rcx
movq 0x68(%rsp), %rax
addq 0xa8(%rax,%rcx,8), %rsi
movq 0x2e8(%rsp), %rcx
movl $0x4, %r8d
callq 0x46c60
jmp 0x8fb1e
movq 0x2e0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x28(%rsp), %rcx
movq %rax, %rdx
movq 0x30(%rsp), %rax
addq 0xa8(%rax,%rdx,8), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x2e0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x308(%rsp), %rdi
callq 0x91c80
movq 0x38(%rsp), %rcx
movq %rax, %rdx
movq 0x40(%rsp), %rax
addq 0xa8(%rax,%rdx,8), %rcx
movq 0x2f0(%rsp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movq 0x2f0(%rsp), %rdi
addq $0x28, %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x91cf0
movq 0x2f0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x2f8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x2e8(%rsp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x45760
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x14(%rax), %edx
callq 0x457a0
movq 0x20(%rsp), %rcx
addq %rax, %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x2f0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x2e8(%rsp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x8fbd8
movq 0x2e8(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x2f0(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x8fc35
movl $0x10, %edi
callq 0x8200
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
leaq 0x1ea87(%rip), %rsi     # 0xae67d
callq 0x87d0
jmp 0x8fbfd
movq 0x8(%rsp), %rdi
movq 0x4a3bf(%rip), %rsi     # 0xd9fc8
movq 0x4a3a0(%rip), %rdx     # 0xd9fb0
callq 0x8710
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x250(%rsp)
movl %eax, 0x24c(%rsp)
callq 0x8330
jmp 0x8fc54
movq 0x300(%rsp), %rdi
movq 0x2f8(%rsp), %rdx
xorl %esi, %esi
callq 0x91d60
addq $0x318, %rsp            # imm = 0x318
retq
movq 0x250(%rsp), %rdi
callq 0x8770
nopw %cs:(%rax,%rax)