// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]MQSim/src/host/IO_Flow_Base.cpp
// Function: Host_Components::IO_Flow_Base::Submit_io_request(Host_Components::Host_IO_Request*)
void IO_Flow_Base::Submit_io_request(Host_IO_Request* request)
	{
		switch (SSD_device_type) {
			case HostInterface_Types::NVME:
				//If either of software or hardware queue is full
				if (NVME_SQ_FULL(nvme_queue_pair) || available_command_ids.size() == 0) {
					waiting_requests.push_back(request);
				} else {
					if (nvme_software_request_queue[*available_command_ids.begin()] != NULL) {
						PRINT_ERROR("Unexpteced situation in IO_Flow_Base! Overwriting an unhandled I/O request in the queue!")
					} else {
						request->IO_queue_info = *available_command_ids.begin();
						nvme_software_request_queue[*available_command_ids.begin()] = request;
						available_command_ids.erase(available_command_ids.begin());
						request_queue_in_memory[nvme_queue_pair.Submission_queue_tail] = request;
						NVME_UPDATE_SQ_TAIL(nvme_queue_pair);
					}
					request->Enqueue_time = Simulator->Time();
					pcie_root_complex->Write_to_device(nvme_queue_pair.Submission_tail_register_address_on_device, nvme_queue_pair.Submission_queue_tail);//Based on NVMe protocol definition, the updated tail pointer should be informed to the device
				}
				break;
			case HostInterface_Types::SATA:
				request->Source_flow_id = flow_id;
				sata_hba->Submit_io_request(request);
				break;
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
movl 0x54(%rdi), %eax
testl %eax, %eax
je 0x1864e
cmpl $0x1, %eax
jne 0x18754
movzwl 0x82(%rbx), %eax
movzwl 0x84(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jle 0x1866e
incl %eax
movzwl 0x80(%rbx), %ecx
cmpl %ecx, %eax
jne 0x1867c
jmp 0x18740
movzwl 0x38(%rbx), %eax
movw %ax, 0x22(%r14)
movq 0x60(%rbx), %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1d5d4
cmpw $0x0, 0x80(%rbx)
je 0x18740
cmpq $0x0, 0xe0(%rbx)
je 0x18740
leaq 0x118(%rbx), %r15
movq 0xd0(%rbx), %rax
movzwl 0x20(%rax), %eax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x19d20
cmpq $0x0, (%rax)
jne 0x18760
leaq 0xb8(%rbx), %r12
movq 0xd0(%rbx), %rax
movzwl 0x20(%rax), %eax
movw %ax, 0x20(%r14)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x19d20
movq %r14, (%rax)
movq 0xd0(%rbx), %rsi
movq %r12, %rdi
callq 0x1a1ae
movzwl 0x82(%rbx), %eax
movq 0xe8(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
incl %eax
xorl %ecx, %ecx
cmpw 0x84(%rbx), %ax
cmovnel %eax, %ecx
movw %cx, 0x82(%rbx)
callq 0x1f784
movq %rax, %rdi
callq 0x1fafc
movq %rax, 0x8(%r14)
movq 0x58(%rbx), %rdi
movq 0x88(%rbx), %rsi
movzwl 0x82(%rbx), %edx
callq 0x1ce34
jmp 0x18754
addq $0x100, %rbx            # imm = 0x100
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x19978
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x49889(%rip), %rbx     # 0x61ff0
leaq 0x2be1a(%rip), %rsi     # 0x44588
movq %rbx, %rdi
callq 0x7360
leaq 0x2d22d(%rip), %rsi     # 0x459aa
movq %rbx, %rdi
callq 0x7360
movq %rax, %rdi
callq 0x71a0
movq 0x4983c(%rip), %rdi     # 0x61fd0
callq 0x73d0
pushq $0x1
popq %rdi
callq 0x73e0
nop