// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]MQSim/src/host/IO_Flow_Synthetic.cpp
// Function: Host_Components::IO_Flow_Synthetic::IO_Flow_Synthetic(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned short, unsigned long, unsigned long, double, unsigned short, unsigned short, unsigned short, IO_Flow_Priority_Class::Priority, double, Utils::Address_Distribution_Type, double, Utils::Request_Size_Distribution_Type, unsigned int, unsigned int, Utils::Request_Generator_Type, unsigned long, unsigned int, bool, unsigned int, int, unsigned long, double, unsigned int, HostInterface_Types, Host_Components::PCIe_Root_Complex*, Host_Components::SATA_HBA*, bool, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
IO_Flow_Synthetic::IO_Flow_Synthetic(const sim_object_id_type &name, uint16_t flow_id,
									 LHA_type start_lsa_on_device, LHA_type end_lsa_on_device, double working_set_ratio, uint16_t io_queue_id,
									 uint16_t nvme_submission_queue_size, uint16_t nvme_completion_queue_size, IO_Flow_Priority_Class::Priority priority_class,
									 double read_ratio, Utils::Address_Distribution_Type address_distribution, double hot_region_ratio,
									 Utils::Request_Size_Distribution_Type request_size_distribution, unsigned int average_request_size, unsigned int variance_request_size,
									 Utils::Request_Generator_Type generator_type, sim_time_type Average_inter_arrival_time_nano_sec, unsigned int average_number_of_enqueued_requests,
									 bool generate_aligned_addresses, unsigned int alignment_value,
									 int seed, sim_time_type stop_time, double initial_occupancy_ratio, unsigned int total_req_count, HostInterface_Types SSD_device_type, PCIe_Root_Complex *pcie_root_complex, SATA_HBA *sata_hba,
									 bool enabled_logging, sim_time_type logging_period, std::string logging_file_path) : IO_Flow_Base(name, flow_id, start_lsa_on_device, LHA_type(start_lsa_on_device + (end_lsa_on_device - start_lsa_on_device) * working_set_ratio), io_queue_id, nvme_submission_queue_size, nvme_completion_queue_size, priority_class, stop_time, initial_occupancy_ratio, total_req_count, SSD_device_type, pcie_root_complex, sata_hba, enabled_logging, logging_period, logging_file_path),
																														  read_ratio(read_ratio), address_distribution(address_distribution),
																														  working_set_ratio(working_set_ratio), hot_region_ratio(hot_region_ratio),
																														  request_size_distribution(request_size_distribution), average_request_size(average_request_size), variance_request_size(variance_request_size),
																														  generator_type(generator_type), Average_inter_arrival_time_nano_sec(Average_inter_arrival_time_nano_sec), average_number_of_enqueued_requests(average_number_of_enqueued_requests),
																														  seed(seed), generate_aligned_addresses(generate_aligned_addresses), alignment_value(alignment_value)
{
	//If read ratio is 0, then we change its value to a negative one so that in request generation we never generate a read request
	if (read_ratio == 0.0)
	{
		read_ratio = -1.0;
	}
	random_request_type_generator_seed = seed++;
	random_request_type_generator = new Utils::RandomGenerator(random_request_type_generator_seed);
	random_address_generator_seed = seed++;
	random_address_generator = new Utils::RandomGenerator(random_address_generator_seed);
	if (this->start_lsa_on_device > this->end_lsa_on_device)
	{
		throw std::logic_error("Problem in IO Flow Synthetic, the start LBA address is greater than the end LBA address");
	}

	if (address_distribution == Utils::Address_Distribution_Type::RANDOM_HOTCOLD)
	{
		random_hot_address_generator_seed = seed++;
		random_hot_address_generator = new Utils::RandomGenerator(random_hot_address_generator_seed);
		random_hot_cold_generator_seed = seed++;
		random_hot_cold_generator = new Utils::RandomGenerator(random_hot_cold_generator_seed);
		hot_region_end_lsa = this->start_lsa_on_device + (LHA_type)((double)(this->end_lsa_on_device - this->start_lsa_on_device) * hot_region_ratio);
	}

	if (request_size_distribution == Utils::Request_Size_Distribution_Type::NORMAL)
	{
		random_request_size_generator_seed = seed++;
		random_request_size_generator = new Utils::RandomGenerator(random_request_size_generator_seed);
	}

	if (generator_type == Utils::Request_Generator_Type::BANDWIDTH)
	{
		random_time_interval_generator_seed = seed++;
		random_time_interval_generator = new Utils::RandomGenerator(random_time_interval_generator_seed);
	}

	if (this->working_set_ratio == 0)
	{
		PRINT_ERROR("The working set ratio is set to zero for workload " << name)
	}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movsd %xmm3, 0x90(%rsp)
movsd %xmm2, 0x78(%rsp)
movsd %xmm1, 0x88(%rsp)
movl %r9d, 0x74(%rsp)
movq %rcx, %r15
movl %edx, 0x70(%rsp)
movq %rsi, %r12
movq %rdi, %rbx
movzwl 0xf0(%rsp), %eax
movl %eax, 0x60(%rsp)
movzwl 0xf8(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq %rcx, %xmm4
movq 0x2b4bc(%rip), %xmm1    # 0x457d0
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
movapd 0x2b4c0(%rip), %xmm2    # 0x457e0
subpd %xmm2, %xmm4
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
addsd %xmm4, %xmm3
subq %rcx, %r8
movq %r8, %xmm4
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm2, %xmm4
movapd %xmm4, %xmm1
unpckhpd %xmm4, %xmm1            # xmm1 = xmm1[1],xmm4[1]
addsd %xmm4, %xmm1
movsd %xmm0, 0x80(%rsp)
mulsd %xmm0, %xmm1
addsd %xmm3, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x28cdf(%rip), %xmm1    # 0x43050
cvttsd2si %xmm1, %r13
andq %rcx, %r13
movq 0x188(%rsp), %rbp
orq %rax, %r13
movq 0x190(%rsp), %rsi
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x7480
movq %r14, 0x50(%rsp)
movq %rbp, 0x48(%rsp)
movzbl 0x180(%rsp), %eax
movl %eax, 0x40(%rsp)
movaps 0x170(%rsp), %xmm0
movups %xmm0, 0x30(%rsp)
movl 0x168(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x160(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x100(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x60(%rsp), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r12, 0x60(%rsp)
movq %r12, %rsi
movl 0x70(%rsp), %edx
movq %r15, %rcx
movq %r13, %r8
movl 0x74(%rsp), %r9d
movsd 0x90(%rsp), %xmm0
callq 0x174a4
movl 0x150(%rsp), %r15d
movl 0x128(%rsp), %r13d
movl 0x118(%rsp), %r12d
movl 0x110(%rsp), %r14d
movl 0x108(%rsp), %ebp
leaq 0x98(%rsp), %rdi
callq 0x7678
leaq 0x467b9(%rip), %rax     # 0x60c18
movq %rax, (%rbx)
leaq 0x46807(%rip), %rax     # 0x60c70
movq %rax, 0x30(%rbx)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x470(%rbx)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x478(%rbx)
movl %ebp, 0x48c(%rbx)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x490(%rbx)
movl %r14d, 0x4d8(%rbx)
movl %r12d, 0x4dc(%rbx)
movl 0x120(%rsp), %eax
movl %eax, 0x4e0(%rbx)
movl %r13d, 0x4f4(%rbx)
movq 0x130(%rsp), %rax
movq %rax, 0x508(%rbx)
movl 0x138(%rsp), %eax
movl %eax, 0x510(%rbx)
movb 0x140(%rsp), %al
movb %al, 0x514(%rbx)
movl 0x148(%rsp), %eax
movl %eax, 0x518(%rbx)
movl %r15d, 0x51c(%rbx)
movl %r15d, 0x488(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r12
movq %rax, %rdi
movl %r15d, %esi
callq 0x41170
leal 0x1(%r15), %ebp
movq %r12, 0x480(%rbx)
movl %ebp, 0x4a0(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x41170
movq %r12, 0x498(%rbx)
movq 0x68(%rbx), %rax
cmpq 0x70(%rbx), %rax
ja 0x1a697
leal 0x2(%r15), %ebp
cmpl $0x3, 0x108(%rsp)
jne 0x1a616
movl %ebp, 0x4c0(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x41170
leal 0x3(%r15), %ebp
movq %r12, 0x4b8(%rbx)
movl %ebp, 0x4b0(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x41170
movq %r12, 0x4a8(%rbx)
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %xmm0
punpckldq 0x2b204(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2b20c(%rip), %xmm0    # 0x457e0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x78(%rsp), %xmm1
cvttsd2si %xmm1, %rcx
addl $0x4, %r15d
movq %rcx, %rdx
subsd 0x28a56(%rip), %xmm1    # 0x43050
sarq $0x3f, %rdx
cvttsd2si %xmm1, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
addq %rax, %rsi
movq %rsi, 0x4c8(%rbx)
movl %r15d, %ebp
cmpl $0x1, 0x110(%rsp)
jne 0x1a644
movl %ebp, 0x4f0(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r15
movq %rax, %rdi
movl %ebp, %esi
callq 0x41170
incl %ebp
movq %r15, 0x4e8(%rbx)
movl 0x128(%rsp), %eax
testl %eax, %eax
jne 0x1a671
movl %ebp, 0x500(%rbx)
pushq $0x18
popq %rdi
callq 0x7370
movq %rax, %r15
movq %rax, %rdi
movl %ebp, %esi
callq 0x41170
movq %r15, 0x4f8(%rbx)
movsd 0x478(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1a685
jnp 0x1a6c7
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x71b0
movq %rax, %r15
leaq 0x2b47f(%rip), %rsi     # 0x45b28
movq %rax, %rdi
callq 0x74b0
movq 0x47908(%rip), %rsi     # 0x61fc0
movq 0x478b1(%rip), %rdx     # 0x61f70
movq %r15, %rdi
callq 0x7590
movq 0x47922(%rip), %rdi     # 0x61ff0
leaq 0x29eb3(%rip), %rsi     # 0x44588
callq 0x7360
movq 0x4790f(%rip), %rdi     # 0x61ff0
leaq 0x2b498(%rip), %rsi     # 0x45b80
callq 0x7360
movq %rax, %rdi
movq 0x60(%rsp), %rsi
callq 0x7310
movq %rax, %rdi
callq 0x71a0
movq 0x478c7(%rip), %rdi     # 0x61fd0
callq 0x73d0
pushq $0x1
popq %rdi
callq 0x73e0
jmp 0x1a718
movq %rax, %r14
movq %r15, %rdi
jmp 0x1a739
jmp 0x1a733
jmp 0x1a733
movq %rax, %r14
movq %r15, %rdi
callq 0x72a0
jmp 0x1a755
jmp 0x1a733
movq %rax, %r14
movq %r12, %rdi
callq 0x7340
jmp 0x1a755
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x7678
jmp 0x1a75d
movq %rax, %r14
movq %rbx, %rdi
callq 0x1785a
movq %r14, %rdi
callq 0x75d0
nop