// File: CMU-SAFARI[P]MQSim/src/exec/SSD_Device.cpp
// Function: SSD_Device::~SSD_Device()
SSD_Device::~SSD_Device()
{
	for (unsigned int channel_cntr = 0; channel_cntr < Channel_count; channel_cntr++)
	{
		for (unsigned int chip_cntr = 0; chip_cntr < Chip_no_per_channel; chip_cntr++)
		{
			delete ((SSD_Components::ONFI_Channel_NVDDR2 *)this->Channels[channel_cntr])->Chips[chip_cntr];
		}
		delete this->Channels[channel_cntr];
	}

	delete this->PHY;
	delete ((SSD_Components::FTL *)this->Firmware)->TSU;
	delete ((SSD_Components::FTL *)this->Firmware)->BlockManager;
	delete ((SSD_Components::FTL *)this->Firmware)->Address_Mapping_Unit;
	delete ((SSD_Components::FTL *)this->Firmware)->GC_and_WL_Unit;
	delete this->Firmware;
	delete this->Cache_manager;
	delete this->Host_interface;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0xac416(%rip), %rcx     # 0xd8b00
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0xac408(%rip), %rcx     # 0xd8b00
addq $0x48, %rcx
movq %rcx, 0x30(%rax)
movl $0x0, 0x5c(%rsp)
movq 0x50(%rsp), %rcx
movl 0x5c(%rsp), %eax
cmpl 0x78(%rcx), %eax
jae 0x2c7bf
movl $0x0, 0x58(%rsp)
movq 0x50(%rsp), %rcx
movl 0x58(%rsp), %eax
cmpl 0x7c(%rcx), %eax
jae 0x2c781
movq 0x50(%rsp), %rdi
addq $0x60, %rdi
movl 0x5c(%rsp), %eax
movl %eax, %esi
callq 0x2d290
movq (%rax), %rax
movq 0x8(%rax), %rax
movl 0x58(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, %rax
je 0x2c772
movq 0x48(%rsp), %rdi
callq 0x436b0
movq 0x48(%rsp), %rdi
callq 0x8410
jmp 0x2c774
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x2c722
movq 0x50(%rsp), %rdi
addq $0x60, %rdi
movl 0x5c(%rsp), %eax
movl %eax, %esi
callq 0x2d290
movq (%rax), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, %rax
je 0x2c7ad
movq 0x40(%rsp), %rdi
callq 0x8410
jmp 0x2c7af
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x2c708
movq 0x50(%rsp), %rax
movq 0x58(%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x2c7e7
movq 0x38(%rsp), %rdi
callq 0x8bc40
movq 0x38(%rsp), %rdi
callq 0x8410
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x2c80a
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x2c82d
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x2c850
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x2c87c
movq 0x18(%rsp), %rdi
callq 0x2d2b0
movq 0x18(%rsp), %rdi
callq 0x8410
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x2c8a4
movq 0x10(%rsp), %rdi
callq 0x2d2f0
movq 0x10(%rsp), %rdi
callq 0x8410
movq 0x50(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x2c8c3
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x2c8e0
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x50(%rsp), %rdi
addq $0x60, %rdi
callq 0x2d230
movq 0x50(%rsp), %rdi
callq 0x1ff90
addq $0x68, %rsp
retq
nopl (%rax)