// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/nvm_chip/flash_memory/Flash_Chip.cpp
// Function: NVM::FlashMemory::Flash_Chip::start_command_execution(NVM::FlashMemory::Flash_Command*)
void Flash_Chip::start_command_execution(Flash_Command* command)
		{
			Die* targetDie = Dies[command->Address[0].DieID];

			//If this is a simple command (not multiplane) then there should be only one address
			if (command->Address.size() > 1
				&& (command->CommandCode == CMD_READ_PAGE
					|| command->CommandCode == CMD_PROGRAM_PAGE
					|| command->CommandCode == CMD_ERASE_BLOCK)) {
				PRINT_ERROR("Flash chip " << ID() << ": executing a flash operation on a busy die!")
			}

			targetDie->Expected_finish_time = Simulator->Time() + Get_command_execution_latency(command->CommandCode, command->Address[0].PageID);
			targetDie->CommandFinishEvent = Simulator->Register_sim_event(targetDie->Expected_finish_time,
				this, command, static_cast<int>(Chip_Sim_Event_Type::COMMAND_FINISHED));
			targetDie->CurrentCMD = command;
			targetDie->Status = DieStatus::BUSY;
			idleDieNo--;

			if (status == Internal_Status::IDLE) {
				executionStartTime = Simulator->Time();
				expectedFinishTime = targetDie->Expected_finish_time;
				status = Internal_Status::BUSY;
			}

			DEBUG("Command execution started on channel: " << this->ChannelID << " chip: " << this->ChipID)
		}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x8(%rsi), %rcx
movq 0x10(%rsi), %rdx
movl 0x8(%rcx), %esi
movq (%rax,%rsi,8), %r12
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rax
cmpq $0x2, %rax
jb 0x26e82
movq (%r14), %rax
cmpq $0x30, %rax
je 0x26f16
cmpq $0x8010, %rax           # imm = 0x8010
je 0x26f16
cmpq $0x60d0, %rax           # imm = 0x60D0
je 0x26f16
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
movq (%r14), %rsi
movq 0x8(%r14), %rax
movl 0x14(%rax), %edx
movq %rbx, %rdi
callq 0x27e7c
addq %r15, %rax
movq %rax, 0x18(%r12)
callq 0x281b4
movq 0x18(%r12), %rsi
movq %rax, %rdi
movq %rbx, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x285aa
movq %rax, 0x10(%r12)
movq %r14, 0x28(%r12)
movl $0x0, 0xc(%r12)
decl 0x3c(%rbx)
cmpl $0x0, 0x38(%rbx)
jne 0x26f0a
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, 0xa0(%rbx)
movq 0x18(%r12), %rax
movq %rax, 0xa8(%rbx)
movl $0x1, 0x38(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x480d3(%rip), %r14     # 0x6eff0
leaq 0x2f684(%rip), %rsi     # 0x565a8
movl $0x6, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x31187(%rip), %rsi     # 0x580bf
movl $0xb, %edx
movq %r14, %rdi
callq 0x7400
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xb036
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x7400
movq %rax, %rbx
leaq 0x3117f(%rip), %rsi     # 0x580fe
movl $0x2c, %edx
movq %rax, %rdi
callq 0x7400
movq %rbx, %rdi
callq 0x71c0
leaq 0x8(%rsp), %rdi
callq 0x76b8
movq 0x4802b(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x26fc6
callq 0x7370
movq %rbx, %rdi
callq 0x7620