// File: /workspace/github_cpp_makefile_star2_O1/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 0x1ba3e(%rip), %r12     # 0x45f50
cmpb $0x1, 0x1cc(%r12)
jne 0x2a861
movq %rdi, %r15
movq 0x48(%rdi), %rax
cmpq %rax, 0x50(%rdi)
je 0x2a861
movslq (%r15), %rbx
movq 0x8(%rax), %r14
subq (%rax), %r14
shrq $0x2, %r14
cmpl $0x7d1, %r14d           # imm = 0x7D1
jl 0x2a5b9
leaq 0x48(%r15), %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2f12a
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movups 0x48(%r15), %xmm0
movq 0x58(%r15), %rax
movaps (%r14), %xmm1
movups %xmm1, 0x48(%r15)
movq 0x10(%r14), %rcx
movq %rcx, 0x58(%r15)
movq 0x10(%rdi), %rcx
movq %rax, 0x10(%rdi)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movaps %xmm1, (%r14)
movq %rcx, 0x10(%r14)
callq 0xc642
movq %r14, %rdi
callq 0xc642
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 0x15482
movslq %r14d, %rsi
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0xc5b2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2a5ff
callq 0x52a0
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x15682
movq %r14, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x15682
movq 0x48(%r15), %rsi
movq %r15, 0x60(%rsp)
movq 0x50(%r15), %rax
subq %rsi, %rax
je 0x2a70f
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 0x2a6fe
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 0x2a692
incq %r8
movl %r8d, %eax
cmpq %rax, 0x68(%rsp)
ja 0x2a660
movq 0x60(%rsp), %rdx
addq $0x8, %rdx
leaq 0xc5a4(%rip), %rsi      # 0x36cc3
leaq 0x30(%rsp), %rdi
callq 0x15714
leaq 0xab38(%rip), %rsi      # 0x35268
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 0x2a76a
movq %rdx, 0xa0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb0(%rsp)
jmp 0x2a771
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 0x15682
leaq 0xd8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x15682
leaq 0xc0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x15682
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 0x2f2ec
leaq 0xc0(%rsp), %rdi
callq 0xc642
leaq 0xd8(%rsp), %rdi
callq 0xc642
leaq 0xf0(%rsp), %rdi
callq 0xc642
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a82d
callq 0x52a0
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a840
callq 0x52a0
leaq 0x70(%rsp), %rdi
callq 0xc642
leaq 0x88(%rsp), %rdi
callq 0xc642
leaq 0x10(%rsp), %rdi
callq 0xc642
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 0xc642
jmp 0x2a888
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xc642
jmp 0x2a89a
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xc642
jmp 0x2a8ac
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2a8c3
callq 0x52a0
jmp 0x2a8c3
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a8db
callq 0x52a0
jmp 0x2a8db
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xc642
leaq 0x88(%rsp), %rdi
callq 0xc642
leaq 0x10(%rsp), %rdi
callq 0xc642
movq %rbx, %rdi
callq 0x55a0
movq %rax, %rbx
jmp 0x2a8e5
movq %rax, %rbx
jmp 0x2a8f2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2a8fc
callq 0x52a0
jmp 0x2a8fc
movq %rax, %rbx
jmp 0x2a8fc
nop