// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/Processor.cpp
// Function: ramulator::Core::Core(ramulator::Config const&, int, char const*, std::function<bool (ramulator::Request)>, ramulator::Cache*, std::shared_ptr<ramulator::CacheSystem>, ramulator::MemoryBase&)
Core::Core(const Config& configs, int coreid,
    const char* trace_fname, function<bool(Request)> send_next,
    Cache* llc, std::shared_ptr<CacheSystem> cachesys, MemoryBase& memory)
    : id(coreid), no_core_caches(!configs.has_core_caches()),
    no_shared_cache(!configs.has_l3_cache()),
    llc(llc), trace(trace_fname), memory(memory)
{
  // set expected limit instruction for calculating weighted speedup
  expected_limit_insts = configs.get_expected_limit_insts();
  trace.expected_limit_insts = expected_limit_insts;

  // Build cache hierarchy
  if (no_core_caches) {
    send = send_next;
  } else {
    // L2 caches[0]
    caches.emplace_back(new Cache(
        l2_size, l2_assoc, l2_blocksz, l2_mshr_num,
        Cache::Level::L2, cachesys));
    // L1 caches[1]
    caches.emplace_back(new Cache(
        l1_size, l1_assoc, l1_blocksz, l1_mshr_num,
        Cache::Level::L1, cachesys));
    send = bind(&Cache::send, caches[1].get(), placeholders::_1);
    if (llc != nullptr) {
      caches[0]->concatlower(llc);
    }
    caches[1]->concatlower(caches[0].get());

    first_level_cache = caches[1].get();
  }
  if (no_core_caches) {
    more_reqs = trace.get_filtered_request(
        bubble_cnt, req_addr, req_type);
    req_addr = memory.page_allocator(req_addr, id);
  } else {
    more_reqs = trace.get_unfiltered_request(
        bubble_cnt, req_addr, req_type);
    req_addr = memory.page_allocator(req_addr, id);
  }

  
  // regStats
  record_cycs.name("record_cycs_core_" + to_string(id))
             .desc("Record cycle number for calculating weighted speedup. (Only valid when expected limit instruction number is non zero in config file.)")
             .precision(0)
             ;

  record_insts.name("record_insts_core_" + to_string(id))
              .desc("Retired instruction number when record cycle number. (Only valid when expected limit instruction number is non zero in config file.)")
              .precision(0)
              ;

  memory_access_cycles.name("memory_access_cycles_core_" + to_string(id))
                      .desc("memory access cycles in memory time domain")
                      .precision(0)
                      ;
  memory_access_cycles = 0;
  cpu_inst.name("cpu_instructions_core_" + to_string(id))
          .desc("cpu instruction number")
          .precision(0)
          ;
  cpu_inst = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, %rbp
movq %r8, %r15
movq %rcx, %r12
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movl %edx, 0x10(%rdi)
leaq 0x18(%rdi), %r13
movups %xmm0, 0x18(%rdi)
movups %xmm0, 0x28(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x48(%rdi)
movq %rsi, %rdi
callq 0xbb646
xorb $0x1, %al
movb %al, 0x58(%rbx)
movq %r14, %rdi
callq 0xbb712
xorb $0x1, %al
movb %al, 0x59(%rbx)
movaps 0x27292(%rip), %xmm0    # 0xe1a70
movups %xmm0, 0x5c(%rbx)
movaps 0x27297(%rip), %xmm0    # 0xe1a80
movups %xmm0, 0x6c(%rbx)
leaq 0x80(%rbx), %rax
movq %rax, 0x60(%rsp)
andq $0x0, 0x90(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%rbx)
movq %rbp, 0x80(%rsp)
movq %rbp, 0x98(%rbx)
leaq 0xa0(%rbx), %rbp
movq %rbp, %rdi
callq 0x186fa
leaq 0x138(%rbx), %rdi
movq %rdi, 0x70(%rsp)
callq 0x186fa
movb $0x0, 0x1d8(%rbx)
leaq 0x1e0(%rbx), %rdi
movq %rdi, 0x58(%rsp)
movq %r12, %rsi
callq 0xbb470
leaq 0x410(%rbx), %rdi
movq %rdi, 0x78(%rsp)
callq 0xbb9c4
orq $-0x1, 0x470(%rbx)
leaq 0x490(%rbx), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x480(%rbx)
movq %r12, %rdi
callq 0x186fa
leaq 0x528(%rbx), %rdi
movq %rdi, 0x68(%rsp)
callq 0x186fa
movq 0x1e8(%rsp), %rax
movq %rax, 0x5c0(%rbx)
movq 0x48(%r14), %rax
movq %rax, 0x1d0(%rbx)
movq %rax, 0x1e0(%rbx)
cmpb $0x1, 0x58(%rbx)
jne 0xba8cf
movq %r13, %rdi
movq %r15, %rsi
callq 0xbba2c
jmp 0xbaa54
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movl $0x6f0, %edi            # imm = 0x6F0
callq 0xb2d0
movq %rax, %r15
movq 0x1e0(%rsp), %rsi
movl 0x6c(%rbx), %r12d
movl 0x70(%rbx), %ebp
movl 0x74(%rbx), %r14d
movl 0x78(%rbx), %r13d
leaq 0x98(%rsp), %rdi
callq 0x9ba06
movb $0x1, %al
movl %eax, 0x34(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, (%rsp)
pushq $0x1
popq %r9
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl %r14d, %ecx
movl %r13d, %r8d
movq 0x60(%rsp), %r14
callq 0x9a1ac
leaq 0x38(%rsp), %rsi
movq %r15, (%rsi)
movl $0x0, 0x34(%rsp)
movq %r14, %rdi
callq 0xbba7a
leaq 0xa0(%rsp), %rdi
callq 0x2248c
movl $0x6f0, %edi            # imm = 0x6F0
callq 0xb2d0
movq %rax, %r15
movl 0x5c(%rbx), %ebp
movl 0x60(%rbx), %r14d
movl 0x64(%rbx), %r12d
movl 0x68(%rbx), %r13d
leaq 0x88(%rsp), %rdi
movq 0x1e0(%rsp), %rsi
callq 0x9ba06
movb $0x1, %al
movl %eax, 0x34(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
xorl %r9d, %r9d
movq 0x60(%rsp), %r14
callq 0x9a1ac
leaq 0x38(%rsp), %rsi
movq %r15, (%rsi)
movl $0x0, 0x34(%rsp)
movq %r14, %rdi
callq 0xbba7a
leaq 0x90(%rsp), %rdi
callq 0x2248c
movq (%r14), %rax
movq 0x10(%rax), %rax
leaq -0x1fce9(%rip), %rcx    # 0x9ad0a
leaq 0x38(%rsp), %rsi
movq %rcx, (%rsi)
andq $0x0, 0x8(%rsi)
movq %rax, 0x10(%rsi)
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq 0x20(%rsp), %rbp
movq 0x28(%rsp), %r12
callq 0xbbaba
movq 0x80(%rsp), %rsi
testq %rsi, %rsi
je 0xbaa33
movq (%r14), %rax
movq (%rax), %rdi
callq 0x9b578
movq (%r14), %rax
movq (%rax), %rsi
movq 0x10(%rax), %rdi
callq 0x9b578
movq 0x80(%rbx), %rax
movq 0x10(%rax), %rax
movq %rax, 0x488(%rbx)
leaq 0x470(%rbx), %rdx
leaq 0x468(%rbx), %rsi
leaq 0x478(%rbx), %rcx
cmpb $0x1, 0x58(%rbx)
jne 0xbaa81
movq 0x58(%rsp), %rdi
callq 0xbaf70
movb %al, 0x47c(%rbx)
jmp 0xbaa92
movq 0x58(%rsp), %rdi
callq 0xbb140
movb $0x1, 0x47c(%rbx)
movq 0x470(%rbx), %rsi
movl 0x10(%rbx), %edx
movq 0x1e8(%rsp), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x470(%rbx)
movl 0x10(%rbx), %esi
leaq 0x38(%rsp), %rdi
callq 0x1a923
leaq 0x270f6(%rip), %rsi     # 0xe1bbb
leaq 0x188(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1aea7
leaq 0x188(%rsp), %rsi
movq %rbp, %rdi
callq 0x1a7c6
movq %rax, %r14
leaq 0x270dc(%rip), %rsi     # 0xe1bcd
leaq 0x168(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x10eea
leaq 0x28(%r14), %rdi
leaq 0x168(%rsp), %rsi
callq 0xb1c0
andl $0x0, 0x48(%r14)
leaq 0x168(%rsp), %rdi
callq 0xb568
leaq 0x188(%rsp), %rdi
callq 0xb568
leaq 0x38(%rsp), %rdi
callq 0xb568
movl 0x10(%rbx), %esi
leaq 0x38(%rsp), %rdi
callq 0x1a923
leaq 0x27102(%rip), %rsi     # 0xe1c53
leaq 0x148(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1aea7
leaq 0x148(%rsp), %rsi
movq 0x70(%rsp), %rdi
callq 0x1a7c6
movq %rax, %r14
leaq 0x270e7(%rip), %rsi     # 0xe1c66
leaq 0x128(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x10eea
leaq 0x28(%r14), %rdi
leaq 0x128(%rsp), %rsi
callq 0xb1c0
andl $0x0, 0x48(%r14)
leaq 0x128(%rsp), %rdi
callq 0xb568
leaq 0x148(%rsp), %rdi
callq 0xb568
leaq 0x38(%rsp), %rdi
callq 0xb568
movl 0x10(%rbx), %esi
leaq 0x38(%rsp), %rdi
callq 0x1a923
leaq 0x2710c(%rip), %rsi     # 0xe1ceb
leaq 0x108(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1aea7
leaq 0x108(%rsp), %rsi
movq %r12, %rdi
callq 0x1a7c6
movq %rax, %r14
leaq 0x270fb(%rip), %rsi     # 0xe1d06
leaq 0xe8(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x10eea
leaq 0x28(%r14), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xb1c0
andl $0x0, 0x48(%r14)
leaq 0xe8(%rsp), %rdi
callq 0xb568
leaq 0x108(%rsp), %rdi
callq 0xb568
leaq 0x38(%rsp), %rdi
callq 0xb568
andq $0x0, 0x500(%rbx)
movl 0x10(%rbx), %esi
leaq 0x38(%rsp), %rdi
callq 0x1a923
leaq 0x270be(%rip), %rsi     # 0xe1d31
leaq 0xc8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1aea7
leaq 0xc8(%rsp), %rsi
movq 0x68(%rsp), %rdi
callq 0x1a7c6
movq %rax, %r14
leaq 0x270a7(%rip), %rsi     # 0xe1d48
leaq 0xa8(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x10eea
leaq 0x28(%r14), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xb1c0
andl $0x0, 0x48(%r14)
leaq 0xa8(%rsp), %rdi
callq 0xb568
leaq 0xc8(%rsp), %rdi
callq 0xb568
leaq 0x38(%rsp), %rdi
callq 0xb568
andq $0x0, 0x598(%rbx)
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbaf08
jmp 0xbaf08
jmp 0xbaf08
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0xb568
jmp 0xbad4b
jmp 0xbad39
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
jmp 0xbae31
jmp 0xbae38
jmp 0xbaef9
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0xe8(%rsp), %rdi
callq 0xb568
jmp 0xbad97
jmp 0xbad85
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x108(%rsp), %rdi
jmp 0xbae31
jmp 0xbae38
jmp 0xbaef9
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x128(%rsp), %rdi
callq 0xb568
jmp 0xbade3
jmp 0xbadd1
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x148(%rsp), %rdi
jmp 0xbae31
jmp 0xbae38
jmp 0xbaef9
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x168(%rsp), %rdi
callq 0xb568
jmp 0xbae29
jmp 0xbae17
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x188(%rsp), %rdi
callq 0xb568
jmp 0xbae4a
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0xb568
jmp 0xbaf0b
jmp 0xbaef9
movq %rax, %r14
leaq 0x90(%rsp), %rdi
jmp 0xbae76
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x2248c
cmpb $0x0, 0x34(%rsp)
je 0xbaf0b
movl $0x6f0, %esi            # imm = 0x6F0
movq %r15, %rdi
callq 0xb2e0
jmp 0xbaf0b
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf15
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf1f
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf29
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf33
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf3d
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf47
movq %r13, 0x18(%rsp)
movq %rax, %r14
jmp 0xbaf51
movq %r12, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq %rax, %r14
movq 0x68(%rsp), %rdi
callq 0x186e4
movq 0x28(%rsp), %rdi
callq 0x186e4
movq 0x78(%rsp), %rdi
callq 0x225f4
movq 0x58(%rsp), %rdi
callq 0x2260e
movq 0x70(%rsp), %rdi
callq 0x186e4
movq 0x20(%rsp), %rdi
callq 0x186e4
movq 0x60(%rsp), %rdi
callq 0x2262c
addq $0x38, %rbx
movq %rbx, %rdi
callq 0x96b6a
movq 0x18(%rsp), %rdi
callq 0x96b6a
movq %r14, %rdi
callq 0xb4d0
nop