// File: CMU-SAFARI[P]MQSim/src/host/IO_Flow_Trace_Based.cpp
// Function: Host_Components::IO_Flow_Trace_Based::Execute_simulator_event(MQSimEngine::Sim_Event*)
void IO_Flow_Trace_Based::Execute_simulator_event(MQSimEngine::Sim_Event *)
{
	Host_IO_Request *request = Generate_next_request();
	if (request != NULL)
	{
		Submit_io_request(request);
	}

	if (STAT_generated_request_count < total_requests_to_be_generated)
	{
		std::string trace_line;
		if (std::getline(trace_file, trace_line))
		{
			Utils::Helper_Functions::Remove_cr(trace_line);
			current_trace_line.clear();
			Utils::Helper_Functions::Tokenize(trace_line, ASCIILineDelimiter, current_trace_line);
		}
		else
		{
			trace_file.close();
			trace_file.open(trace_file_path);
			replay_counter++;
			time_offset = Simulator->Time();
			std::getline(trace_file, trace_line);
			Utils::Helper_Functions::Remove_cr(trace_line);
			current_trace_line.clear();
			Utils::Helper_Functions::Tokenize(trace_line, ASCIILineDelimiter, current_trace_line);
			PRINT_MESSAGE("* Replay round " << replay_counter << "of " << total_replay_no << " started  for" << ID())
		}
		char *pEnd;
		Simulator->Register_sim_event(time_offset + std::strtoll(current_trace_line[ASCIITraceTimeColumn].c_str(), &pEnd, 10), this);
	}
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq 0x100(%rsp), %rdi
movq %rdi, 0x90(%rsp)
movq (%rdi), %rax
callq *0x20(%rax)
movq %rax, 0xf0(%rsp)
cmpq $0x0, 0xf0(%rsp)
je 0x39d85
movq 0x90(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x320b0
movq 0x90(%rsp), %rcx
movl 0x150(%rcx), %eax
cmpl 0x50(%rcx), %eax
jae 0x3a0d0
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x85e0
movq 0x90(%rsp), %rdi
movq 0x80(%rsp), %rsi
addq $0x498, %rdi            # imm = 0x498
callq 0x80b0
movq %rax, 0x88(%rsp)
jmp 0x39dd7
movq 0x88(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x8530
movb %al, 0x7f(%rsp)
jmp 0x39df4
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x39dfe
jmp 0x39e5d
leaq 0xd0(%rsp), %rdi
callq 0x3af30
jmp 0x39e0d
movq 0x90(%rsp), %rdi
addq $0x6b0, %rdi            # imm = 0x6B0
movq %rdi, 0x70(%rsp)
callq 0x3afa0
movq 0x70(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
movl $0x20, %esi
callq 0x3afc0
jmp 0x39e3f
jmp 0x3a036
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x3a0c1
movq 0x90(%rsp), %rdi
addq $0x498, %rdi            # imm = 0x498
callq 0x80d0
jmp 0x39e73
movq 0x90(%rsp), %rsi
movq %rsi, %rdi
addq $0x498, %rdi            # imm = 0x498
addq $0x478, %rsi            # imm = 0x478
movl $0x8, %edx
callq 0x83b0
jmp 0x39e98
movq 0x90(%rsp), %rax
movl 0x6a4(%rax), %ecx
incl %ecx
movl %ecx, 0x6a4(%rax)
callq 0x46500
movq %rax, 0x68(%rsp)
jmp 0x39eba
movq 0x68(%rsp), %rdi
callq 0x46c50
movq %rax, 0x60(%rsp)
jmp 0x39ecb
movq 0x90(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rax, 0x6c8(%rdi)
addq $0x498, %rdi            # imm = 0x498
leaq 0xd0(%rsp), %rsi
callq 0x80b0
jmp 0x39ef5
leaq 0xd0(%rsp), %rdi
callq 0x3af30
jmp 0x39f04
movq 0x90(%rsp), %rdi
addq $0x6b0, %rdi            # imm = 0x6B0
movq %rdi, 0x58(%rsp)
callq 0x3afa0
movq 0x58(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
movl $0x20, %esi
callq 0x3afc0
jmp 0x39f36
movq 0xa005b(%rip), %rdi     # 0xd9f98
leaq 0x7203a(%rip), %rsi     # 0xabf7e
callq 0x8440
movq %rax, 0x50(%rsp)
jmp 0x39f50
movq 0x50(%rsp), %rdi
movq 0x90(%rsp), %rax
movl 0x6a4(%rax), %esi
callq 0x85b0
movq %rax, 0x48(%rsp)
jmp 0x39f6f
movq 0x48(%rsp), %rdi
leaq 0x6f4c5(%rip), %rsi     # 0xa9440
callq 0x8440
movq %rax, 0x40(%rsp)
jmp 0x39f87
movq 0x40(%rsp), %rdi
movq 0x90(%rsp), %rax
movl 0x6a0(%rax), %esi
callq 0x85b0
movq %rax, 0x38(%rsp)
jmp 0x39fa6
movq 0x38(%rsp), %rdi
leaq 0x71fdc(%rip), %rsi     # 0xabf8e
callq 0x8440
movq %rax, 0x30(%rsp)
jmp 0x39fbe
movq 0x90(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0xcdf0
jmp 0x39fd5
movq 0x30(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x83e0
movq %rax, 0x28(%rsp)
jmp 0x39fee
movq 0x28(%rsp), %rdi
movq 0x9ff5e(%rip), %rsi     # 0xd9f58
callq 0x8480
jmp 0x3a001
leaq 0xa0(%rsp), %rdi
callq 0x8848
jmp 0x3a036
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x8848
jmp 0x3a0c1
callq 0x46500
movq %rax, 0x20(%rsp)
jmp 0x3a042
movq 0x90(%rsp), %rdi
movq 0x6c8(%rdi), %rax
movq %rax, 0x8(%rsp)
addq $0x6b0, %rdi            # imm = 0x6B0
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movl %eax, %esi
movq %rsi, 0x10(%rsp)
callq 0x3af10
movq %rax, %rdi
callq 0x8190
movq %rax, %rdi
leaq 0x98(%rsp), %rsi
movl $0xa, %edx
callq 0x8830
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x90(%rsp), %rdx
movq 0x10(%rsp), %rcx
movl 0x1c(%rsp), %r8d
addq %rax, %rsi
callq 0x46c60
jmp 0x3a0b2
leaq 0xd0(%rsp), %rdi
callq 0x8848
jmp 0x3a0d0
leaq 0xd0(%rsp), %rdi
callq 0x8848
jmp 0x3a0d8
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xc8(%rsp), %rdi
callq 0x8770
nopw %cs:(%rax,%rax)