// File: /workspace/github_cpp_makefile_star2_O1/gvaumour[P]cache-simulator/src/Hierarchy.cc
// Function: Hierarchy::Hierarchy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
Hierarchy::Hierarchy(string policy, int nbCores)
{
	ConfigCache L1Dataconfig (32768, 4 , BLOCK_SIZE , "LRU", 0);
	vector<ConfigCache> firstLevel;
	firstLevel.push_back(L1Dataconfig);

	ConfigCache L1Instconfig = L1Dataconfig;
	firstLevel.push_back(L1Instconfig);

	int nb_sets = simu_parameters.nb_sets;
	int nvm_assoc = simu_parameters.nvm_assoc;
	int sram_assoc = simu_parameters.sram_assoc;

	ConfigCache L2config ( (nvm_assoc+sram_assoc)*BLOCK_SIZE*nb_sets , sram_assoc + nvm_assoc, \
				BLOCK_SIZE , policy , nvm_assoc);
	L2config.m_printStats = true;
	vector<ConfigCache> secondLevelConfig;
	secondLevelConfig.push_back(L2config);
	
		
	m_nbLevel = 2;
	m_nbCores = nbCores;
//	m_private_caches.resize(m_nbCores);
	
	m_directory = new Directory();
	
	m_prefetcher = NULL;
	if(simu_parameters.enablePrefetch)
		m_prefetcher = new SimplePrefetcher( simu_parameters.prefetchDegree , simu_parameters.prefetchStreams , true);

	stats_beginTimeFrame = 0;
	
	for(unsigned i = 0 ; i < m_nbCores ; i++){
		m_private_caches.push_back(new Level(i , firstLevel, this) );
	}

	m_LLC = new Level(-1, secondLevelConfig , this);
	
	m_start_index = log2(BLOCK_SIZE)-1;
	
	stats_cleanWB_MainMem = 0;
	stats_dirtyWB_MainMem = 0;
	stats_writeMainMem = 0;
	stats_readMainMem = 0;
	
	stats_hitsPrefetch = 0;
	stats_issuedPrefetchs = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
leaq 0x48(%rdi), %r12
movq %r12, 0x38(%rdi)
movq %rax, 0x40(%rdi)
movb $0x0, 0x48(%rdi)
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1ebf4(%rip), %rsi     # 0x3539e
leaq 0x1ebf0(%rip), %rdx     # 0x353a1
leaq 0x90(%rsp), %rdi
movq %r12, 0x40(%rsp)
callq 0xccac
movabsq $0x400008000, %rax      # imm = 0x400008000
leaq 0x18(%rsp), %rdi
movq %rax, -0x10(%rdi)
movl $0x40, -0x8(%rdi)
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
callq 0xcc1c
movl $0x0, 0x38(%rsp)
movb $0x0, 0x3c(%rsp)
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x1681d
callq 0x52a0
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x8(%rsp), %rsi
callq 0x18176
movq 0x8(%rsp), %rax
leaq 0x128(%rsp), %rdi
movq %rax, -0x10(%rdi)
movl 0x10(%rsp), %eax
movl %eax, -0x8(%rdi)
leaq 0x138(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
callq 0xcc1c
movl %ebp, 0x4(%rsp)
movl 0x38(%rsp), %eax
leaq 0x118(%rsp), %rsi
movl %eax, 0x30(%rsi)
movb 0x3c(%rsp), %al
movb %al, 0x34(%rsi)
leaq 0x70(%rsp), %rdi
callq 0x18176
leaq 0x2f6b5(%rip), %r12     # 0x45f50
movl 0x44(%r12), %r15d
movl 0x38(%r12), %ebp
movl 0x40(%r12), %r13d
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xcc1c
addl %r13d, %ebp
imull %ebp, %r15d
shll $0x6, %r15d
leaq 0xf0(%rsp), %rdi
movl %r15d, -0x10(%rdi)
movl %ebp, -0xc(%rdi)
movl $0x40, -0x8(%rdi)
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
callq 0xcc1c
movl %r13d, 0x110(%rsp)
movb $0x0, 0x114(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
movl 0x4(%rsp), %r14d
je 0x1692f
callq 0x52a0
leaq 0xe0(%rsp), %rsi
movb $0x1, 0x34(%rsi)
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x18176
movl $0x2, 0x30(%rbx)
movl %r14d, 0x34(%rbx)
movl $0x30, %edi
callq 0x52e0
movq %rax, %r15
movq %rax, %rdi
callq 0x12fb2
movq %r15, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
cmpb $0x1, 0x8b(%r12)
jne 0x169bb
movl $0x30, %edi
callq 0x52e0
movq %rax, %r15
movl 0x8c(%r12), %esi
movl 0x90(%r12), %edx
movq %rax, %rdi
movl $0x1, %ecx
callq 0x2925c
movq %r15, 0x28(%rbx)
movq $0x0, 0x68(%rbx)
cmpl $0x0, 0x34(%rbx)
je 0x16a3b
xorl %ebp, %ebp
leaq 0x150(%rsp), %r14
leaq 0x70(%rsp), %r12
movl $0x28, %edi
callq 0x52e0
movq %rax, %r15
movq %r14, %rdi
movq %r12, %rsi
callq 0x181e0
movb $0x1, %r13b
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1e9f0
movq %r15, 0x48(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x16a1c
movq %r15, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x16a2c
xorl %r13d, %r13d
movq %rbx, %rdi
leaq 0x48(%rsp), %rdx
callq 0x1871c
movq %r14, %rdi
callq 0x18272
incl %ebp
cmpl 0x34(%rbx), %ebp
jb 0x169d8
movl $0x28, %edi
callq 0x52e0
movq %rax, %r15
leaq 0xc8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x181e0
leaq 0xc8(%rsp), %rdx
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rbx, %rcx
callq 0x1e9f0
movq %r15, 0x18(%rbx)
leaq 0xc8(%rsp), %rdi
callq 0x18272
movl $0x5, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0x18272
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x16ac9
callq 0x52a0
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x16ae3
callq 0x52a0
leaq 0x70(%rsp), %rdi
callq 0x18272
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x16b01
callq 0x52a0
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16b29
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0x18272
jmp 0x16b93
jmp 0x16b29
movq %rax, %r14
jmp 0x16b93
movq %rax, %r14
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
jmp 0x16bb8
jmp 0x16b3f
movq %rax, %r14
jmp 0x16bc2
jmp 0x16b46
movq %rax, %r14
jmp 0x16bdc
movq %rax, %r14
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
jne 0x16bf5
jmp 0x16bfa
movq %rax, %r14
jmp 0x16bfa
jmp 0x16b71
movq %rax, %r14
jmp 0x16b9b
movq %rax, %r14
movb $0x1, %r13b
jmp 0x16b8e
movq %rax, %r14
leaq 0x150(%rsp), %rdi
callq 0x18272
testb %r13b, %r13b
je 0x16b9b
movq %r15, %rdi
callq 0x52a0
leaq 0xb0(%rsp), %rdi
callq 0x18272
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x16bc2
callq 0x52a0
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x16bdc
callq 0x52a0
leaq 0x70(%rsp), %rdi
callq 0x18272
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x16bfa
callq 0x52a0
movq 0x38(%rbx), %rdi
cmpq 0x40(%rsp), %rdi
je 0x16c0a
callq 0x52a0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x16c17
callq 0x52a0
movq %r14, %rdi
callq 0x55a0
nop