// File: /workspace/github_cpp_makefile_star2_O1/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), %r12d
movl 0xb8(%rsp), %r15d
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 %r12d, 0x30(%rsp)
movl %r15d, 0x28(%rsp)
movups %xmm1, 0x18(%rsp)
movups %xmm0, 0x8(%rsp)
movl %eax, (%rsp)
callq 0x32a38
leaq 0x3b277(%rip), %rax     # 0x6e258
movq %rax, (%rbx)
movq %r14, 0xa8(%rbx)
movl %ebp, 0xb0(%rbx)
movl %r13d, 0xb8(%rbx)
movb $0x0, 0xc8(%rbx)
movl $0x0, 0xe4(%rbx)
movl 0xd0(%rsp), %eax
movl %eax, 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)
movl %r12d, %r13d
cmpl $0x1, %r15d
je 0x3312b
testl %r15d, %r15d
jne 0x33271
movl %eax, %ebp
movl $0x58, %edi
callq 0x73a0
movq %rax, %r14
movq %rax, %rdi
movl %ebp, %esi
callq 0x31d04
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
testl %r12d, %r12d
je 0x3309a
xorl %eax, %eax
movq 0xc0(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x33087
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 0x35000
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, %bpl
jmp 0x3326a
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
testl %r12d, %r12d
je 0x3317c
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 0x31d04
movq 0xc0(%rbx), %rax
movq %r14, (%rax,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x33147
movq %r13, %r14
shlq $0x4, %r14
leaq (%r14,%r14,4), %rdi
addq $0x8, %rdi
callq 0x7030
movq %r13, (%rax)
movq %rax, 0x38(%rsp)
addq $0x8, %rax
movq %rax, 0x40(%rsp)
testl %r12d, %r12d
je 0x331e6
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 0x35000
addq $-0x50, %rbp
addq $0x50, %r15
cmpq %rbp, %r14
jne 0x331b4
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 0x33238
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 0x33220
movq %rax, 0xd8(%rbx)
leaq (,%r13,4), %r14
movq %r14, %rdi
callq 0x7030
movq %rax, 0xf0(%rbx)
xorl %ebp, %ebp
testl %r12d, %r12d
je 0x3326a
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x7230
movb %bpl, 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 0x332bb
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 0x3329b
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 0x33307
jmp 0x33313
jmp 0x3330e
jmp 0x3330e
movq %rax, %r15
testq %rbp, %rbp
je 0x33302
negq %rbp
movq 0x38(%rsp), %r14
addq $-0x48, %r14
leaq (%r14,%rbp), %rdi
callq 0x34fbc
addq $-0x50, %rbp
jne 0x332f3
movq 0x38(%rsp), %rdi
callq 0x7480
jmp 0x3331e
movq %rax, %r15
jmp 0x3331e
movq %rax, %r15
movq %r14, %rdi
callq 0x7370
movq %rbx, %rdi
callq 0x32b82
movq %r15, %rdi
callq 0x7620