// File: CMU-SAFARI[P]MQSim/src/ssd/Data_Cache_Manager_Flash_Advanced.cpp
// Function: SSD_Components::Data_Cache_Manager_Flash_Advanced::Data_Cache_Manager_Flash_Advanced(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, SSD_Components::Host_Interface_Base*, SSD_Components::NVM_Firmware*, SSD_Components::NVM_PHY_ONFI*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long, unsigned long, SSD_Components::Caching_Mode*, SSD_Components::Cache_Sharing_Mode, unsigned int, unsigned int, unsigned int)
Data_Cache_Manager_Flash_Advanced::Data_Cache_Manager_Flash_Advanced(const sim_object_id_type& id, Host_Interface_Base* host_interface, NVM_Firmware* firmware, NVM_PHY_ONFI* flash_controller,
		unsigned int total_capacity_in_bytes,
		unsigned int dram_row_size, unsigned int dram_data_rate, unsigned int dram_busrt_size, sim_time_type dram_tRCD, sim_time_type dram_tCL, sim_time_type dram_tRP,
		Caching_Mode* caching_mode_per_input_stream, Cache_Sharing_Mode sharing_mode,unsigned int stream_count,
		unsigned int sector_no_per_page, unsigned int back_pressure_buffer_max_depth)
		: Data_Cache_Manager_Base(id, host_interface, firmware, dram_row_size, dram_data_rate, dram_busrt_size, dram_tRCD, dram_tCL, dram_tRP, caching_mode_per_input_stream, sharing_mode, stream_count),
		flash_controller(flash_controller), capacity_in_bytes(total_capacity_in_bytes), sector_no_per_page(sector_no_per_page),	memory_channel_is_busy(false),
		dram_execution_list_turn(0), back_pressure_buffer_max_depth(back_pressure_buffer_max_depth)
	{
		capacity_in_pages = capacity_in_bytes / (SECTOR_SIZE_IN_BYTE * sector_no_per_page);
		switch (sharing_mode)
		{
			case SSD_Components::Cache_Sharing_Mode::SHARED:
			{
				Data_Cache_Flash* sharedCache = new Data_Cache_Flash(capacity_in_pages);
				per_stream_cache = new Data_Cache_Flash*[stream_count];
				for (unsigned int i = 0; i < stream_count; i++) {
					per_stream_cache[i] = sharedCache;
				}
				dram_execution_queue = new std::queue<Memory_Transfer_Info*>[1];
				waiting_user_requests_queue_for_dram_free_slot = new std::list<User_Request*>[1];
				this->back_pressure_buffer_depth = new unsigned int[1];
				this->back_pressure_buffer_depth[0] = 0;
				shared_dram_request_queue = true;
				break; 
			}
			case SSD_Components::Cache_Sharing_Mode::EQUAL_PARTITIONING:
				per_stream_cache = new Data_Cache_Flash*[stream_count];
				for (unsigned int i = 0; i < stream_count; i++) {
					per_stream_cache[i] = new Data_Cache_Flash(capacity_in_pages / stream_count);
				}
				dram_execution_queue = new std::queue<Memory_Transfer_Info*>[stream_count];
				waiting_user_requests_queue_for_dram_free_slot = new std::list<User_Request*>[stream_count];
				this->back_pressure_buffer_depth = new unsigned int[stream_count];
				for (unsigned int i = 0; i < stream_count; i++) {
					this->back_pressure_buffer_depth[i] = 0;
				}
				shared_dram_request_queue = false;
				break;
			default:
				break;
		}

		bloom_filter = new std::set<LPA_type>[stream_count];
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movl 0x250(%rsp), %eax
movl 0x248(%rsp), %eax
movl 0x240(%rsp), %eax
movl 0x238(%rsp), %eax
movq 0x230(%rsp), %rax
movq 0x228(%rsp), %rax
movq 0x220(%rsp), %rax
movq 0x218(%rsp), %rax
movl 0x210(%rsp), %eax
movl 0x208(%rsp), %eax
movl 0x200(%rsp), %eax
movq %rdi, 0x1c8(%rsp)
movq %rsi, 0x1c0(%rsp)
movq %rdx, 0x1b8(%rsp)
movq %rcx, 0x1b0(%rsp)
movq %r8, 0x1a8(%rsp)
movl %r9d, 0x1a4(%rsp)
movq 0x1c8(%rsp), %rdi
movq %rdi, 0x170(%rsp)
movq 0x1c0(%rsp), %rsi
movq 0x1b8(%rsp), %rdx
movq 0x1b0(%rsp), %rcx
movl 0x200(%rsp), %r8d
movl 0x208(%rsp), %r9d
movl 0x210(%rsp), %r10d
movq 0x218(%rsp), %r11
movq 0x220(%rsp), %rbx
movq 0x228(%rsp), %r14
movq 0x230(%rsp), %r15
movl 0x238(%rsp), %ebp
movl 0x240(%rsp), %r12d
movq %rsp, %rax
movl %r12d, 0x30(%rax)
movl %ebp, 0x28(%rax)
movq %r15, 0x20(%rax)
movq %r14, 0x18(%rax)
movq %rbx, 0x10(%rax)
movq %r11, 0x8(%rax)
movl %r10d, (%rax)
callq 0x67920
movq 0x170(%rsp), %rax
leaq 0x6fed8(%rip), %rcx     # 0xd9258
movq %rcx, (%rax)
movq 0x1a8(%rsp), %rcx
movq %rcx, 0xa8(%rax)
movl 0x1a4(%rsp), %ecx
movl %ecx, 0xb0(%rax)
movl 0x248(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movb $0x0, 0xc8(%rax)
movl $0x0, 0xe4(%rax)
movl 0x250(%rsp), %ecx
movl %ecx, 0xe8(%rax)
movq $0x3b9aca00, 0x100(%rax) # imm = 0x3B9ACA00
movq $0x0, 0x108(%rax)
movl 0xb0(%rax), %eax
movl 0x248(%rsp), %ecx
shll $0x9, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
movq 0x170(%rsp), %rax
movl %ecx, 0xb4(%rax)
movl 0x238(%rsp), %eax
movl %eax, 0x17c(%rsp)
testl %eax, %eax
je 0x6942d
jmp 0x69418
movl 0x17c(%rsp), %eax
subl $0x1, %eax
je 0x69713
jmp 0x69a87
movl $0x58, %edi
callq 0x8450
movq %rax, 0x168(%rsp)
jmp 0x69441
movq 0x168(%rsp), %rdi
movq 0x170(%rsp), %rax
movl 0xb4(%rax), %esi
callq 0x64350
jmp 0x6945e
movq 0x168(%rsp), %rax
movq %rax, 0x198(%rsp)
movl 0x240(%rsp), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x8030
movq %rax, 0x160(%rsp)
jmp 0x6948a
movq 0x170(%rsp), %rax
movq 0x160(%rsp), %rcx
movq %rcx, 0xc0(%rax)
movl $0x0, 0x188(%rsp)
movl 0x188(%rsp), %eax
cmpl 0x240(%rsp), %eax
jae 0x69530
movq 0x170(%rsp), %rax
movq 0x198(%rsp), %rdx
movq 0xc0(%rax), %rax
movl 0x188(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl 0x188(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x188(%rsp)
jmp 0x694ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
jmp 0x69b2f
movq 0x168(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
callq 0x8410
jmp 0x69b2f
movl $0x58, %edi
callq 0x8030
movq %rax, 0x158(%rsp)
jmp 0x69544
movq 0x158(%rsp), %rax
movq $0x1, (%rax)
addq $0x8, %rax
movq %rax, 0x140(%rsp)
movq %rax, %rcx
addq $0x50, %rcx
movq %rcx, 0x148(%rsp)
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rdi
movq %rdi, 0x138(%rsp)
callq 0x6bf50
jmp 0x6958d
movq 0x148(%rsp), %rcx
movq 0x138(%rsp), %rax
addq $0x50, %rax
cmpq %rcx, %rax
movq %rax, 0x150(%rsp)
jne 0x69576
movq 0x170(%rsp), %rax
movq 0x140(%rsp), %rcx
movq %rcx, 0xd0(%rax)
movl $0x20, %edi
callq 0x8030
movq %rax, 0x130(%rsp)
jmp 0x695d9
movq 0x130(%rsp), %rax
movq $0x1, (%rax)
addq $0x8, %rax
movq %rax, 0x118(%rsp)
movq %rax, %rcx
addq $0x18, %rcx
movq %rcx, 0x120(%rsp)
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rdi
movq %rdi, 0x110(%rsp)
callq 0x6bf90
movq 0x110(%rsp), %rax
movq 0x120(%rsp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, 0x128(%rsp)
jne 0x6960b
movq 0x170(%rsp), %rax
movq 0x118(%rsp), %rcx
movq %rcx, 0xd8(%rax)
movl $0x4, %edi
callq 0x8030
movq %rax, 0x108(%rsp)
jmp 0x6966c
movq 0x170(%rsp), %rax
movq 0x108(%rsp), %rcx
movq %rcx, 0xf0(%rax)
movq 0xf0(%rax), %rcx
movl $0x0, (%rcx)
movb $0x1, 0xe0(%rax)
jmp 0x69a89
movq 0x140(%rsp), %rcx
movq %rax, %rsi
movq 0x138(%rsp), %rax
movq %rsi, 0x190(%rsp)
movl %edx, 0x18c(%rsp)
cmpq %rax, %rcx
movq %rax, 0x100(%rsp)
je 0x69701
movq 0x100(%rsp), %rdi
addq $-0x50, %rdi
movq %rdi, 0xf8(%rsp)
callq 0x6bf80
movq 0x140(%rsp), %rcx
movq 0xf8(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x100(%rsp)
jne 0x696cb
movq 0x158(%rsp), %rdi
callq 0x8570
jmp 0x69b2f
movl 0x240(%rsp), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x8030
movq %rax, 0xf0(%rsp)
jmp 0x6972f
movq 0x170(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq %rcx, 0xc0(%rax)
movl $0x0, 0x184(%rsp)
movl 0x184(%rsp), %eax
cmpl 0x240(%rsp), %eax
jae 0x69801
movl $0x58, %edi
callq 0x8450
movq %rax, 0xe8(%rsp)
jmp 0x69779
movq 0xe8(%rsp), %rdi
movq 0x170(%rsp), %rax
movl 0xb4(%rax), %eax
movl 0x240(%rsp), %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %esi
callq 0x64350
jmp 0x697a3
movq 0xe8(%rsp), %rdx
movq 0x170(%rsp), %rax
movq 0xc0(%rax), %rax
movl 0x184(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x69751
movq 0xe8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
callq 0x8410
jmp 0x69b2f
movl 0x240(%rsp), %eax
movq %rax, 0xd8(%rsp)
shlq $0x4, %rax
leaq 0x8(%rax,%rax,4), %rdi
callq 0x8030
movq %rax, 0xe0(%rsp)
jmp 0x69828
movq 0xd8(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0xd0(%rsp)
cmpq $0x0, %rax
je 0x698af
movq 0xd0(%rsp), %rax
movq 0xd8(%rsp), %rcx
imulq $0x50, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x6bf50
jmp 0x6988e
movq 0xc0(%rsp), %rcx
movq 0xb8(%rsp), %rax
addq $0x50, %rax
cmpq %rcx, %rax
movq %rax, 0xc8(%rsp)
jne 0x69877
movq 0x170(%rsp), %rax
movq 0xd0(%rsp), %rcx
movq %rcx, 0xd0(%rax)
movl 0x240(%rsp), %eax
movq %rax, 0xa8(%rsp)
leaq (%rax,%rax,2), %rax
leaq 0x8(,%rax,8), %rdi
callq 0x8030
movq %rax, 0xb0(%rsp)
jmp 0x698f0
movq 0xa8(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0xa0(%rsp)
cmpq $0x0, %rax
je 0x69975
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
imulq $0x18, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x6bf90
movq 0x88(%rsp), %rax
movq 0x90(%rsp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, 0x98(%rsp)
jne 0x6993f
movq 0x170(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0xd8(%rax)
movl 0x240(%rsp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x8030
movq %rax, 0x80(%rsp)
jmp 0x699a8
movq 0x170(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0xf0(%rax)
movl $0x0, 0x180(%rsp)
movl 0x180(%rsp), %eax
cmpl 0x240(%rsp), %eax
jae 0x69a76
movq 0x170(%rsp), %rax
movq 0xf0(%rax), %rax
movl 0x180(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x180(%rsp)
jmp 0x699ca
movq 0xd0(%rsp), %rcx
movq %rax, %rsi
movq 0xb8(%rsp), %rax
movq %rsi, 0x190(%rsp)
movl %edx, 0x18c(%rsp)
cmpq %rax, %rcx
movq %rax, 0x78(%rsp)
je 0x69a64
movq 0x78(%rsp), %rdi
addq $-0x50, %rdi
movq %rdi, 0x70(%rsp)
callq 0x6bf80
movq 0xd0(%rsp), %rcx
movq 0x70(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x78(%rsp)
jne 0x69a3a
movq 0xe0(%rsp), %rdi
callq 0x8570
jmp 0x69b2f
movq 0x170(%rsp), %rax
movb $0x0, 0xe0(%rax)
jmp 0x69a89
jmp 0x69a89
movl 0x240(%rsp), %eax
movq %rax, 0x60(%rsp)
shlq $0x4, %rax
leaq 0x8(%rax,%rax,2), %rdi
callq 0x8030
movq %rax, 0x68(%rsp)
jmp 0x69aaa
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x58(%rsp)
cmpq $0x0, %rax
je 0x69b0b
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
imulq $0x30, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x21570
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
addq $0x30, %rax
cmpq %rcx, %rax
movq %rax, 0x50(%rsp)
jne 0x69ae4
movq 0x170(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, 0xf8(%rax)
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x170(%rsp), %rdi
callq 0x67ae0
movq 0x190(%rsp), %rdi
callq 0x8770
nopl (%rax)