// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/ssd/NVM_PHY_ONFI_NVDDR2.cpp
// Function: SSD_Components::NVM_PHY_ONFI_NVDDR2::NVM_PHY_ONFI_NVDDR2(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, SSD_Components::ONFI_Channel_NVDDR2**, unsigned int, unsigned int, unsigned int, unsigned int)
NVM_PHY_ONFI_NVDDR2::NVM_PHY_ONFI_NVDDR2(const sim_object_id_type& id, ONFI_Channel_NVDDR2** channels,
		unsigned int ChannelCount, unsigned int chip_no_per_channel, unsigned int DieNoPerChip, unsigned int PlaneNoPerDie)
		: NVM_PHY_ONFI(id, ChannelCount, chip_no_per_channel, DieNoPerChip, PlaneNoPerDie), channels(channels)
	{
		WaitingReadTX = new Flash_Transaction_Queue[channel_count];
		WaitingGCRead_TX = new Flash_Transaction_Queue[channel_count];
		WaitingMappingRead_TX = new Flash_Transaction_Queue[channel_count];
		WaitingCopybackWrites = new std::list<DieBookKeepingEntry*>[channel_count];
		bookKeepingTable = new ChipBookKeepingEntry*[channel_count];
		for (unsigned int channelID = 0; channelID < channel_count; channelID++) {
			bookKeepingTable[channelID] = new ChipBookKeepingEntry[chip_no_per_channel];
			for (unsigned int chipID = 0; chipID < chip_no_per_channel; chipID++) {
				bookKeepingTable[channelID][chipID].Expected_command_exec_finish_time = T0; 
				bookKeepingTable[channelID][chipID].Last_transfer_finish_time = T0;
				bookKeepingTable[channelID][chipID].Die_book_keeping_records = new DieBookKeepingEntry[DieNoPerChip];
				bookKeepingTable[channelID][chipID].Status = ChipStatus::IDLE;
				bookKeepingTable[channelID][chipID].HasSuspend = false;
				bookKeepingTable[channelID][chipID].WaitingReadTXCount = 0;
				bookKeepingTable[channelID][chipID].No_of_active_dies = 0;
				for (unsigned int dieID = 0; dieID < DieNoPerChip; dieID++) {
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].ActiveCommand = NULL;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].ActiveTransactions.clear();
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].SuspendedCommand = NULL;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].SuspendedTransactions.clear();
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Free = true;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Suspended = false;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].DieInterleavedTime = INVALID_TIME;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Expected_finish_time = INVALID_TIME;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].RemainingExecTime = INVALID_TIME;
				}
			}
		}
		_my_instance = this;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, %r14d
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0xb036
movq %rbx, %rdi
movq %r13, %rsi
callq 0x45790
movl 0xb0(%rsp), %eax
leaq 0x28e6f(%rip), %rcx     # 0x6eb48
movq %rcx, (%rbx)
movl %r12d, 0x2c(%rbx)
movl %ebp, 0x24(%rsp)
movl %ebp, 0x30(%rbx)
movl %r14d, 0x14(%rsp)
movl %r14d, 0x34(%rbx)
movl %eax, 0x38(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x40(%rbx)
movdqu %xmm0, 0x50(%rbx)
movdqu %xmm0, 0x60(%rbx)
movdqu %xmm0, 0x70(%rbx)
movq $0x0, 0x80(%rbx)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x45d2a
callq 0x7370
leaq 0x28d6f(%rip), %rax     # 0x6eaa0
movq %rax, (%rbx)
movq %r15, 0x88(%rbx)
movq %rbx, 0x8(%rsp)
movl 0x2c(%rbx), %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r14
testq %rbx, %rbx
je 0x45d8e
imulq $-0x108, %rbx, %rbp     # imm = 0xFEF8
xorl %r13d, %r13d
movq %r14, %r12
movq %r12, %rdi
callq 0x3e844
addq $-0x108, %r13           # imm = 0xFEF8
addq $0x108, %r12            # imm = 0x108
cmpq %r13, %rbp
jne 0x45d73
movq 0x8(%rsp), %rax
movq %r14, 0x98(%rax)
movl 0x2c(%rax), %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r14
testq %rbx, %rbx
je 0x45de8
imulq $-0x108, %rbx, %rbp     # imm = 0xFEF8
xorl %r13d, %r13d
movq %r14, %r12
movq %r12, %rdi
callq 0x3e844
addq $-0x108, %r13           # imm = 0xFEF8
addq $0x108, %r12            # imm = 0x108
cmpq %r13, %rbp
jne 0x45dcd
movq 0x8(%rsp), %rax
movq %r14, 0xa0(%rax)
movl 0x2c(%rax), %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r14
testq %rbx, %rbx
je 0x45e42
imulq $-0x108, %rbx, %rbp     # imm = 0xFEF8
xorl %r13d, %r13d
movq %r14, %r12
movq %r12, %rdi
callq 0x3e844
addq $-0x108, %r13           # imm = 0xFEF8
addq $0x108, %r12            # imm = 0x108
cmpq %r13, %rbp
jne 0x45e27
movq 0x8(%rsp), %rax
movq %r14, 0xa8(%rax)
movl 0x2c(%rax), %r15d
leaq (%r15,%r15,2), %rbx
leaq 0x8(,%rbx,8), %rdi
callq 0x7030
movq %r15, (%rax)
addq $0x8, %rax
testq %r15, %r15
je 0x45e8e
leaq (%rax,%rbx,8), %rcx
movq %rax, %rdx
movq %rdx, 0x8(%rdx)
movq %rdx, (%rdx)
movq $0x0, 0x10(%rdx)
addq $0x18, %rdx
cmpq %rcx, %rdx
jne 0x45e76
movq 0x8(%rsp), %rcx
movq %rax, 0xb0(%rcx)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x7030
movq 0x8(%rsp), %rbx
movq %rax, 0x90(%rbx)
cmpl $0x0, 0x2c(%rbx)
movl 0x14(%rsp), %eax
movl 0x24(%rsp), %r14d
je 0x46131
movl %r14d, %ecx
movq %rcx, 0x28(%rsp)
shlq $0x7, %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x38(%rsp)
movl %eax, %eax
movq %rax, 0x30(%rsp)
imulq $0x68, %rax, %rax
movq %rax, 0x40(%rsp)
addq $0x8, %rax
movq %rax, 0x48(%rsp)
negq %rcx
movq %rcx, 0x50(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x38(%rsp), %rdi
callq 0x7030
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq %rax, (%rcx)
testl %r14d, %r14d
je 0x45f65
movq 0x18(%rsp), %rax
leaq 0x30(%rax), %r15
xorl %ebp, %ebp
pxor %xmm0, %xmm0
movdqu %xmm0, 0x40(%r15)
movdqu %xmm0, 0x30(%r15)
movdqu %xmm0, 0x20(%r15)
movdqu %xmm0, 0x10(%r15)
movdqu %xmm0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0x48286
addq $-0x80, %rbp
subq $-0x80, %r15
cmpq %rbp, 0x50(%rsp)
jne 0x45f2b
movq 0x18(%rsp), %rcx
addq $0x8, %rcx
movq 0x90(%rbx), %rax
movq %rcx, (%rax,%r12,8)
testl %r14d, %r14d
je 0x4611d
xorl %ebp, %ebp
movq 0x90(%rbx), %r14
movq (%r14,%r12,8), %rax
movq %rbp, %r15
shlq $0x7, %r15
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax,%r15)
movq 0x48(%rsp), %rdi
callq 0x7030
movq %rbp, 0x18(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, (%rax)
cmpl $0x0, 0x14(%rsp)
je 0x45fed
leaq 0x30(%rax), %rcx
movq 0x40(%rsp), %rdx
leaq -0x20(%rcx), %rsi
movq %rsi, -0x18(%rcx)
movq %rsi, -0x20(%rcx)
movq %r13, -0x10(%rcx)
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
movq %r13, 0x10(%rcx)
addq $0x68, %rcx
addq $-0x68, %rdx
jne 0x45fc8
addq $0x8, %rax
movq (%r14,%r12,8), %rcx
movq %rax, 0x8(%rcx,%r15)
movq (%r14,%r12,8), %rax
movl $0x0, (%rax,%r15)
movb $0x0, 0x20(%rax,%r15)
movq $0x0, 0x78(%rax,%r15)
cmpl $0x0, 0x14(%rsp)
je 0x46104
xorl %r14d, %r14d
movq 0x90(%rbx), %rax
movq (%rax,%r12,8), %rcx
movq 0x8(%rcx,%r15), %rcx
imulq $0x68, %r14, %rbp
movq $0x0, (%rcx,%rbp)
movq (%rax,%r12,8), %rax
movq 0x8(%rax,%r15), %rax
leaq (%rax,%rbp), %rbx
addq $0x8, %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x46068
movq (%rdi), %r13
callq 0x7370
movq %r13, %rdi
cmpq %rbx, %r13
jne 0x46058
movq %rbx, 0x8(%rbx)
movq %rbx, (%rbx)
xorl %edx, %edx
movq %rdx, 0x10(%rbx)
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rax
movq (%rax,%r12,8), %rcx
movq 0x8(%rcx,%r15), %rcx
movq %rdx, 0x20(%rcx,%rbp)
movq (%rax,%r12,8), %rax
movq 0x8(%rax,%r15), %rax
leaq (%rax,%rbp), %rbx
addq $0x28, %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x460b8
movq (%rdi), %r13
callq 0x7370
movq %r13, %rdi
cmpq %rbx, %r13
jne 0x460a8
movq %rbx, 0x8(%rbx)
movq %rbx, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x8(%rsp), %rbx
movq 0x90(%rbx), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rax,%r15), %rax
movw $0x1, 0x48(%rax,%rbp)
incq %r14
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x50(%rax,%rbp)
movq $-0x1, 0x60(%rax,%rbp)
cmpq 0x30(%rsp), %r14
jne 0x46023
movq 0x18(%rsp), %rbp
incq %rbp
cmpq 0x28(%rsp), %rbp
movl $0x0, %r13d
jne 0x45f84
incq %r12
movl 0x2c(%rbx), %eax
cmpq %rax, %r12
movl 0x24(%rsp), %r14d
jb 0x45f01
movq %rbx, 0x29540(%rip)     # 0x6f678
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x46230
callq 0x7370
jmp 0x46230
movq %rax, %r14
jmp 0x46223
jmp 0x461f0
movq %rax, %r14
testq %r13, %r13
je 0x4621b
negq %r13
movq %r15, %rbx
addq $-0x100, %rbx
leaq (%rbx,%r13), %rdi
callq 0x475fc
addq $-0x108, %r13           # imm = 0xFEF8
jne 0x4618a
jmp 0x4621b
movq %rax, %r14
testq %r13, %r13
je 0x4621b
negq %r13
movq %r15, %rbx
addq $-0x100, %rbx
leaq (%rbx,%r13), %rdi
callq 0x475fc
addq $-0x108, %r13           # imm = 0xFEF8
jne 0x461b3
jmp 0x4621b
movq %rax, %r14
testq %r13, %r13
je 0x4621b
negq %r13
movq %r15, %rbx
addq $-0x100, %rbx
leaq (%rbx,%r13), %rdi
callq 0x475fc
addq $-0x108, %r13           # imm = 0xFEF8
jne 0x461dc
jmp 0x4621b
movq %rax, %r14
jmp 0x46228
movq %rax, %r14
testq %rbp, %rbp
movq 0x18(%rsp), %r15
je 0x4621b
negq %rbp
movq %r15, %rbx
addq $-0x50, %rbx
leaq (%rbx,%rbp), %rdi
callq 0x483ee
addq $-0x80, %rbp
jne 0x4620c
movq %r15, %rdi
callq 0x7480
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x47676
movq %r14, %rdi
callq 0x7620