// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
cmpb $0x0, 0x28(%rdi)
je 0x1f3c6
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x30(%rdi), %rax
addq $0x30, %r14
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x52c0
movsbl %al, %edx
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x55d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x1f177
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0xc7c2
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x1f163
callq 0x52b0
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rsp), %rdx
testq %rdx, %rdx
je 0x1f148
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x40(%rsp), %rsi
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0xcbd6
leaq 0x60(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movl $0x20, %edx
callq 0x2e230
movq 0x30(%rsp), %rax
leaq 0x60(%rsp), %r14
movaps (%r14), %xmm0
movq 0x10(%r14), %rcx
movq %rcx, 0x30(%rsp)
movaps 0x20(%rsp), %xmm1
movaps %xmm0, 0x20(%rsp)
movq %rsp, %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0xc7c2
movq %r14, %rdi
callq 0xc7c2
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f213
callq 0x52b0
movq 0x20(%rsp), %rax
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xcbd6
movq (%rsp), %rdi
cmpb $0x23, (%rdi)
jne 0x1f367
cmpb $0x21, 0x1(%rdi)
jne 0x1f367
movq 0x8(%rsp), %rsi
addq %rdi, %rsi
leaq 0x60(%rsp), %rdx
movb $0x23, (%rdx)
callq 0x1f882
movq %rax, %rcx
subq (%rsp), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
addq %rdi, %rsi
leaq 0x60(%rsp), %rdx
movb $0x21, (%rdx)
callq 0x1f882
movq %rax, %rcx
subq (%rsp), %rcx
movq %rcx, 0x8(%rsp)
movb $0x0, (%rax)
movq (%rsp), %rsi
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xcbd6
leaq 0x98(%rsp), %rdi
callq 0x2e3ec
movq %rax, (%rbx)
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f2de
callq 0x52b0
movq 0x20(%rsp), %r13
movq 0x20(%r13), %rdi
callq 0x54c0
movl %eax, %ebp
movq 0x40(%r13), %rdi
callq 0x54c0
movl %eax, 0x8(%rbx)
movq 0x60(%r13), %rdi
callq 0x54c0
movl %eax, 0x20(%rbx)
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x80(%r13), %rsi
movq 0x88(%r13), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xcbd6
leaq 0x78(%rsp), %rdi
callq 0x2e3ec
movq %rax, 0x10(%rbx)
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f34b
callq 0x52b0
cmpl $0x3, %ebp
jae 0x1f3e5
movl %ebp, %eax
leaq 0x16d37(%rip), %rcx     # 0x36094
movl (%rcx,%rax,4), %eax
movl %eax, 0x1c(%rbx)
movb $0x1, %bl
jmp 0x1f3af
movq 0x25c62(%rip), %rbx     # 0x44fd0
leaq 0x16c6e(%rip), %rsi     # 0x35fe3
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x5360
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x52c0
movsbl %al, %esi
movq 0x25c30(%rip), %rdi     # 0x44fd0
callq 0x5030
movq %rax, %rdi
callq 0x5200
xorl %ebx, %ebx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x1f14a
callq 0x52b0
jmp 0x1f14a
leaq 0x16bc9(%rip), %rdi     # 0x35f96
leaq 0x16bcb(%rip), %rsi     # 0x35f9f
leaq 0x16c6b(%rip), %rcx     # 0x36046
movl $0x6b, %edx
callq 0x51d0
leaq 0x16c12(%rip), %rdi     # 0x35ffe
leaq 0x16bac(%rip), %rsi     # 0x35f9f
leaq 0x16c4c(%rip), %rcx     # 0x36046
movl $0x8e, %edx
callq 0x51d0
movq %rax, %rbx
movq 0x78(%rsp), %rdi
jmp 0x1f41b
jmp 0x1f441
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f444
callq 0x52b0
jmp 0x1f444
jmp 0x1f441
jmp 0x1f441
jmp 0x1f454
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x1f44d
jmp 0x1f457
jmp 0x1f454
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x1f457
callq 0x52b0
jmp 0x1f457
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xc7c2
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x1f470
callq 0x52b0
movq %rbx, %rdi
callq 0x55a0