// File: /workspace/github_cpp_makefile_star2_O3/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 $0x108, %rsp            # imm = 0x108
leaq 0x1bd92(%rip), %r12     # 0x45f50
cmpb $0x1, 0x1cc(%r12)
jne 0x2a4ff
movq %rdi, %r15
movq 0x48(%rdi), %rax
cmpq %rax, 0x50(%rdi)
je 0x2a4ff
movslq (%r15), %rbx
movq 0x8(%rax), %r14
subq (%rax), %r14
shrq $0x2, %r14
cmpl $0x7d1, %r14d           # imm = 0x7D1
jl 0x2a257
leaq 0x48(%r15), %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2eda1
movq 0x58(%r15), %rax
movaps (%r14), %xmm0
movq 0x10(%r14), %rcx
movq %rcx, 0x58(%r15)
movups 0x48(%r15), %xmm1
movups %xmm0, 0x48(%r15)
leaq 0x30(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0xc5b4
movq %r14, %rdi
callq 0xc5b4
movq 0x48(%r15), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
shrq $0x2, %r14
leaq 0x88(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rcx
movq %rbx, %rsi
callq 0x152ee
movslq %r14d, %rsi
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0xc524
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2a29d
callq 0x52b0
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x154f6
movq %r14, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x154f6
movq 0x48(%r15), %rsi
movq %r15, 0x60(%rsp)
movq 0x50(%r15), %rax
subq %rsi, %rax
je 0x2a3ad
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq %rcx, 0x68(%rsp)
xorl %r8d, %r8d
movl $0xff, %r9d
leaq (%r8,%r8,2), %rax
movq (%rsi,%rax,8), %r10
movq 0x8(%rsi,%rax,8), %r11
subq %r10, %r11
je 0x2a39c
sarq $0x2, %r11
movq 0x88(%rsp), %r13
movq 0x10(%rsp), %rdi
movq 0x70(%rsp), %rbx
xorl %r14d, %r14d
xorl %r15d, %r15d
movl (%r10,%r14,4), %eax
testl %eax, %eax
movq %r13, %rdx
cmovnsq %rdi, %rdx
movl $0xffffff01, %ecx       # imm = 0xFFFFFF01
cmovnsl %r9d, %ecx
movq %rdi, %rbp
cmovnsq %r13, %rbp
movq (%rdx,%r15), %rdx
movl %r9d, (%rdx,%r8,4)
imull %eax, %ecx
movl %ecx, %eax
cltd
idivl 0x1b0(%r12)
movl $0xff, %edx
subl %eax, %edx
movq (%rbp,%r15), %rax
movl %edx, (%rax,%r8,4)
movl %ecx, %eax
cltd
idivl 0x1b0(%r12)
movl $0xff, %ecx
subl %eax, %ecx
movq (%rbx,%r15), %rax
movl %ecx, (%rax,%r8,4)
incq %r14
movl %r14d, %eax
addq $0x18, %r15
cmpq %rax, %r11
ja 0x2a330
incq %r8
movl %r8d, %eax
cmpq %rax, 0x68(%rsp)
ja 0x2a2fe
movq 0x60(%rsp), %rdx
addq $0x8, %rdx
leaq 0xc8fe(%rip), %rsi      # 0x36cbb
leaq 0x30(%rsp), %rdi
callq 0x15588
leaq 0xae6a(%rip), %rsi      # 0x35238
leaq 0x30(%rsp), %rdi
callq 0x55f0
leaq 0xb0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2a408
movq %rdx, 0xa0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb0(%rsp)
jmp 0x2a40f
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0xa8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x154f6
leaq 0xd8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x154f6
leaq 0xc0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x154f6
leaq 0xa0(%rsp), %rdi
leaq 0xf0(%rsp), %rcx
leaq 0xd8(%rsp), %r8
leaq 0xc0(%rsp), %r9
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x2ef63
leaq 0xc0(%rsp), %rdi
callq 0xc5b4
leaq 0xd8(%rsp), %rdi
callq 0xc5b4
leaq 0xf0(%rsp), %rdi
callq 0xc5b4
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a4cb
callq 0x52b0
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a4de
callq 0x52b0
leaq 0x70(%rsp), %rdi
callq 0xc5b4
leaq 0x88(%rsp), %rdi
callq 0xc5b4
leaq 0x10(%rsp), %rdi
callq 0xc5b4
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xc5b4
jmp 0x2a526
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xc5b4
jmp 0x2a538
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xc5b4
jmp 0x2a54a
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a561
callq 0x52b0
jmp 0x2a561
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a579
callq 0x52b0
jmp 0x2a579
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xc5b4
leaq 0x88(%rsp), %rdi
callq 0xc5b4
leaq 0x10(%rsp), %rdi
callq 0xc5b4
movq %rbx, %rdi
callq 0x55a0
movq %rax, %rbx
jmp 0x2a583
movq %rax, %rbx
jmp 0x2a590
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2a59a
callq 0x52b0
jmp 0x2a59a
movq %rax, %rbx
jmp 0x2a59a
nop