// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/Processor.cpp
// Function: ramulator::Processor::Processor(ramulator::Config const&, std::vector<char const*, std::allocator<char const*>>, std::function<bool (ramulator::Request)>, ramulator::MemoryBase&)
Processor::Processor(const Config& configs,
    vector<const char*> trace_list,
    function<bool(Request)> send_memory,
    MemoryBase& memory)
    : ipcs(trace_list.size(), -1),
    early_exit(configs.is_early_exit()),
    no_core_caches(!configs.has_core_caches()),
    no_shared_cache(!configs.has_l3_cache()),
    cachesys(new CacheSystem(configs, send_memory)),
    llc(l3_size, l3_assoc, l3_blocksz,
         mshr_per_bank * trace_list.size(),
         Cache::Level::L3, cachesys) {

  assert(cachesys != nullptr);
  int tracenum = trace_list.size();
  assert(tracenum > 0);
  printf("tracenum: %d\n", tracenum);
  for (int i = 0 ; i < tracenum ; ++i) {
    printf("trace_list[%d]: %s\n", i, trace_list[i]);
  }
  if (no_shared_cache) {
    for (int i = 0 ; i < tracenum ; ++i) {
      cores.emplace_back(new Core(
          configs, i, trace_list[i], send_memory, nullptr,
          cachesys, memory));
    }
  } else {
    for (int i = 0 ; i < tracenum ; ++i) {
      cores.emplace_back(new Core(configs, i, trace_list[i],
          std::bind(&Cache::send, &llc, std::placeholders::_1),
          &llc, cachesys, memory));
    }
  }
  for (int i = 0 ; i < tracenum ; ++i) {
    cores[i]->callback = std::bind(&Processor::receive, this,
        placeholders::_1);
  }

  // regStats
  cpu_cycles.name("cpu_cycles")
            .desc("cpu cycle number")
            .precision(0)
            ;
  cpu_cycles = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %r8, 0x70(%rsp)
movq %rcx, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
leaq 0x18(%rdi), %rbx
movq 0x8(%rdx), %rsi
movq %rdx, 0x18(%rsp)
subq (%rdx), %rsi
sarq $0x3, %rsi
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
leaq 0x38(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x50(%rsp), %rcx
movq %rbx, %rdi
callq 0x18bf6
andq $0x0, 0x30(%rbp)
movq %r15, %rdi
callq 0x21fcc
movb %al, 0x38(%rbp)
movq %r15, %rdi
callq 0xbb646
xorb $0x1, %al
movb %al, 0x39(%rbp)
movq %r15, %rdi
callq 0xbb712
xorb $0x1, %al
movb %al, 0x3a(%rbp)
movaps 0x27fcc(%rip), %xmm0    # 0xe1a60
movups %xmm0, 0x3c(%rbp)
pushq $0x60
popq %rdi
callq 0xb2d0
movq %rax, %r12
leaq 0xe8(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xbb7de
movq %rbx, 0x8(%rsp)
movb $0x1, %bl
leaq 0xe8(%rsp), %rdx
movq %r12, %rdi
movq %r15, 0x68(%rsp)
movq %r15, %rsi
callq 0xbb824
leaq 0x50(%rbp), %r14
xorl %ebx, %ebx
movq %r14, %rdi
movq %r12, %rsi
callq 0xbbea8
leaq 0xe8(%rsp), %rdi
callq 0x96b6a
leaq 0x60(%rbp), %rbx
movl 0x3c(%rbp), %eax
movl %eax, (%rsp)
movl 0x40(%rbp), %r15d
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r12
subq (%rax), %r12
movl 0x44(%rbp), %r13d
shrq $0x3, %r12
imull 0x48(%rbp), %r12d
leaq 0x88(%rsp), %rdi
movq %r14, 0x30(%rsp)
movq %r14, %rsi
callq 0x9ba06
subq $0x8, %rsp
pushq $0x2
popq %r9
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
movl 0x8(%rsp), %esi
movl %r15d, %edx
movl %r13d, %ecx
movl %r12d, %r8d
leaq 0x90(%rsp), %rax
pushq %rax
callq 0x9a1ac
popq %rax
popq %rcx
leaq 0x90(%rsp), %rdi
callq 0x2248c
leaq 0x750(%rbp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x186fa
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
je 0xb9e70
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rbx
subq (%rax), %rbx
shrq $0x3, %rbx
testl %ebx, %ebx
jle 0xb9e89
leaq 0x27fba(%rip), %rdi     # 0xe1b61
movl %ebx, %esi
xorl %eax, %eax
callq 0xb050
movq %rbx, 0x28(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x27fad(%rip), %r14     # 0xe1b6f
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0xb9be8
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0xb050
incq %r15
jmp 0xb9bc5
movq %rbp, (%rsp)
cmpb $0x0, 0x3a(%rbp)
movq %rbx, 0x60(%rsp)
je 0xb9cb8
xorl %r14d, %r14d
leaq 0x128(%rsp), %r15
movq 0x28(%rsp), %r12
cmpq %r14, %rbx
je 0xb9d98
movl $0x5c8, %edi            # imm = 0x5C8
callq 0xb2d0
movq %rax, %r12
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r14,8), %r13
movq %r15, %rdi
movq 0x20(%rsp), %rsi
callq 0xbb7de
movq %r15, %rbx
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq 0x30(%rsp), %rsi
callq 0x9ba06
movb $0x1, %bpl
movq %r12, %rdi
movq 0x68(%rsp), %rsi
movl %r14d, %edx
movq %r13, %rcx
movq %rbx, %r13
movq %rbx, %r8
xorl %r9d, %r9d
pushq 0x70(%rsp)
pushq %r15
callq 0xba780
popq %rax
popq %rcx
movq %r12, 0x38(%rsp)
xorl %ebp, %ebp
movq (%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xbb8f6
leaq 0xa0(%rsp), %rdi
callq 0x2248c
movq %r13, %r15
movq %r13, %rdi
callq 0x96b6a
incq %r14
movq 0x28(%rsp), %r12
movq 0x60(%rsp), %rbx
jmp 0xb9c0b
xorl %r13d, %r13d
leaq 0x108(%rsp), %rbp
movq 0x28(%rsp), %r12
cmpq %r13, %rbx
je 0xb9d98
movl $0x5c8, %edi            # imm = 0x5C8
callq 0xb2d0
movq %rax, %r14
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %r15
leaq -0x1efe7(%rip), %rax    # 0x9ad0a
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movq 0x10(%rsp), %r12
movq %r12, 0x48(%rsp)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
callq 0xbb92e
leaq 0x78(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x9ba06
movb $0x1, %bl
movq %r14, %rdi
movq 0x68(%rsp), %rsi
movq %r13, 0x20(%rsp)
movl %r13d, %edx
movq %r15, %rcx
movq %rbp, %r15
movq %rbp, %r8
movq %r12, %r9
pushq 0x70(%rsp)
leaq 0x80(%rsp), %rax
pushq %rax
callq 0xba780
popq %rax
popq %rcx
movq %r14, 0x50(%rsp)
xorl %ebx, %ebx
movq (%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xbb8f6
leaq 0x80(%rsp), %rdi
callq 0x2248c
movq %r15, %rbp
movq %r15, %rdi
callq 0x96b6a
movq 0x20(%rsp), %r13
incq %r13
movq 0x28(%rsp), %r12
movq 0x60(%rsp), %rbx
jmp 0xb9cc8
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
leaq 0x248(%rip), %r15       # 0xb9ff0
leaq 0x38(%rsp), %r14
movq (%rsp), %rbp
cmpq %rbx, %r12
je 0xb9ddf
movq %r15, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movq %rbp, 0x48(%rsp)
movq (%rbp), %rax
movq (%rax,%rbx,8), %rdi
addq $0x38, %rdi
movq %r14, %rsi
callq 0xbb976
incq %rbx
jmp 0xb9db1
leaq 0x27d9d(%rip), %rsi     # 0xe1b83
leaq 0xc8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x10eea
leaq 0xc8(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x1a7c6
movq %rax, %r14
leaq 0x27d7a(%rip), %rsi     # 0xe1b8e
leaq 0xa8(%rsp), %rdi
leaq 0x50(%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
andq $0x0, 0x7c0(%rbp)
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27c49(%rip), %rdi     # 0xe1ac0
leaq 0x27c56(%rip), %rsi     # 0xe1ad4
leaq 0x27c61(%rip), %rcx     # 0xe1ae6
pushq $0x14
jmp 0xb9ea0
leaq 0x27cc4(%rip), %rdi     # 0xe1b54
leaq 0x27c3d(%rip), %rsi     # 0xe1ad4
leaq 0x27c48(%rip), %rcx     # 0xe1ae6
pushq $0x16
popq %rdx
callq 0xb210
movq %rax, %r15
leaq 0xa8(%rsp), %rdi
callq 0xb568
jmp 0xb9ebd
jmp 0xb9eba
movq %rax, %r15
leaq 0xc8(%rsp), %rdi
callq 0xb568
jmp 0xb9faf
jmp 0xb9f41
movq %rax, %r15
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
jmp 0xb9fc7
movq %rax, %r15
leaq 0x90(%rsp), %rdi
callq 0x2248c
movq 0x8(%rsp), %rbx
jmp 0xb9fcf
movq %rax, %r15
jmp 0xb9f27
movq %rax, %r15
jmp 0xb9fe0
movq %rax, %r15
leaq 0xe8(%rsp), %rdi
callq 0x96b6a
testb %bl, %bl
movq 0x8(%rsp), %rbx
je 0xb9fd8
pushq $0x60
popq %rsi
movq %r12, %rdi
callq 0xb2e0
jmp 0xb9fd8
movq %rax, %r15
jmp 0xb9fd8
jmp 0xb9f41
movq %rax, %r15
jmp 0xb9faf
movq %rax, %r15
jmp 0xb9f76
movq %rax, %r15
jmp 0xb9fa2
movq %rax, %r15
jmp 0xb9fb3
movq %rax, %r15
leaq 0x80(%rsp), %rdi
callq 0x2248c
leaq 0x108(%rsp), %rdi
callq 0x96b6a
testb %bl, %bl
je 0xb9faf
movl $0x5c8, %esi            # imm = 0x5C8
movq %r14, %rdi
jmp 0xb9faa
movq %rax, %r15
leaq 0xa0(%rsp), %rdi
callq 0x2248c
leaq 0x128(%rsp), %rdi
callq 0x96b6a
testb %bpl, %bpl
je 0xb9faf
movl $0x5c8, %esi            # imm = 0x5C8
movq %r12, %rdi
callq 0xb2e0
movq (%rsp), %rbp
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x58(%rsp), %rdi
callq 0x186e4
movq %r14, %rdi
callq 0x222b2
leaq 0x58(%rbp), %rdi
callq 0x2248c
movq %rbx, %rdi
callq 0x18c78
movq %rbp, %rdi
callq 0x22374
movq %r15, %rdi
callq 0xb4d0