// File: gvaumour[P]cache-simulator/src/SimplePerceptron.cc
// Function: SimplePerceptronPredictor::SimplePerceptronPredictor(int, int, int, int, std::vector<std::vector<CacheEntry*, std::allocator<CacheEntry*>>, std::allocator<std::vector<CacheEntry*, std::allocator<CacheEntry*>>>>&, std::vector<std::vector<CacheEntry*, std::allocator<CacheEntry*>>, std::allocator<std::vector<CacheEntry*, std::allocator<CacheEntry*>>>>&, HybridCache*)
SimplePerceptronPredictor::SimplePerceptronPredictor(int id, int nbAssoc , int nbSet, int nbNVMways, DataArray& SRAMtable, DataArray& NVMtable, HybridCache* cache) :\
	Predictor(id, nbAssoc , nbSet , nbNVMways , SRAMtable , NVMtable , cache)
{	
	m_tableSize = simu_parameters.perceptron_table_size;

	m_feature_names = simu_parameters.simple_perceptron_features;
	
	initFeatures();
	
	for(auto p : simu_parameters.simple_perceptron_features)
		cout << p << ",";
	cout << endl;
	
	m_costParameters = simu_parameters.optTarget;
	
	m_cpt = 0;
	
	if(simu_parameters.printDebug)
		debug_file_simple_perceptron.open(SIMPLE_PERCEPTRON_DEBUG_FILE);	
	
	stats_access_class = vector<vector<int> >(NUM_RD_TYPE ,  vector<int>(2, 0));
	stats_nbMigrations = vector<int>(2,0);

	stats_good_alloc = 0, stats_wrong_alloc = 0;

}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq 0x148(%rsp), %rax
movq 0x140(%rsp), %rax
movq %rdi, 0x130(%rsp)
movl %esi, 0x12c(%rsp)
movl %edx, 0x128(%rsp)
movl %ecx, 0x124(%rsp)
movl %r8d, 0x120(%rsp)
movq %r9, 0x118(%rsp)
movq 0x130(%rsp), %rdi
movq %rdi, 0x68(%rsp)
movl 0x12c(%rsp), %esi
movl 0x128(%rsp), %edx
movl 0x124(%rsp), %ecx
movl 0x120(%rsp), %r8d
movq 0x118(%rsp), %r9
movq 0x140(%rsp), %r10
movq 0x148(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x8(%rax)
movq %r10, (%rax)
callq 0x537e0
movq 0x68(%rsp), %rdi
leaq 0x32e37(%rip), %rax     # 0x92d08
movq %rax, (%rdi)
addq $0x270, %rdi            # imm = 0x270
movq %rdi, 0x50(%rsp)
callq 0x64900
movq 0x68(%rsp), %rdi
addq $0x288, %rdi            # imm = 0x288
movq %rdi, 0x58(%rsp)
callq 0xe840
movq 0x68(%rsp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
movq %rdi, 0x60(%rsp)
callq 0xe850
movq 0x68(%rsp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movq %rdi, 0x70(%rsp)
callq 0xe880
jmp 0x5ff29
movq 0x68(%rsp), %rdi
addq $0x338, %rdi            # imm = 0x338
movq %rdi, 0x40(%rsp)
callq 0xe860
movq 0x68(%rsp), %rdi
addq $0x350, %rdi            # imm = 0x350
movq %rdi, 0x48(%rsp)
callq 0xe8d0
movq 0x68(%rsp), %rdi
leaq 0x3408f(%rip), %rsi     # 0x93ff0
movl 0x1c8(%rsi), %eax
movl %eax, 0x2b8(%rdi)
addq $0x2a0, %rdi            # imm = 0x2A0
addq $0x230, %rsi            # imm = 0x230
callq 0xe930
jmp 0x5ff82
movq 0x68(%rsp), %rdi
callq 0x60340
jmp 0x5ff8e
leaq 0x3405b(%rip), %rax     # 0x93ff0
addq $0x230, %rax            # imm = 0x230
movq %rax, 0x100(%rsp)
leaq 0x34046(%rip), %rdi     # 0x93ff0
addq $0x230, %rdi            # imm = 0x230
callq 0xebf0
movq %rax, 0xf8(%rsp)
leaq 0x3402b(%rip), %rdi     # 0x93ff0
addq $0x230, %rdi            # imm = 0x230
callq 0xec20
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0xec50
testb $0x1, %al
jne 0x5fff7
jmp 0x600bb
leaq 0xf8(%rsp), %rdi
callq 0xec90
movq %rax, %rsi
leaq 0xd0(%rsp), %rdi
callq 0x51b0
jmp 0x60016
movq 0x32fb3(%rip), %rdi     # 0x92fd0
leaq 0xd0(%rsp), %rsi
callq 0x5330
movq %rax, 0x38(%rsp)
jmp 0x60031
movq 0x38(%rsp), %rdi
leaq 0x11005(%rip), %rsi     # 0x71042
callq 0x5380
jmp 0x60044
leaq 0xd0(%rsp), %rdi
callq 0x5768
leaq 0xf8(%rsp), %rdi
callq 0xeca0
jmp 0x5ffd9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
jmp 0x60300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
jmp 0x602e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x5768
jmp 0x602e2
movq 0x32f0e(%rip), %rdi     # 0x92fd0
movq 0x32eef(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x600d0
movq 0x68(%rsp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
leaq 0x33f0d(%rip), %rsi     # 0x93ff0
addq $0xe8, %rsi
callq 0xefb0
jmp 0x600f1
movq 0x68(%rsp), %rax
movq $0x0, 0x2c0(%rax)
leaq 0x33ee8(%rip), %rax     # 0x93ff0
testb $0x1, (%rax)
je 0x60129
leaq 0x33c9c(%rip), %rdi     # 0x93db0
leaq 0x13b53(%rip), %rsi     # 0x73c6e
movl $0x10, %edx
callq 0x5070
jmp 0x60127
jmp 0x60129
movl $0x0, 0x9c(%rsp)
leaq 0x9b(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xed30
movq 0x30(%rsp), %rcx
leaq 0xa0(%rsp), %rdi
movl $0x2, %esi
leaq 0x9c(%rsp), %rdx
callq 0xed40
jmp 0x60167
leaq 0x9a(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xedc0
movq 0x28(%rsp), %rcx
leaq 0xb8(%rsp), %rdi
movl $0x3, %esi
leaq 0xa0(%rsp), %rdx
callq 0xedd0
jmp 0x6019a
movq 0x68(%rsp), %rdi
addq $0x338, %rdi            # imm = 0x338
leaq 0xb8(%rsp), %rsi
movq %rsi, 0x18(%rsp)
callq 0xee50
movq 0x18(%rsp), %rdi
callq 0xee90
leaq 0x9a(%rsp), %rdi
callq 0xeef0
leaq 0xa0(%rsp), %rdi
callq 0xef00
leaq 0x9b(%rsp), %rdi
callq 0xef60
movl $0x0, 0x7c(%rsp)
leaq 0x7b(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xed30
movq 0x20(%rsp), %rcx
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
leaq 0x7c(%rsp), %rdx
callq 0xed40
jmp 0x6021e
movq 0x68(%rsp), %rdi
addq $0x350, %rdi            # imm = 0x350
leaq 0x80(%rsp), %rsi
callq 0xf150
leaq 0x80(%rsp), %rdi
callq 0xef00
leaq 0x7b(%rsp), %rdi
callq 0xef60
movq 0x68(%rsp), %rax
movq $0x0, 0x328(%rax)
movq $0x0, 0x330(%rax)
addq $0x138, %rsp            # imm = 0x138
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
jmp 0x602b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0x9a(%rsp), %rdi
callq 0xeef0
leaq 0xa0(%rsp), %rdi
callq 0xef00
leaq 0x9b(%rsp), %rdi
callq 0xef60
jmp 0x602e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0x7b(%rsp), %rdi
callq 0xef60
movq 0x48(%rsp), %rdi
callq 0xef00
movq 0x40(%rsp), %rdi
callq 0xee90
movq 0x70(%rsp), %rdi
callq 0xf520
movq 0x60(%rsp), %rdi
callq 0xf560
movq 0x58(%rsp), %rdi
callq 0xf5c0
movq 0x50(%rsp), %rdi
callq 0x64910
movq 0x68(%rsp), %rdi
callq 0x549b0
movq 0x110(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)