// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
leaq 0x1bbc4(%rip), %r13     # 0x3df50
cmpb $0x1, 0x1cc(%r13)
jne 0x2262d
movq %rdi, %rbx
movq 0x48(%rdi), %rax
cmpq %rax, 0x50(%rdi)
je 0x2262d
movslq (%rbx), %rsi
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x2, %rcx
movq %rcx, 0x8(%rsp)
cmpl $0x7d1, %ecx            # imm = 0x7D1
movq %rbx, 0x10(%rsp)
jl 0x22410
leaq 0x48(%rbx), %r14
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %rsi, %rbx
movq %r14, %rsi
callq 0x2561b
movq %r14, %rdi
movq %r12, %rsi
callq 0xa710
movq %r12, %rdi
callq 0x9d36
movq %rbx, %rsi
movq 0x10(%rsp), %rbx
movq (%r14), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x2, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x78(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0x60(%rsp), %rcx
movq %rsi, 0x50(%rsp)
callq 0x9c8a
movslq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x9ce0
leaq 0x30(%rsp), %rdi
callq 0xa49a
leaq 0x78(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x119a0
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x119a0
movq 0x48(%rbx), %rdi
movq 0x50(%rbx), %rax
subq %rdi, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, 0x58(%rsp)
xorl %r8d, %r8d
movl $0xff, %r9d
movl %r8d, %r8d
cmpq %r8, 0x58(%rsp)
jbe 0x2253b
imulq $0x18, %r8, %rax
movq (%rdi,%rax), %r10
movq 0x8(%rdi,%rax), %r11
subq %r10, %r11
sarq $0x2, %r11
movq 0x78(%rsp), %r12
movq 0x18(%rsp), %rcx
xorl %eax, %eax
movq 0x60(%rsp), %rbx
movl %eax, %r14d
cmpq %r14, %r11
jbe 0x2252e
movl (%r10,%r14,4), %eax
imulq $0x18, %r14, %r15
testl %eax, %eax
movq %r12, %rdx
cmovnsq %rcx, %rdx
movl $0xffffff01, %esi       # imm = 0xFFFFFF01
cmovnsl %r9d, %esi
movq %rcx, %rbp
cmovnsq %r12, %rbp
movq (%rdx,%r15), %rdx
movl %r9d, (%rdx,%r8,4)
imull %eax, %esi
movl %esi, %eax
cltd
idivl 0x1b0(%r13)
movl $0xff, %edx
subl %eax, %edx
movq (%rbp,%r15), %rax
movl %edx, (%rax,%r8,4)
movl %esi, %eax
cltd
idivl 0x1b0(%r13)
movl $0xff, %edx
subl %eax, %edx
movq (%rbx,%r15), %rax
movl %edx, (%rax,%r8,4)
leal 0x1(%r14), %eax
jmp 0x224c1
incl %r8d
movq 0x10(%rsp), %rbx
jmp 0x2248e
addq $0x8, %rbx
leaq 0x9725(%rip), %rsi      # 0x2bc6b
leaq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x119fa
leaq 0x7c8a(%rip), %rdx      # 0x2a1e4
leaq 0xd8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa0bd
leaq 0xc0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x119a0
leaq 0xa8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x119a0
leaq 0x90(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x119a0
leaq 0xd8(%rsp), %rdi
leaq 0xc0(%rsp), %rcx
leaq 0xa8(%rsp), %r8
leaq 0x90(%rsp), %r9
movq 0x8(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x2577d
leaq 0x90(%rsp), %rdi
callq 0x9d36
leaq 0xa8(%rsp), %rdi
callq 0x9d36
leaq 0xc0(%rsp), %rdi
callq 0x9d36
leaq 0xd8(%rsp), %rdi
callq 0x5618
leaq 0x30(%rsp), %rdi
callq 0x5618
leaq 0x60(%rsp), %rdi
callq 0x9d36
leaq 0x78(%rsp), %rdi
callq 0x9d36
leaq 0x18(%rsp), %rdi
callq 0x9d36
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x9d36
jmp 0x22654
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x9d36
jmp 0x22666
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x9d36
jmp 0x22678
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x5618
jmp 0x2268a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5618
leaq 0x60(%rsp), %rdi
callq 0x9d36
leaq 0x78(%rsp), %rdi
callq 0x9d36
leaq 0x18(%rsp), %rdi
callq 0x9d36
movq %rbx, %rdi
callq 0x5570
movq %rax, %rbx
jmp 0x22694
movq %rax, %rbx
jmp 0x2269e
movq %rax, %rbx
jmp 0x226a8
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xa49a
jmp 0x226b2
movq %rax, %rbx
jmp 0x226b2
nop