// File: /workspace/github_cpp_makefile_star2_O2/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 0x29400
leaq 0x378df(%rip), %rax     # 0x61230
movq %rax, (%rbx)
movq %r14, 0xa8(%rbx)
movl %ebp, 0xb0(%rbx)
movl %r13d, 0xb8(%rbx)
movb $0x0, 0xc8(%rbx)
andl $0x0, 0xe4(%rbx)
movl 0xd0(%rsp), %eax
movl %eax, 0xe8(%rbx)
movq $0x3b9aca00, 0x100(%rbx) # imm = 0x3B9ACA00
andq $0x0, 0x108(%rbx)
shll $0x9, %r13d
movl %ebp, %eax
xorl %edx, %edx
divl %r13d
movl %eax, 0xb4(%rbx)
movl %r12d, %r13d
testl %r15d, %r15d
je 0x29a0c
cmpl $0x1, %r15d
jne 0x29b76
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
xorl %ebp, %ebp
pushq $0x58
popq %r14
cmpq %rbp, %r13
je 0x29abe
movq %r14, %rdi
callq 0x7370
movq %rax, %r15
movl 0xb4(%rbx), %eax
xorl %edx, %edx
divl %r12d
movq %r15, %rdi
movl %eax, %esi
callq 0x28798
movq 0xc0(%rbx), %rax
movq %r15, (%rax,%rbp,8)
incq %rbp
jmp 0x299d3
movl %eax, %ebp
pushq $0x58
popq %rdi
callq 0x7370
movq %rax, %r15
movq %rax, %rdi
movl %ebp, %esi
callq 0x28798
leaq (,%r13,8), %rdi
callq 0x7030
movq %rax, 0xc0(%rbx)
xorl %eax, %eax
cmpq %rax, %r13
je 0x29a4e
movq 0xc0(%rbx), %rcx
movq %r15, (%rcx,%rax,8)
incq %rax
jmp 0x29a39
pushq $0x58
popq %rdi
callq 0x7030
movq %rax, %r15
movq $0x1, (%rax)
movq %rax, %r14
addq $0x8, %r14
movq %r14, %rdi
callq 0x2aaf0
movq %r14, 0xd0(%rbx)
pushq $0x20
popq %rdi
callq 0x7030
movq $0x1, (%rax)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
movq %rcx, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rcx, 0xd8(%rbx)
pushq $0x4
popq %rdi
callq 0x7030
movq %rax, 0xf0(%rbx)
andl $0x0, (%rax)
movb $0x1, 0xe0(%rbx)
jmp 0x29b76
imulq $0x50, %r13, %rdi
orq $0x8, %rdi
callq 0x7030
movq %r13, (%rax)
movq %rax, 0x38(%rsp)
addq $0x8, %rax
movq %rax, 0x40(%rsp)
testl %r12d, %r12d
je 0x29b01
imulq $-0x50, %r13, %r15
xorl %ebp, %ebp
movq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x2aaf0
addq $-0x50, %rbp
addq $0x50, %r14
cmpq %rbp, %r15
jne 0x29aec
movq 0x40(%rsp), %rax
movq %rax, 0xd0(%rbx)
imulq $0x18, %r13, %r14
leaq 0x8(%r14), %rdi
callq 0x7030
movq %rax, %rcx
addq $0x8, %rax
movq %r13, (%rcx)
testl %r12d, %r12d
je 0x29b44
addq %rax, %r14
movq %rax, %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
andq $0x0, 0x10(%rcx)
addq $0x18, %rcx
cmpq %r14, %rcx
jne 0x29b2f
movq %rax, 0xd8(%rbx)
leaq (,%r13,4), %rdi
callq 0x7030
movq %rax, 0xf0(%rbx)
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x29b6f
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0x29b61
movb $0x0, 0xe0(%rbx)
imulq $0x30, %r13, %r14
leaq 0x8(%r14), %rdi
callq 0x7030
movq %r13, (%rax)
leaq 0x8(%rax), %rcx
testl %r12d, %r12d
je 0x29bb2
addq $0x10, %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
addq $0x30, %rax
addq $-0x30, %r14
jne 0x29b93
movq %rcx, 0xf8(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %r15, %rdi
jmp 0x29bfe
jmp 0x29c0a
jmp 0x29c05
jmp 0x29c05
movq %rax, %r14
testq %rbp, %rbp
je 0x29bf9
negq %rbp
movq 0x38(%rsp), %r15
addq $-0x48, %r15
leaq (%r15,%rbp), %rdi
callq 0x2ad54
addq $-0x50, %rbp
jne 0x29bea
movq 0x38(%rsp), %rdi
callq 0x7430
jmp 0x29c15
movq %rax, %r14
jmp 0x29c15
movq %rax, %r14
movq %r15, %rdi
callq 0x7340
movq %rbx, %rdi
callq 0x294fe
movq %r14, %rdi
callq 0x75d0
nop