// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/IO_Flow_Base.cpp
// Function: Host_Components::IO_Flow_Base::SATA_consume_io_request(Host_Components::Host_IO_Request*)
void IO_Flow_Base::SATA_consume_io_request(Host_IO_Request* request)
	{
		sim_time_type device_response_time = Simulator->Time() - request->Enqueue_time;
		sim_time_type request_delay = Simulator->Time() - request->Arrival_time;
		
		STAT_serviced_request_count++;
		STAT_serviced_request_count_short_term++;
		STAT_sum_device_response_time += device_response_time;
		STAT_sum_device_response_time_short_term += device_response_time;
		STAT_sum_request_delay += request_delay;
		STAT_sum_request_delay_short_term += request_delay;
		if (device_response_time > STAT_max_device_response_time) {
			STAT_max_device_response_time = device_response_time;
		}
		if (device_response_time < STAT_min_device_response_time) {
			STAT_min_device_response_time = device_response_time;
		}
		if (request_delay > STAT_max_request_delay) {
			STAT_max_request_delay = request_delay;
		}
		if (request_delay < STAT_min_request_delay) {
			STAT_min_request_delay = request_delay;
		}
		STAT_transferred_bytes_total += request->LBA_count * SECTOR_SIZE_IN_BYTE;

		if (request->Type == Host_IO_Request_Type::READ) {
			STAT_serviced_read_request_count++;
			STAT_sum_device_response_time_read += device_response_time;
			STAT_sum_request_delay_read += request_delay;
			if (device_response_time > STAT_max_device_response_time_read) {
				STAT_max_device_response_time_read = device_response_time;
			}
			if (device_response_time < STAT_min_device_response_time_read) {
				STAT_min_device_response_time_read = device_response_time;
			}
			if (request_delay > STAT_max_request_delay_read) {
				STAT_max_request_delay_read = request_delay;
			}
			if (request_delay < STAT_min_request_delay_read) {
				STAT_min_request_delay_read = request_delay;
			}
			STAT_transferred_bytes_read += request->LBA_count * SECTOR_SIZE_IN_BYTE;
		} else {
			STAT_serviced_write_request_count++;
			STAT_sum_device_response_time_write += device_response_time;
			STAT_sum_request_delay_write += request_delay;
			if (device_response_time > STAT_max_device_response_time_write) {
				STAT_max_device_response_time_write = device_response_time;
			}
			if (device_response_time < STAT_min_device_response_time_write) {
				STAT_min_device_response_time_write = device_response_time;
			}
			if (request_delay > STAT_max_request_delay_write) {
				STAT_max_request_delay_write = request_delay;
			}
			if (request_delay < STAT_min_request_delay_write) {
				STAT_min_request_delay_write = request_delay;
			}
			STAT_transferred_bytes_write += request->LBA_count * SECTOR_SIZE_IN_BYTE;
		}

		delete request;

		//Announce simulation progress
		if (stop_time > 0) {
			progress = int(Simulator->Time() / (double)stop_time * 100);
		} else {
			progress = int(STAT_serviced_request_count / (double)total_requests_to_be_generated * 100);
		}
		if (progress >= next_progress_step) {
			std::string progress_bar;
			int barWidth = 100;
			progress_bar += "[";
			int pos = progress;
			for (int i = 0; i < barWidth; i += 5) {
				if (i < pos) {
					progress_bar += "=";
				} else if (i == pos) {
					progress_bar += ">";
				} else {
					progress_bar += " ";
				}
			}
			progress_bar += "] ";
			PRINT_MESSAGE(progress_bar << " " << progress << "% progress in " << ID() << std::endl)
				next_progress_step += 5;
		}

		if (Simulator->Time() > next_logging_milestone) {
			log_file << Simulator->Time() / SIM_TIME_TO_MICROSECONDS_COEFF << "\t" << Get_device_response_time_short_term() << "\t" << Get_end_to_end_request_delay_short_term() << std::endl;
			STAT_sum_device_response_time_short_term = 0;
			STAT_sum_request_delay_short_term = 0;
			STAT_serviced_request_count_short_term = 0;
			next_logging_milestone = Simulator->Time() + logging_period;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %r15
subq 0x8(%r14), %r15
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
subq (%r14), %rax
incl 0x160(%rbx)
incl 0x468(%rbx)
addq %r15, 0x170(%rbx)
addq %r15, 0x458(%rbx)
addq %rax, 0x1b8(%rbx)
addq %rax, 0x460(%rbx)
cmpq 0x1a0(%rbx), %r15
jbe 0x1eabe
movq %r15, 0x1a0(%rbx)
cmpq 0x188(%rbx), %r15
jae 0x1eace
movq %r15, 0x188(%rbx)
cmpq 0x1e8(%rbx), %rax
jbe 0x1eade
movq %rax, 0x1e8(%rbx)
cmpq 0x1d0(%rbx), %rax
jae 0x1eaee
movq %rax, 0x1d0(%rbx)
movl 0x18(%r14), %ecx
shll $0x9, %ecx
addq %rcx, 0x200(%rbx)
cmpl $0x0, 0x1c(%r14)
je 0x1eb5e
incl 0x168(%rbx)
addq %r15, 0x180(%rbx)
addq %rax, 0x1c8(%rbx)
cmpq 0x1b0(%rbx), %r15
jbe 0x1eb27
movq %r15, 0x1b0(%rbx)
cmpq 0x198(%rbx), %r15
jae 0x1eb37
movq %r15, 0x198(%rbx)
cmpq 0x1f8(%rbx), %rax
jbe 0x1eb47
movq %rax, 0x1f8(%rbx)
movl $0x210, %edx            # imm = 0x210
cmpq 0x1e0(%rbx), %rax
jae 0x1ebba
leaq 0x1e0(%rbx), %rsi
jmp 0x1ebb7
incl 0x164(%rbx)
addq %r15, 0x178(%rbx)
addq %rax, 0x1c0(%rbx)
cmpq 0x1a8(%rbx), %r15
jbe 0x1eb82
movq %r15, 0x1a8(%rbx)
cmpq 0x190(%rbx), %r15
jae 0x1eb92
movq %r15, 0x190(%rbx)
cmpq 0x1f0(%rbx), %rax
jbe 0x1eba2
movq %rax, 0x1f0(%rbx)
movl $0x208, %edx            # imm = 0x208
cmpq 0x1d8(%rbx), %rax
jae 0x1ebba
leaq 0x1d8(%rbx), %rsi
movq %rax, (%rsi)
addq %rcx, (%rbx,%rdx)
movq %r14, %rdi
callq 0x7370
cmpq $0x0, 0x48(%rbx)
je 0x1ec22
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
movq %rax, %xmm1
movq 0x38cd9(%rip), %xmm2    # 0x578c0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x38cdd(%rip), %xmm3    # 0x578d0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0x48(%rbx), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
jmp 0x1ec39
movl 0x160(%rbx), %eax
cvtsi2sd %rax, %xmm0
movl 0x50(%rbx), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
mulsd 0x3825f(%rip), %xmm0    # 0x56ea0
cvttsd2si %xmm0, %eax
movl %eax, 0x218(%rbx)
cmpl %eax, 0x21c(%rbx)
jg 0x1edd6
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x38d7c(%rip), %rsi     # 0x579ee
movq %rsp, %rdi
callq 0x7690
movq %rbx, 0x20(%rsp)
movl 0x218(%rbx), %ebp
xorl %r13d, %r13d
leaq 0x36965(%rip), %r12     # 0x555f4
leaq 0x39158(%rip), %r15     # 0x57dee
leaq 0x369ae(%rip), %rbx     # 0x5564b
movq %rsp, %r14
cmpl %r13d, %ebp
movq %r15, %rsi
cmoveq %r12, %rsi
cmovgq %rbx, %rsi
movq %r14, %rdi
callq 0x7690
leal 0x5(%r13), %eax
cmpl $0x5f, %r13d
movl %eax, %r13d
jb 0x1eca0
leaq 0x38d26(%rip), %rsi     # 0x579f0
movq %rsp, %rdi
callq 0x7690
movq 0x20(%rsp), %rbx
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x502a9(%rip), %rdi     # 0x6ef90
callq 0x7400
movq %rax, %r14
leaq 0x390f8(%rip), %rsi     # 0x57dee
movl $0x1, %edx
movq %rax, %rdi
callq 0x7400
movl 0x218(%rbx), %esi
movq %r14, %rdi
callq 0x75f0
movq %rax, %r14
leaq 0x38cd8(%rip), %rsi     # 0x579f3
movl $0xe, %edx
movq %rax, %rdi
callq 0x7400
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0xb036
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x7400
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7380
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7380
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7290
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x1edbc
callq 0x7370
addl $0x5, 0x21c(%rbx)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1edd6
callq 0x7370
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
cmpq 0x230(%rbx), %rax
jbe 0x1ef0f
leaq 0x458(%rbx), %r15
leaq 0x258(%rbx), %r14
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %r12 # imm = 0x20C49BA5E353F7CF
mulq %r12
shrq $0x4, %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x7280
movq %rax, %r14
leaq 0x38ba5(%rip), %rsi     # 0x579da
movl $0x1, %edx
movq %rax, %rdi
callq 0x7400
movl 0x468(%rbx), %ecx
testq %rcx, %rcx
je 0x1ee64
movq (%r15), %rax
xorl %edx, %edx
divq %rcx
shrq $0x3, %rax
mulq %r12
shrq $0x4, %rdx
movl %edx, %esi
jmp 0x1ee66
xorl %esi, %esi
movq %r14, %rdi
callq 0x7280
movq %rax, %r14
leaq 0x38b62(%rip), %rsi     # 0x579da
movl $0x1, %edx
movq %rax, %rdi
callq 0x7400
cmpl $0x0, 0x160(%rbx)
je 0x1eeaf
movq 0x460(%rbx), %rax
movl 0x468(%rbx), %ecx
xorl %edx, %edx
divq %rcx
shrq $0x3, %rax
mulq %r12
shrq $0x4, %rdx
movl %edx, %esi
jmp 0x1eeb1
xorl %esi, %esi
movq %r14, %rdi
callq 0x7280
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7380
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7290
xorpd %xmm0, %xmm0
movupd %xmm0, (%r15)
movl $0x0, 0x10(%r15)
callq 0x281b4
movq %rax, %rdi
callq 0x285a6
addq 0x228(%rbx), %rax
movq %rax, 0x230(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ef38
jmp 0x1ef38
jmp 0x1ef38
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x1ef3b
callq 0x7370
jmp 0x1ef3b
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1ef4e
callq 0x7370
movq %rbx, %rdi
callq 0x7620