// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebp
movq %r8, %r14
movq %rdi, %rbx
movl 0xc0(%rsp), %edi
movl 0xb8(%rsp), %r15d
movl 0xd0(%rsp), %r12d
movl 0xc8(%rsp), %r13d
movl 0x80(%rsp), %r8d
movl 0x88(%rsp), %r9d
movl 0x90(%rsp), %eax
movups 0x98(%rsp), %xmm0
movups 0xa8(%rsp), %xmm1
movl %edi, 0x30(%rsp)
movl %r15d, 0x28(%rsp)
movups %xmm1, 0x18(%rsp)
movups %xmm0, 0x8(%rsp)
movl %eax, (%rsp)
movq %rbx, %rdi
callq 0x31ffc
leaq 0x3bca6(%rip), %rax     # 0x6e250
movq %rax, (%rbx)
movq %r14, 0xa8(%rbx)
movl %ebp, 0xb0(%rbx)
movl %r13d, 0xb8(%rbx)
movb $0x0, 0xc8(%rbx)
movl $0x0, 0xe4(%rbx)
movl %r12d, 0xe8(%rbx)
movq $0x3b9aca00, 0x100(%rbx) # imm = 0x3B9ACA00
movq $0x0, 0x108(%rbx)
shll $0x9, %r13d
movl %ebp, %eax
xorl %edx, %edx
divl %r13d
movl %eax, 0xb4(%rbx)
testl %r15d, %r15d
je 0x32767
movl 0xc0(%rsp), %r12d
movl %r12d, %r13d
cmpl $0x1, %r15d
jne 0x32849
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
testl %r12d, %r12d
je 0x3266f
xorl %r15d, %r15d
movl $0x58, %edi
callq 0x73a0
movq %rax, %r14
movl 0xb4(%rbx), %eax
xorl %edx, %edx
divl %r12d
movq %r14, %rdi
movl %eax, %esi
callq 0x314e8
movq 0xc0(%rbx), %rax
movq %r14, (%rax,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x3263a
movq %r13, %r14
shlq $0x4, %r14
leaq (%r14,%r14,4), %rdi
addq $0x8, %rdi
callq 0x7030
leaq 0x8(%rax), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq %r13, (%rax)
testl %r12d, %r12d
je 0x326d9
leaq (%r14,%r14,4), %r14
negq %r14
xorl %ebp, %ebp
movq 0x40(%rsp), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0x345a2
addq $-0x50, %rbp
addq $0x50, %r15
cmpq %rbp, %r14
jne 0x326a7
movq 0x40(%rsp), %rax
movq %rax, 0xd0(%rbx)
leaq (,%r13,2), %r14
addq %r13, %r14
leaq 0x8(,%r14,8), %rdi
callq 0x7030
movq %rax, %rcx
addq $0x8, %rax
movq %r13, (%rcx)
testl %r12d, %r12d
je 0x3272b
leaq (%rax,%r14,8), %rcx
movq %rax, %rdx
movq %rdx, 0x8(%rdx)
movq %rdx, (%rdx)
movq $0x0, 0x10(%rdx)
addq $0x18, %rdx
cmpq %rcx, %rdx
jne 0x32713
movq %rax, 0xd8(%rbx)
leaq (,%r13,4), %r14
movq %r14, %rdi
callq 0x7030
movq %rax, 0xf0(%rbx)
testl %r12d, %r12d
je 0x3275b
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7230
movb $0x0, 0xe0(%rbx)
jmp 0x32849
movl %eax, %ebp
movl $0x58, %edi
callq 0x73a0
movl 0xc0(%rsp), %r12d
movq %rax, %r14
movq %rax, %rdi
movl %ebp, %esi
callq 0x314e8
movl %r12d, %r13d
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
testl %r12d, %r12d
je 0x327b9
xorl %eax, %eax
movq 0xc0(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x327a6
movl $0x58, %edi
callq 0x7030
movq %rax, %r14
movq $0x1, (%rax)
movq %rax, %r15
addq $0x8, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movq %r15, %rdi
xorl %esi, %esi
callq 0x345a2
movq %r15, 0xd0(%rbx)
movl $0x20, %edi
callq 0x7030
movq $0x1, (%rax)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
movq %rcx, 0x8(%rax)
movq $0x0, 0x18(%rax)
movq %rcx, 0xd8(%rbx)
movl $0x4, %edi
callq 0x7030
movq %rax, 0xf0(%rbx)
movl $0x0, (%rax)
movb $0x1, 0xe0(%rbx)
movq %r13, %r14
shlq $0x4, %r14
leaq (%r14,%r14,2), %rdi
addq $0x8, %rdi
callq 0x7030
movq %r13, (%rax)
leaq 0x8(%rax), %rcx
testl %r12d, %r12d
je 0x32893
addq $0x10, %rax
leaq (%r14,%r14,2), %rdx
xorl %esi, %esi
movl $0x0, (%rax)
movq %rsi, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rsi, 0x20(%rax)
addq $0x30, %rax
addq $-0x30, %rdx
jne 0x32873
movq %rcx, 0xf8(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %r14, %rdi
jmp 0x328df
jmp 0x328eb
jmp 0x328e6
jmp 0x328e6
movq %rax, %r15
testq %rbp, %rbp
je 0x328da
negq %rbp
movq 0x38(%rsp), %r14
addq $-0x48, %r14
leaq (%r14,%rbp), %rdi
callq 0x34558
addq $-0x50, %rbp
jne 0x328cb
movq 0x38(%rsp), %rdi
callq 0x7480
jmp 0x328f6
movq %rax, %r15
jmp 0x328f6
movq %rax, %r15
movq %r14, %rdi
callq 0x7370
movq %rbx, %rdi
callq 0x32140
movq %r15, %rdi
callq 0x7620