// File: gvaumour[P]cache-simulator/src/Perceptron.cc
// Function: PerceptronPredictor::initFeatures(bool)
void
PerceptronPredictor::initFeatures(bool isBP)
{
	vector<FeatureTable*>* features;
	vector<string>* criterias_name;
	vector<hashing_function>* features_hash;

	if(isBP)
	{
		criterias_name = &m_BP_criterias_names;
		features_hash = &m_BP_features_hash;
		features = &m_BP_features;		
	}
	else
	{
		criterias_name = &m_Allocation_criterias_names;
		features_hash = &m_Allocation_features_hash;
		features = &m_Allocation_features;
	}

	for(auto feature : *criterias_name)
	{
		features->push_back( new FeatureTable(m_tableSize, feature, isBP));
		if(feature == "MissPC_LSB")
			features_hash->push_back(hashingMissPC_LSB);
		else if(feature == "MissPC_LSB1")
			features_hash->push_back(hashingMissPC_LSB1);
		else if(feature == "MissPC_MSB")
			features_hash->push_back(hashingMissPC_MSB);		

		else if(feature == "TagBlock")
			features_hash->push_back(hashingTag_block);
		else if(feature == "TagPage")
			features_hash->push_back(hashingTag_page);
	
		else if(feature == "MissCounter")
			features_hash->push_back(hashing_MissCounter);	
		else if(feature == "MissCounter1")
			features_hash->push_back(hashing_MissCounter1);
		
		else if( feature == "CallStack")
			features_hash->push_back(hashing_CallStack);
		else if( feature == "CallStack1")	
			features_hash->push_back(hashing_CallStack1);
			
		else if(feature == "currentPC")
			features_hash->push_back(hashing_currentPC);
		else if(feature == "currentPC1")
			features_hash->push_back(hashing_currentPC1);
		else if(feature == "currentPC_3")
			features_hash->push_back(hashingcurrentPC_3);
		else if(feature == "currentPC_2")
			features_hash->push_back(hashingcurrentPC_2);
		else if(feature == "currentPC_1")
			features_hash->push_back(hashingcurrentPC_1);
		else
			assert(false && "Error while initializing the features , wrong name\n");


		if(feature == "CallStack" || feature == "CallStack1")
			m_need_callee_file = true;
	}	
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movb %sil, %al
movq %rdi, 0x140(%rsp)
andb $0x1, %al
movb %al, 0x13f(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x30(%rsp)
testb $0x1, 0x13f(%rsp)
je 0x5052b
movq 0x30(%rsp), %rax
movq %rax, %rcx
addq $0x2e8, %rcx            # imm = 0x2E8
movq %rcx, 0x128(%rsp)
movq %rax, %rcx
addq $0x2d0, %rcx            # imm = 0x2D0
movq %rcx, 0x120(%rsp)
addq $0x2b8, %rax            # imm = 0x2B8
movq %rax, 0x130(%rsp)
jmp 0x50562
movq 0x30(%rsp), %rax
movq %rax, %rcx
addq $0x2a0, %rcx            # imm = 0x2A0
movq %rcx, 0x128(%rsp)
movq %rax, %rcx
addq $0x288, %rcx            # imm = 0x288
movq %rcx, 0x120(%rsp)
addq $0x270, %rax            # imm = 0x270
movq %rax, 0x130(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
callq 0xebf0
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
callq 0xec20
movq %rax, 0x108(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0xec50
testb $0x1, %al
jne 0x505ba
jmp 0x50bbb
leaq 0x110(%rsp), %rdi
callq 0xec90
movq %rax, %rsi
leaq 0xe8(%rsp), %rdi
callq 0x51b0
movq 0x130(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0xa8, %edi
callq 0x53a0
movq %rax, 0x28(%rsp)
jmp 0x505f5
movq 0x30(%rsp), %rax
movb $0x1, 0xaf(%rsp)
movl 0x300(%rax), %eax
movl %eax, 0x1c(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x51b0
jmp 0x50623
movl 0x1c(%rsp), %esi
movq 0x28(%rsp), %rdi
movzbl 0x13f(%rsp), %ecx
andl $0x1, %ecx
leaq 0xb0(%rsp), %rdx
callq 0x2c870
jmp 0x50646
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movb $0x0, 0xaf(%rsp)
movq %rax, 0xe0(%rsp)
leaq 0xe0(%rsp), %rsi
callq 0xf750
jmp 0x5066f
leaq 0xb0(%rsp), %rdi
callq 0x5768
leaq 0x229d3(%rip), %rsi     # 0x73056
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x1b(%rsp)
jmp 0x50696
movb 0x1b(%rsp), %al
testb $0x1, %al
jne 0x506a3
jmp 0x50739
movq 0x120(%rsp), %rdi
leaq -0x20092(%rip), %rax    # 0x30620
movq %rax, 0xa0(%rsp)
leaq 0xa0(%rsp), %rsi
callq 0x4d750
jmp 0x506c9
jmp 0x50b39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x50bac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x5071e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x5768
testb $0x1, 0xaf(%rsp)
jne 0x5072a
jmp 0x50734
movq 0x28(%rsp), %rdi
callq 0x5340
jmp 0x50bac
leaq 0x22921(%rip), %rsi     # 0x73061
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x1a(%rsp)
jmp 0x50753
movb 0x1a(%rsp), %al
testb $0x1, %al
jne 0x5075d
jmp 0x50788
movq 0x120(%rsp), %rdi
leaq -0x2011c(%rip), %rax    # 0x30650
movq %rax, 0x98(%rsp)
leaq 0x98(%rsp), %rsi
callq 0x4d750
jmp 0x50783
jmp 0x50b37
leaq 0x228de(%rip), %rsi     # 0x7306d
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x19(%rsp)
jmp 0x507a2
movb 0x19(%rsp), %al
testb $0x1, %al
jne 0x507ac
jmp 0x507d7
movq 0x120(%rsp), %rdi
leaq -0x2011b(%rip), %rax    # 0x306a0
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %rsi
callq 0x4d750
jmp 0x507d2
jmp 0x50b35
leaq 0x2289a(%rip), %rsi     # 0x73078
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x18(%rsp)
jmp 0x507f1
movb 0x18(%rsp), %al
testb $0x1, %al
jne 0x507fb
jmp 0x50826
movq 0x120(%rsp), %rdi
leaq -0x203aa(%rip), %rax    # 0x30460
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rsi
callq 0x4d750
jmp 0x50821
jmp 0x50b33
leaq 0x22854(%rip), %rsi     # 0x73081
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x17(%rsp)
jmp 0x50840
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x5084a
jmp 0x50875
movq 0x120(%rsp), %rdi
leaq -0x203c9(%rip), %rax    # 0x30490
movq %rax, 0x80(%rsp)
leaq 0x80(%rsp), %rsi
callq 0x4d750
jmp 0x50870
jmp 0x50b31
leaq 0x2280d(%rip), %rsi     # 0x73089
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x16(%rsp)
jmp 0x5088f
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x50899
jmp 0x508be
movq 0x120(%rsp), %rdi
leaq -0x201d8(%rip), %rax    # 0x306d0
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %rsi
callq 0x4d750
jmp 0x508b9
jmp 0x50b2f
leaq 0x227d0(%rip), %rsi     # 0x73095
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x15(%rsp)
jmp 0x508d8
movb 0x15(%rsp), %al
testb $0x1, %al
jne 0x508e2
jmp 0x50907
movq 0x120(%rsp), %rdi
leaq -0x20201(%rip), %rax    # 0x306f0
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rsi
callq 0x4d750
jmp 0x50902
jmp 0x50b2d
leaq 0x22794(%rip), %rsi     # 0x730a2
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x14(%rsp)
jmp 0x50921
movb 0x14(%rsp), %al
testb $0x1, %al
jne 0x5092b
jmp 0x50950
movq 0x120(%rsp), %rdi
leaq -0x2017a(%rip), %rax    # 0x307c0
movq %rax, 0x68(%rsp)
leaq 0x68(%rsp), %rsi
callq 0x4d750
jmp 0x5094b
jmp 0x50b2b
leaq 0x22755(%rip), %rsi     # 0x730ac
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x13(%rsp)
jmp 0x5096a
movb 0x13(%rsp), %al
testb $0x1, %al
jne 0x50974
jmp 0x50999
movq 0x120(%rsp), %rdi
leaq -0x20193(%rip), %rax    # 0x307f0
movq %rax, 0x60(%rsp)
leaq 0x60(%rsp), %rsi
callq 0x4d750
jmp 0x50994
jmp 0x50b29
leaq 0x218fa(%rip), %rsi     # 0x7229a
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x12(%rsp)
jmp 0x509b3
movb 0x12(%rsp), %al
testb $0x1, %al
jne 0x509bd
jmp 0x509e2
movq 0x120(%rsp), %rdi
leaq -0x2028c(%rip), %rax    # 0x30740
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rsi
callq 0x4d750
jmp 0x509dd
jmp 0x50b27
leaq 0x218bb(%rip), %rsi     # 0x722a4
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x11(%rsp)
jmp 0x509fc
movb 0x11(%rsp), %al
testb $0x1, %al
jne 0x50a06
jmp 0x50a2b
movq 0x120(%rsp), %rdi
leaq -0x202a5(%rip), %rax    # 0x30770
movq %rax, 0x50(%rsp)
leaq 0x50(%rsp), %rsi
callq 0x4d750
jmp 0x50a26
jmp 0x50b25
leaq 0x22685(%rip), %rsi     # 0x730b7
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0x10(%rsp)
jmp 0x50a45
movb 0x10(%rsp), %al
testb $0x1, %al
jne 0x50a4f
jmp 0x50a74
movq 0x120(%rsp), %rdi
leaq -0x2064e(%rip), %rax    # 0x30410
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %rsi
callq 0x4d750
jmp 0x50a6f
jmp 0x50b23
leaq 0x22648(%rip), %rsi     # 0x730c3
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0xf(%rsp)
jmp 0x50a8e
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x50a98
jmp 0x50aba
movq 0x120(%rsp), %rdi
leaq -0x206e7(%rip), %rax    # 0x303c0
movq %rax, 0x40(%rsp)
leaq 0x40(%rsp), %rsi
callq 0x4d750
jmp 0x50ab8
jmp 0x50b21
leaq 0x2260e(%rip), %rsi     # 0x730cf
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0xe(%rsp)
jmp 0x50ad4
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0x50ade
jmp 0x50b00
movq 0x120(%rsp), %rdi
leaq -0x2077d(%rip), %rax    # 0x30370
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %rsi
callq 0x4d750
jmp 0x50afe
jmp 0x50b1f
leaq 0x225d4(%rip), %rdi     # 0x730db
leaq 0x2295a(%rip), %rsi     # 0x73468
movl $0x8f, %edx
leaq 0x22960(%rip), %rcx     # 0x7347a
callq 0x5260
jmp 0x50b21
jmp 0x50b23
jmp 0x50b25
jmp 0x50b27
jmp 0x50b29
jmp 0x50b2b
jmp 0x50b2d
jmp 0x50b2f
jmp 0x50b31
jmp 0x50b33
jmp 0x50b35
jmp 0x50b37
jmp 0x50b39
leaq 0x22562(%rip), %rsi     # 0x730a2
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0xd(%rsp)
jmp 0x50b53
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0x50b81
jmp 0x50b5d
leaq 0x22548(%rip), %rsi     # 0x730ac
leaq 0xe8(%rsp), %rdi
callq 0xfa60
movb %al, 0xc(%rsp)
jmp 0x50b77
movb 0xc(%rsp), %al
testb $0x1, %al
jne 0x50b81
jmp 0x50b8d
movq 0x30(%rsp), %rax
movb $0x1, 0x310(%rax)
leaq 0xe8(%rsp), %rdi
callq 0x5768
leaq 0x110(%rsp), %rdi
callq 0xeca0
jmp 0x5059c
leaq 0xe8(%rsp), %rdi
callq 0x5768
jmp 0x50bc3
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xd8(%rsp), %rdi
callq 0x5690