// File: CMU-SAFARI[P]MQSim/src/main.cpp
// Function: collect_results(SSD_Device&, Host_System&, char const*)
void collect_results(SSD_Device& ssd, Host_System& host, const char* output_file_path)
{
	Utils::XmlWriter xmlwriter;
	xmlwriter.Open(output_file_path);

	std::string tmp("MQSim_Results");
	xmlwriter.Write_open_tag(tmp);
	
	host.Report_results_in_XML("", xmlwriter);
	ssd.Report_results_in_XML("", xmlwriter);

	xmlwriter.Write_close_tag();

	std::vector<Host_Components::IO_Flow_Base*> IO_flows = host.Get_io_flows();
	for (unsigned int stream_id = 0; stream_id < IO_flows.size(); stream_id++) {
		cout << "Flow " << IO_flows[stream_id]->ID() << " - total requests generated: " << IO_flows[stream_id]->Get_generated_request_count()
			<< " total requests serviced:" << IO_flows[stream_id]->Get_serviced_request_count() << endl;
		cout << "                   - device response time: " << IO_flows[stream_id]->Get_device_response_time() << " (us)"
			<< " end-to-end request delay:" << IO_flows[stream_id]->Get_end_to_end_request_delay() << " (us)" << endl;
	}
}

// Assembly:
subq $0x428, %rsp            # imm = 0x428
movq %rdi, 0x420(%rsp)
movq %rsi, 0x418(%rsp)
movq %rdx, 0x410(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xc640
movq 0x410(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x1af(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x8780
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0x1b0(%rsp), %rdi
callq 0x85d0
jmp 0xb5b0
leaq 0x1d0(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0xa7cb0
jmp 0xb5c7
leaq 0x1b0(%rsp), %rdi
callq 0x8848
leaq 0x1af(%rsp), %rdi
callq 0x84a0
leaq 0x177(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x8780
movq 0xa8(%rsp), %rdx
leaq 0x9dca9(%rip), %rsi     # 0xa92ae
leaq 0x178(%rsp), %rdi
callq 0x85d0
jmp 0xb614
leaq 0x177(%rsp), %rdi
callq 0x84a0
leaq 0x150(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x81a0
jmp 0xb638
leaq 0x1d0(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0xa7d60
jmp 0xb64f
leaq 0x150(%rsp), %rdi
callq 0x8848
movq 0x418(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x12f(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x8780
movq 0xa0(%rsp), %rdx
leaq 0xa03ef(%rip), %rsi     # 0xaba7f
leaq 0x130(%rsp), %rdi
callq 0x85d0
jmp 0xb69f
movq 0x98(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x130(%rsp), %rsi
leaq 0x1d0(%rsp), %rdx
callq *%rax
jmp 0xb6c2
leaq 0x130(%rsp), %rdi
callq 0x8848
leaq 0x12f(%rsp), %rdi
callq 0x84a0
movq 0x420(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x107(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x8780
movq 0x90(%rsp), %rdx
leaq 0xa036f(%rip), %rsi     # 0xaba7f
leaq 0x108(%rsp), %rdi
callq 0x85d0
jmp 0xb71f
movq 0x88(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x108(%rsp), %rsi
leaq 0x1d0(%rsp), %rdx
callq *%rax
jmp 0xb742
leaq 0x108(%rsp), %rdi
callq 0x8848
leaq 0x107(%rsp), %rdi
callq 0x84a0
leaq 0x1d0(%rsp), %rdi
callq 0xa80f0
jmp 0xb76b
movq 0x418(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x1f460
jmp 0xb782
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
movq %rax, 0x80(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0xcdb0
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0xbb4d
movq 0xce7d4(%rip), %rdi     # 0xd9f98
leaq 0x9daf1(%rip), %rsi     # 0xa92bc
callq 0x8440
movq %rax, 0x78(%rsp)
jmp 0xb7d7
movl 0xe4(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xcdd0
movq (%rax), %rsi
leaq 0xc0(%rsp), %rdi
callq 0xcdf0
jmp 0xb7ff
movq 0x78(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x83e0
movq %rax, 0x70(%rsp)
jmp 0xb818
movq 0x70(%rsp), %rdi
leaq 0x9da9e(%rip), %rsi     # 0xa92c2
callq 0x8440
movq %rax, 0x68(%rsp)
jmp 0xb830
movl 0xe4(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xcdd0
movq (%rax), %rdi
callq 0x32440
movl %eax, 0x64(%rsp)
jmp 0xb854
movl 0x64(%rsp), %esi
movq 0x68(%rsp), %rdi
callq 0x85b0
movq %rax, 0x58(%rsp)
jmp 0xb869
movq 0x58(%rsp), %rdi
leaq 0x9da6b(%rip), %rsi     # 0xa92e0
callq 0x8440
movq %rax, 0x50(%rsp)
jmp 0xb881
movl 0xe4(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xcdd0
movq (%rax), %rdi
callq 0x32460
movl %eax, 0x4c(%rsp)
jmp 0xb8a5
movl 0x4c(%rsp), %esi
movq 0x50(%rsp), %rdi
callq 0x85b0
movq %rax, 0x40(%rsp)
jmp 0xb8ba
movq 0x40(%rsp), %rdi
movq 0xce692(%rip), %rsi     # 0xd9f58
callq 0x8480
jmp 0xb8cd
leaq 0xc0(%rsp), %rdi
callq 0x8848
movq 0xce6b7(%rip), %rdi     # 0xd9f98
leaq 0x9da12(%rip), %rsi     # 0xa92fa
callq 0x8440
movq %rax, 0x38(%rsp)
jmp 0xb8f4
movl 0xe4(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xcdd0
movq (%rax), %rdi
callq 0x32480
movl %eax, 0x34(%rsp)
jmp 0xb918
movl 0x34(%rsp), %esi
movq 0x38(%rsp), %rdi
callq 0x85b0
movq %rax, 0x28(%rsp)
jmp 0xb92d
movq 0x28(%rsp), %rdi
leaq 0x9d9ed(%rip), %rsi     # 0xa9326
callq 0x8440
movq %rax, 0x20(%rsp)
jmp 0xb945
movq 0x20(%rsp), %rdi
leaq 0x9d9db(%rip), %rsi     # 0xa932c
callq 0x8440
movq %rax, 0x18(%rsp)
jmp 0xb95d
movl 0xe4(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xcdd0
movq (%rax), %rdi
callq 0x32510
movl %eax, 0x14(%rsp)
jmp 0xb981
movl 0x14(%rsp), %esi
movq 0x18(%rsp), %rdi
callq 0x85b0
movq %rax, 0x8(%rsp)
jmp 0xb996
movq 0x8(%rsp), %rdi
leaq 0x9d984(%rip), %rsi     # 0xa9326
callq 0x8440
movq %rax, (%rsp)
jmp 0xb9ad
movq (%rsp), %rdi
movq 0xce5a0(%rip), %rsi     # 0xd9f58
callq 0x8480
jmp 0xb9bf
jmp 0xb9c1
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0xb78d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0xba0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x8848
leaq 0x1af(%rsp), %rdi
callq 0x84a0
jmp 0xbb96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x177(%rsp), %rdi
callq 0x84a0
jmp 0xbb96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0xbb89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x8848
jmp 0xbb89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0xbabc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x8848
leaq 0x12f(%rsp), %rdi
callq 0x84a0
jmp 0xbb89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0xbb05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x8848
leaq 0x107(%rsp), %rdi
callq 0x84a0
jmp 0xbb89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0xbb7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x8848
jmp 0xbb7c
leaq 0xe8(%rsp), %rdi
callq 0xce20
leaq 0x178(%rsp), %rdi
callq 0x8848
leaq 0x1d0(%rsp), %rdi
callq 0xc680
addq $0x428, %rsp            # imm = 0x428
retq
leaq 0xe8(%rsp), %rdi
callq 0xce20
leaq 0x178(%rsp), %rdi
callq 0x8848
leaq 0x1d0(%rsp), %rdi
callq 0xc680
movq 0x1a0(%rsp), %rdi
callq 0x8770