// File: CMU-SAFARI[P]MQSim/src/ssd/Address_Mapping_Unit_Base.cpp
// Function: SSD_Components::Address_Mapping_Unit_Base::Address_Mapping_Unit_Base(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, SSD_Components::FTL*, SSD_Components::NVM_PHY_ONFI*, SSD_Components::Flash_Block_Manager_Base*, bool, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, double, SSD_Components::CMT_Sharing_Mode, bool)
Address_Mapping_Unit_Base::Address_Mapping_Unit_Base(const sim_object_id_type& id, FTL* ftl, NVM_PHY_ONFI* flash_controller, Flash_Block_Manager_Base* block_manager,
		bool ideal_mapping_table, unsigned int no_of_input_streams,
		unsigned int ChannelCount, unsigned int chip_no_per_channel, unsigned int DieNoPerChip, unsigned int PlaneNoPerDie,
		unsigned int Block_no_per_plane, unsigned int Page_no_per_block, unsigned int SectorsPerPage, unsigned int PageSizeInBytes,
		double Overprovisioning_ratio, CMT_Sharing_Mode sharing_mode, bool fold_large_addresses)
		: Sim_Object(id), ftl(ftl), flash_controller(flash_controller), block_manager(block_manager),
		ideal_mapping_table(ideal_mapping_table), no_of_input_streams(no_of_input_streams),
		channel_count(ChannelCount), chip_no_per_channel(chip_no_per_channel), die_no_per_chip(DieNoPerChip), plane_no_per_die(PlaneNoPerDie),
		block_no_per_plane(Block_no_per_plane), pages_no_per_block(Page_no_per_block), sector_no_per_page(SectorsPerPage), page_size_in_byte(PageSizeInBytes), 
		overprovisioning_ratio(Overprovisioning_ratio), sharing_mode(sharing_mode), fold_large_addresses(fold_large_addresses),
		mapping_table_stored_on_flash(false)
	{
		page_no_per_plane = pages_no_per_block * block_no_per_plane;
		page_no_per_die = page_no_per_plane * plane_no_per_die;
		page_no_per_chip = page_no_per_die * die_no_per_chip;
		page_no_per_channel = page_no_per_chip * chip_no_per_channel;
		total_physical_pages_no = page_no_per_channel * ChannelCount;
		total_logical_pages_no = (unsigned int)((double)total_physical_pages_no * (1 - overprovisioning_ratio));
		max_logical_sector_address = (LHA_type)(SectorsPerPage * total_logical_pages_no - 1);
	}

// Assembly:
subq $0x68, %rsp
movl %r9d, %eax
movq %rcx, 0x8(%rsp)
movq %rdx, %rcx
movq 0x8(%rsp), %rdx
movq %rcx, 0x10(%rsp)
movq %rsi, %rcx
movq 0x10(%rsp), %rsi
movq %rcx, 0x18(%rsp)
movq %rdi, %r9
movq 0x18(%rsp), %rdi
movb %al, %cl
movb 0xc0(%rsp), %al
movl 0xb8(%rsp), %r10d
movl 0xb0(%rsp), %r10d
movl 0xa8(%rsp), %r10d
movl 0xa0(%rsp), %r10d
movl 0x98(%rsp), %r10d
movl 0x90(%rsp), %r10d
movl 0x88(%rsp), %r10d
movl 0x80(%rsp), %r10d
movl 0x78(%rsp), %r10d
movl 0x70(%rsp), %r10d
movq %r9, 0x60(%rsp)
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %r8, 0x40(%rsp)
andb $0x1, %cl
movb %cl, 0x3f(%rsp)
movsd %xmm0, 0x30(%rsp)
andb $0x1, %al
movb %al, 0x2f(%rsp)
movq 0x60(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq 0x58(%rsp), %rsi
callq 0x1fd60
movq 0x20(%rsp), %rax
leaq 0x8f303(%rip), %rcx     # 0xd8e90
movq %rcx, (%rax)
movq 0x50(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x48(%rsp), %rcx
movq %rcx, 0x38(%rax)
movq 0x40(%rsp), %rcx
movq %rcx, 0x40(%rax)
movl 0xb8(%rsp), %ecx
movl %ecx, 0x48(%rax)
movb 0x3f(%rsp), %cl
andb $0x1, %cl
movb %cl, 0x4c(%rax)
movl 0x70(%rsp), %ecx
movl %ecx, 0x50(%rax)
movl $0x0, 0x60(%rax)
movl 0x78(%rsp), %ecx
movl %ecx, 0x64(%rax)
movl 0x80(%rsp), %ecx
movl %ecx, 0x68(%rax)
movl 0x88(%rsp), %ecx
movl %ecx, 0x6c(%rax)
movl 0x90(%rsp), %ecx
movl %ecx, 0x70(%rax)
movl 0x98(%rsp), %ecx
movl %ecx, 0x74(%rax)
movl 0xa0(%rsp), %ecx
movl %ecx, 0x78(%rax)
movl 0xa8(%rsp), %ecx
movl %ecx, 0x7c(%rax)
movl 0xb0(%rsp), %ecx
movl %ecx, 0x80(%rax)
movl $0x0, 0x84(%rax)
movl $0x0, 0x88(%rax)
movl $0x0, 0x8c(%rax)
movl $0x0, 0x90(%rax)
movl $0x0, 0x94(%rax)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x98(%rax)
movb 0x2f(%rsp), %cl
andb $0x1, %cl
movb %cl, 0xa0(%rax)
movb $0x0, 0xa1(%rax)
movl 0x74(%rax), %edx
movl 0x78(%rax), %ecx
imull %edx, %ecx
movl %ecx, 0x94(%rax)
movl 0x70(%rax), %edx
movl 0x94(%rax), %ecx
imull %edx, %ecx
movl %ecx, 0x90(%rax)
movl 0x6c(%rax), %edx
movl 0x90(%rax), %ecx
imull %edx, %ecx
movl %ecx, 0x8c(%rax)
movl 0x8c(%rax), %ecx
movl 0x80(%rsp), %edx
imull %edx, %ecx
movl %ecx, 0x88(%rax)
movl 0x88(%rax), %ecx
movl 0x78(%rsp), %edx
imull %edx, %ecx
movl %ecx, 0x84(%rax)
movl 0x84(%rax), %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x98(%rax), %xmm2
movsd 0x61fd8(%rip), %xmm1    # 0xabcc0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movl %ecx, 0x60(%rax)
movl 0xa8(%rsp), %ecx
imull 0x60(%rax), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq %rcx, 0x58(%rax)
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)