// File: gvaumour[P]cache-simulator/src/SimpleFeatureTable.cc
// Function: SimpleFeatureTable::finishSimu()
void 
SimpleFeatureTable::finishSimu()
{

	if(!simu_parameters.perceptron_drawFeatureMaps || stats_heatmap_counter.size() == 0)
		return;
		
	int height = m_size;
	int width = stats_heatmap_counter[0].size();


	if(width > IMG_WIDTH)
	{
		stats_heatmap_counter = resize_image(stats_heatmap_counter);
		width = stats_heatmap_counter[0].size();
	}	
	vector< vector<int> > red = vector< vector<int> >(width, vector<int>(height, 0));
	vector< vector<int> > blue  = red;
	vector< vector<int> > green = red;
	
	for(unsigned i = 0 ; i < stats_heatmap_counter.size(); i++)
	{
		for(unsigned j = 0 ; j < stats_heatmap_counter[i].size(); j++)
		{
			int value = stats_heatmap_counter[i][j];
			
			if(value >= 0)
			{
				red[j][i] = 255;
				blue[j][i] = 255 - 255 * value / simu_parameters.perceptron_counter_size;			
				green[j][i] =  255 - 255 * value / simu_parameters.perceptron_counter_size; 
			}
			else
			{
				blue[j][i] = 255;
				red[j][i] = 255 - 255 * -value / simu_parameters.perceptron_counter_size;
				green[j][i] = 255 - 255 * -value / simu_parameters.perceptron_counter_size; 
			}
		}
	}

	writeBMPimage(string("counter_" + m_name + ".bmp") , width , height , red, blue, green );
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x180(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x3567d(%rip), %rax     # 0x93ff0
testb $0x1, 0x1cc(%rax)
je 0x5e990
movq 0x48(%rsp), %rdi
addq $0x48, %rdi
callq 0xfb20
cmpq $0x0, %rax
jne 0x5e995
jmp 0x5ef48
movq 0x48(%rsp), %rdi
movl (%rdi), %eax
movl %eax, 0x17c(%rsp)
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
callq 0x11020
movl %eax, 0x178(%rsp)
cmpl $0x7d0, 0x178(%rsp) # imm = 0x7D0
jle 0x5ea26
movq 0x48(%rsp), %rsi
addq $0x48, %rsi
leaq 0x160(%rsp), %rdi
callq 0x66180
movq 0x48(%rsp), %rdi
addq $0x48, %rdi
leaq 0x160(%rsp), %rsi
callq 0xee50
leaq 0x160(%rsp), %rdi
callq 0xee90
movq 0x48(%rsp), %rdi
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
callq 0x11020
movl %eax, 0x178(%rsp)
movslq 0x178(%rsp), %rax
movq %rax, 0x30(%rsp)
movslq 0x17c(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x12c(%rsp)
leaq 0x12b(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xed30
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rcx
leaq 0x130(%rsp), %rdi
leaq 0x12c(%rsp), %rdx
callq 0xed40
jmp 0x5ea7e
leaq 0x11b(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xedc0
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rcx
leaq 0x148(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0xedd0
jmp 0x5eab1
leaq 0x11b(%rsp), %rdi
callq 0xeef0
leaq 0x130(%rsp), %rdi
callq 0xef00
leaq 0x12b(%rsp), %rdi
callq 0xef60
leaq 0x100(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x2e9d0
jmp 0x5eaef
leaq 0xe8(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x2e9d0
jmp 0x5eb06
movl $0x0, 0xe4(%rsp)
movq 0x48(%rsp), %rdi
movl 0xe4(%rsp), %eax
movq %rax, 0x20(%rsp)
addq $0x48, %rdi
callq 0xfb20
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x5ee2d
movl $0x0, 0xe0(%rsp)
movq 0x48(%rsp), %rdi
movl 0xe0(%rsp), %eax
movq %rax, 0x18(%rsp)
addq $0x48, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
callq 0x11020
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x5ee15
movq 0x48(%rsp), %rdi
addq $0x48, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl 0xe0(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl (%rax), %eax
movl %eax, 0xdc(%rsp)
cmpl $0x0, 0xdc(%rsp)
jl 0x5ed22
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl $0xff, (%rax)
imull $0xff, 0xdc(%rsp), %eax
leaq 0x353ef(%rip), %rcx     # 0x93ff0
cltd
idivl 0x1b0(%rcx)
movl %eax, %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, 0x10(%rsp)
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0x100(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl 0x10(%rsp), %ecx
movl %ecx, (%rax)
imull $0xff, 0xdc(%rsp), %eax
leaq 0x3539c(%rip), %rcx     # 0x93ff0
cltd
idivl 0x1b0(%rcx)
movl %eax, %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, 0x14(%rsp)
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x5edfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5ecde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0x11b(%rsp), %rdi
callq 0xeef0
leaq 0x130(%rsp), %rdi
callq 0xef00
leaq 0x12b(%rsp), %rdi
callq 0xef60
jmp 0x5f03a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5f02d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5f020
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0x100(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl $0xff, (%rax)
xorl %eax, %eax
subl 0xdc(%rsp), %eax
imull $0xff, %eax, %eax
leaq 0x3528b(%rip), %rcx     # 0x93ff0
cltd
idivl 0x1b0(%rcx)
movl %eax, %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, 0x8(%rsp)
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl 0x8(%rsp), %ecx
movl %ecx, (%rax)
xorl %eax, %eax
subl 0xdc(%rsp), %eax
imull $0xff, %eax, %eax
leaq 0x35234(%rip), %rcx     # 0x93ff0
cltd
idivl 0x1b0(%rcx)
movl %eax, %ecx
movl $0xff, %eax
subl %ecx, %eax
movl %eax, 0xc(%rsp)
movl 0xe0(%rsp), %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
callq 0xef70
movq %rax, %rdi
movl 0xe4(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x5edff
movl 0xe0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe0(%rsp)
jmp 0x5eb47
jmp 0x5ee17
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x5eb11
movq 0x48(%rsp), %rdx
addq $0x8, %rdx
leaq 0x14e28(%rip), %rsi     # 0x73c65
leaq 0x98(%rsp), %rdi
callq 0x2ead0
jmp 0x5ee4c
leaq 0x133d5(%rip), %rdx     # 0x72228
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x10180
jmp 0x5ee6a
movl 0x178(%rsp), %eax
movl %eax, (%rsp)
movl 0x17c(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x2e9d0
jmp 0x5ee96
leaq 0x68(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2e9d0
jmp 0x5eeaa
leaq 0x50(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x2e9d0
jmp 0x5eebe
movl 0x4(%rsp), %edx
movl (%rsp), %esi
leaq 0xb8(%rsp), %rdi
leaq 0x80(%rsp), %rcx
leaq 0x68(%rsp), %r8
leaq 0x50(%rsp), %r9
callq 0x66550
jmp 0x5eee6
leaq 0x50(%rsp), %rdi
callq 0xee90
leaq 0x68(%rsp), %rdi
callq 0xee90
leaq 0x80(%rsp), %rdi
callq 0xee90
leaq 0xb8(%rsp), %rdi
callq 0x5768
leaq 0x98(%rsp), %rdi
callq 0x5768
leaq 0xe8(%rsp), %rdi
callq 0xee90
leaq 0x100(%rsp), %rdi
callq 0xee90
leaq 0x148(%rsp), %rdi
callq 0xee90
addq $0x188, %rsp            # imm = 0x188
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5f013
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5f006
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5eff9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5efec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
jmp 0x5efe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xee90
leaq 0x68(%rsp), %rdi
callq 0xee90
leaq 0x80(%rsp), %rdi
callq 0xee90
leaq 0xb8(%rsp), %rdi
callq 0x5768
leaq 0x98(%rsp), %rdi
callq 0x5768
leaq 0xe8(%rsp), %rdi
callq 0xee90
leaq 0x100(%rsp), %rdi
callq 0xee90
leaq 0x148(%rsp), %rdi
callq 0xee90
movq 0x120(%rsp), %rdi
callq 0x5690
nopw (%rax,%rax)