// File: gvaumour[P]cache-simulator/src/Cerebron.cc
// Function: CerebronPredictor::finishSimu()
void 
CerebronPredictor::finishSimu()
{
	if(simu_parameters.perceptron_drawFeatureMaps)
	{
		drawFeatureMaps();
	}

	CacheEntry* entry = NULL;
	for(int i = 0 ; i < m_nb_set ; i++)
	{
		for(int j = 0 ; j < m_nbNVMways ; j++)
		{
			entry = m_tableNVM[i][j];		

			if(!entry->isValid)
				continue;
				
			allocDecision des = getDecision(entry);
			if(des != ALLOCATE_IN_NVM)				
				stats_wrong_alloc++;
			else
				stats_good_alloc++;
		}
		for(int j = 0 ; j < m_nbSRAMways ; j++)
		{
			entry = m_tableSRAM[i][j];		

			if(!entry->isValid)
				continue;

			allocDecision des = getDecision(entry);
			if(des != ALLOCATE_IN_SRAM)				
				stats_wrong_alloc++;
			else
				stats_good_alloc++;
		}
	}
	
	
	for(auto feature : m_features)
		feature->finishSimu();

	Predictor::finishSimu();
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x85ce6(%rip), %rax     # 0x93ff0
testb $0x1, 0x1cc(%rax)
je 0xe31d
movq 0x8(%rsp), %rdi
callq 0xe520
movq $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x8(%rsp), %rcx
movl 0x44(%rsp), %eax
cmpl 0x18(%rcx), %eax
jge 0xe4a6
movl $0x0, 0x40(%rsp)
movq 0x8(%rsp), %rcx
movl 0x40(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0xe3ea
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movslq 0x44(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movslq 0x40(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, (%rax)
jne 0xe38e
jmp 0xe3da
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xc020
movl %eax, 0x3c(%rsp)
cmpl $0x1, 0x3c(%rsp)
je 0xe3c1
movq 0x8(%rsp), %rax
movq 0x438(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x438(%rax)
jmp 0xe3d8
movq 0x8(%rsp), %rax
movq 0x430(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x430(%rax)
jmp 0xe3da
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0xe348
movl $0x0, 0x38(%rsp)
movq 0x8(%rsp), %rcx
movl 0x38(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0xe494
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x44(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movslq 0x38(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, (%rax)
jne 0xe438
jmp 0xe484
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xc020
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
je 0xe46b
movq 0x8(%rsp), %rax
movq 0x438(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x438(%rax)
jmp 0xe482
movq 0x8(%rsp), %rax
movq 0x430(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x430(%rax)
jmp 0xe484
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0xe3f2
jmp 0xe496
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xe32e
movq 0x8(%rsp), %rax
addq $0x270, %rax            # imm = 0x270
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0xf680
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rdi
callq 0xf6b0
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xf6e0
testb $0x1, %al
jne 0xe4e9
jmp 0xe511
leaq 0x20(%rsp), %rdi
callq 0xf720
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x2da40
leaq 0x20(%rsp), %rdi
callq 0xf730
jmp 0xe4d4
movq 0x8(%rsp), %rdi
callq 0xfcb0
addq $0x58, %rsp
retq