// File: /workspace/github_cpp_makefile_star2_O2/gvaumour[P]cache-simulator/src/MemoryTrace.cc
// Function: TextTrace::readNext(Access&)
bool
TextTrace::readNext(Access& element)
{	
	assert(m_isOpen);

	string line;
	vector<string> split_line;
			
	if(!getline(m_textTrace , line)){
		return false;
	}
	if(line.empty())
		return false;
	
	split_line = split(line , ' ');

	string addr = split_line[0];

	if(addr[0] != '#' || addr[1] != '!')
	{
		cout << "Line passed - Wrong Format" << endl;
		return false;
	}

	addr.erase( remove(addr.begin(), addr.end(), '#'), addr.end());
	addr.erase( remove(addr.begin(), addr.end(), '!'), addr.end());

	element.m_address = hexToInt(addr);
	int operation = atoi(split_line[1].c_str());		
	element.m_size = atoi(split_line[2].c_str());		
	element.m_idthread = atoi(split_line[3].c_str());
	element.m_pc = hexToInt(split_line[4]);


	switch(operation){
		case 0 : element.m_type = MemCmd::INST_READ;break;
		case 1 : element.m_type = MemCmd::DATA_READ;break;
		case 2 : element.m_type = MemCmd::DATA_WRITE;break;
		default: assert(false && "operation not recognized \n");
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xc8, %rsp
cmpb $0x0, 0x28(%rdi)
je 0x19b30
movq %rsi, %rbx
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
addq $0x30, %rdi
leaq 0x48(%rsp), %rsi
callq 0x50a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
xorl %ebp, %ebp
testb $0x5, 0x20(%rax,%rcx)
jne 0x19b0c
cmpq $0x0, 0x50(%rsp)
je 0x19b0c
leaq 0xa8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5410
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
pushq $0x20
popq %rdx
callq 0x24e58
leaq 0x30(%rsp), %r14
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x19eae
movq %r15, %rdi
callq 0x9ef6
leaq 0xa8(%rsp), %rdi
callq 0x5618
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x5410
movq 0x10(%rsp), %rdi
cmpb $0x23, (%rdi)
jne 0x19ae5
cmpb $0x21, 0x1(%rdi)
jne 0x19ae5
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
leaq 0xf(%rsp), %rdx
movb $0x23, (%rdx)
callq 0x19eff
leaq 0x10(%rsp), %rdi
movq (%rdi), %rdx
addq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x50c0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
leaq 0xf(%rsp), %rdx
movb $0x21, (%rdx)
callq 0x19eff
leaq 0x10(%rsp), %rdi
movq (%rdi), %rdx
addq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x50c0
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5410
leaq 0x88(%rsp), %rdi
callq 0x24fc9
movq %rax, (%rbx)
leaq 0x88(%rsp), %rdi
callq 0x5618
movq 0x30(%rsp), %r14
movq 0x20(%r14), %rdi
callq 0x5490
movl %eax, %ebp
movq 0x40(%r14), %rdi
callq 0x5490
movl %eax, 0x8(%rbx)
movq 0x60(%r14), %rdi
callq 0x5490
movl %eax, 0x20(%rbx)
subq $-0x80, %r14
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x5410
leaq 0x68(%rsp), %rdi
callq 0x24fc9
movq %rax, 0x10(%rbx)
leaq 0x68(%rsp), %rdi
callq 0x5618
cmpl $0x3, %ebp
jae 0x19b4d
movl %ebp, %eax
leaq 0x1156a(%rip), %rcx     # 0x2b044
movl (%rcx,%rax,4), %eax
movl %eax, 0x1c(%rbx)
movb $0x1, %bpl
jmp 0x19b02
movq 0x234e4(%rip), %rdi     # 0x3cfd0
leaq 0x114a0(%rip), %rsi     # 0x2af93
callq 0x52c0
movq %rax, %rdi
callq 0x5190
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
callq 0x5618
leaq 0x30(%rsp), %rdi
callq 0x9ef6
leaq 0x48(%rsp), %rdi
callq 0x5618
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1140f(%rip), %rdi     # 0x2af46
leaq 0x11411(%rip), %rsi     # 0x2af4f
leaq 0x114b1(%rip), %rcx     # 0x2aff6
pushq $0x6b
popq %rdx
callq 0x51e0
leaq 0x1145a(%rip), %rdi     # 0x2afae
leaq 0x113f4(%rip), %rsi     # 0x2af4f
leaq 0x11494(%rip), %rcx     # 0x2aff6
movl $0x8e, %edx
callq 0x51e0
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x19b83
jmp 0x19ba3
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5618
jmp 0x19ba6
jmp 0x19ba3
jmp 0x19ba3
jmp 0x19ba3
jmp 0x19ba3
jmp 0x19bb2
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x19bab
jmp 0x19bb2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5618
jmp 0x19bb5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x9ef6
leaq 0x48(%rsp), %rdi
callq 0x5618
movq %rbx, %rdi
callq 0x5570
nop