// File: /workspace/github_cpp_makefile_star2_O1/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, %rbp
movq %rdi, %rbx
movzwl 0xf0(%rsp), %eax
movl %eax, 0x60(%rsp)
movzwl 0xf8(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq %rcx, %xmm4
movq 0x35a90(%rip), %xmm1    # 0x578c0
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
movapd 0x35a94(%rip), %xmm2    # 0x578d0
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 0x190(%rsp), %rcx
movq %rax, %rdx
subsd 0x331bf(%rip), %xmm1    # 0x55050
sarq $0x3f, %rdx
cvttsd2si %xmm1, %r13
andq %rdx, %r13
orq %rax, %r13
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
movq 0x188(%rsp), %r12
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0xb036
movq %r14, 0x50(%rsp)
movq %r12, 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 %rbp, 0x60(%rsp)
movq %rbp, %rsi
movl 0x70(%rsp), %edx
movq %r15, %rcx
movq %r13, %r8
movl 0x74(%rsp), %r9d
movsd 0x90(%rsp), %xmm0
callq 0x1e350
movl 0x150(%rsp), %r15d
movl 0x148(%rsp), %r13d
movb 0x140(%rsp), %r14b
movl 0x138(%rsp), %ebp
movq 0x130(%rsp), %r12
movl 0x120(%rsp), %r9d
movl 0x118(%rsp), %r10d
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x21fb7
callq 0x7370
movl 0x118(%rsp), %r10d
movl 0x120(%rsp), %r9d
leaq 0x4bcba(%rip), %rax     # 0x6dc78
movq %rax, (%rbx)
leaq 0x4bd08(%rip), %rax     # 0x6dcd0
movq %rax, 0x30(%rbx)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x470(%rbx)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x478(%rbx)
movl 0x108(%rsp), %eax
movl %eax, 0x48c(%rbx)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x490(%rbx)
movl 0x110(%rsp), %eax
movl %eax, 0x4d8(%rbx)
movl %r10d, 0x4dc(%rbx)
movl %r9d, 0x4e0(%rbx)
movl 0x128(%rsp), %eax
movl %eax, 0x4f4(%rbx)
movq %r12, 0x508(%rbx)
movl %ebp, 0x510(%rbx)
movb %r14b, 0x514(%rbx)
movl %r13d, 0x518(%rbx)
movl %r15d, 0x51c(%rbx)
movl %r15d, 0x488(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r12
movq %rax, %rdi
movl %r15d, %esi
callq 0x53b58
leal 0x1(%r15), %ebp
movq %r12, 0x480(%rbx)
movl %ebp, 0x4a0(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x53b58
movq %r12, 0x498(%rbx)
movq 0x68(%rbx), %rax
cmpq 0x70(%rbx), %rax
ja 0x221f3
leal 0x2(%r15), %ebp
cmpl $0x3, 0x108(%rsp)
jne 0x2216f
movl %ebp, 0x4c0(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x53b58
leal 0x3(%r15), %ebp
movq %r12, 0x4b8(%rbx)
movl %ebp, 0x4b0(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x53b58
movq %r12, 0x4a8(%rbx)
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %xmm0
punpckldq 0x3579b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x357a3(%rip), %xmm0    # 0x578d0
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 0x32efd(%rip), %xmm1    # 0x55050
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 0x2219f
movl %ebp, 0x4f0(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r15
movq %rax, %rdi
movl %ebp, %esi
callq 0x53b58
incl %ebp
movq %r15, 0x4e8(%rbx)
cmpl $0x0, 0x128(%rsp)
jne 0x221cd
movl %ebp, 0x500(%rbx)
movl $0x18, %edi
callq 0x73a0
movq %rax, %r15
movq %rax, %rdi
movl %ebp, %esi
callq 0x53b58
movq %r15, 0x4f8(%rbx)
movsd 0x478(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x221e1
jnp 0x22225
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x71d0
movq %rax, %r15
leaq 0x35a11(%rip), %rsi     # 0x57c18
movq %rax, %rdi
callq 0x7500
movq 0x4cdaa(%rip), %rsi     # 0x6efc0
movq 0x4cd6b(%rip), %rdx     # 0x6ef88
movq %r15, %rdi
callq 0x75e0
movq 0x4cdc4(%rip), %rdi     # 0x6eff0
leaq 0x34375(%rip), %rsi     # 0x565a8
movl $0x6, %edx
callq 0x7400
movq 0x4cdac(%rip), %rdi     # 0x6eff0
leaq 0x35a25(%rip), %rsi     # 0x57c70
movl $0x32, %edx
callq 0x7400
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x4cd88(%rip), %rdi     # 0x6eff0
callq 0x7400
movq %rax, %rdi
callq 0x71c0
movq 0x4cd54(%rip), %rdi     # 0x6efd0
callq 0x7430
movl $0x1, %edi
callq 0x7440
jmp 0x2228d
movq %rax, %r14
movq %r15, %rdi
jmp 0x222ae
jmp 0x222a8
jmp 0x222a8
movq %rax, %r14
movq %r15, %rdi
callq 0x72c0
jmp 0x222d7
jmp 0x222a8
movq %rax, %r14
movq %r12, %rdi
callq 0x7370
jmp 0x222d7
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x222df
callq 0x7370
jmp 0x222df
movq %rax, %r14
movq %rbx, %rdi
callq 0x1e798
movq %r14, %rdi
callq 0x7620
nop