// File: 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
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdx, -0x1e0(%rbp)
movq %rcx, -0x1f8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
movq %rdi, %rax
movq %rax, -0x1f0(%rbp)
callq 0x1fa2b0
movq -0x1e8(%rbp), %rax
movq -0x1e0(%rbp), %rdi
addq $0x18, %rax
movq %rax, -0x1d8(%rbp)
callq 0x25250
movq %rax, -0x1d0(%rbp)
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, -0x30(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x27640
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rcx
leaq -0x30(%rbp), %rdx
callq 0x27660
jmp 0x1f6eca
leaq -0x31(%rbp), %rdi
callq 0x276e0
movq -0x1f0(%rbp), %rax
movq $0x0, 0x30(%rax)
addq $0x38, %rax
movq %rax, -0x208(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4a000
movb %al, -0x1f9(%rbp)
jmp 0x1f6efe
movq -0x1f0(%rbp), %rax
movq -0x208(%rbp), %rcx
movb -0x1f9(%rbp), %dl
andb $0x1, %dl
movb %dl, (%rcx)
addq $0x39, %rax
movq %rax, -0x218(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1fa2d0
movb %al, -0x209(%rbp)
jmp 0x1f6f33
movq -0x1f0(%rbp), %rax
movq -0x218(%rbp), %rcx
movb -0x209(%rbp), %dl
notb %dl
andb $0x1, %dl
movb %dl, (%rcx)
addq $0x3a, %rax
movq %rax, -0x228(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1fa4e0
movb %al, -0x219(%rbp)
jmp 0x1f6f6a
movq -0x1f0(%rbp), %rax
movq -0x228(%rbp), %rcx
movb -0x219(%rbp), %dl
notb %dl
andb $0x1, %dl
movb %dl, (%rcx)
movl $0x800000, 0x3c(%rax)   # imm = 0x800000
movl $0x8, 0x40(%rax)
movl $0x40, 0x44(%rax)
movl $0x10, 0x48(%rax)
addq $0x50, %rax
movq %rax, -0x238(%rbp)
movl $0x60, %edi
callq 0xc360
movq %rax, -0x230(%rbp)
jmp 0x1f6fbf
movq -0x1f8(%rbp), %rsi
movb $0x1, -0x69(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x1fa6f0
jmp 0x1f6fe0
movq -0x240(%rbp), %rsi
movq -0x230(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x1fa7a0
jmp 0x1f6ff9
movq -0x230(%rbp), %rsi
movq -0x238(%rbp), %rdi
movb $0x0, -0x69(%rbp)
callq 0x1fa900
jmp 0x1f7012
leaq -0x68(%rbp), %rdi
callq 0x49f40
movq -0x1e0(%rbp), %rdi
movq -0x1f0(%rbp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, -0x258(%rbp)
movl 0x3c(%rax), %ecx
movl %ecx, -0x250(%rbp)
movl 0x40(%rax), %ecx
movl %ecx, -0x24c(%rbp)
movl 0x44(%rax), %ecx
movl %ecx, -0x248(%rbp)
movl 0x48(%rax), %eax
movl %eax, -0x264(%rbp)
callq 0x25250
movq -0x1f0(%rbp), %rsi
movq %rax, %rcx
movl -0x264(%rbp), %eax
imull %ecx, %eax
movl %eax, -0x244(%rbp)
addq $0x50, %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x17ff90
movq -0x260(%rbp), %r9
movq -0x258(%rbp), %rdi
movl -0x250(%rbp), %esi
movl -0x24c(%rbp), %edx
movl -0x248(%rbp), %ecx
movl -0x244(%rbp), %r8d
movq %rsp, %rax
movq %r9, (%rax)
movl $0x2, %r9d
callq 0x17bfa0
jmp 0x1f70c7
leaq -0x80(%rbp), %rdi
callq 0x4b1e0
movq -0x1f0(%rbp), %rdi
addq $0x750, %rdi            # imm = 0x750
movq %rdi, -0x270(%rbp)
callq 0x25e50
jmp 0x1f70ec
movq -0x1f0(%rbp), %rdi
addq $0x50, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1fa930
testb $0x1, %al
jne 0x1f7106
jmp 0x1f710b
jmp 0x1f71c1
leaq 0x69e8e(%rip), %rdi     # 0x260fa0
leaq 0x69e9b(%rip), %rsi     # 0x260fb4
movl $0x14, %edx
leaq 0x69ea1(%rip), %rcx     # 0x260fc6
callq 0xc280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x276e0
jmp 0x1f787d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7871
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7178
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x49f40
testb $0x1, -0x69(%rbp)
jne 0x1f7180
jmp 0x1f7191
movq -0x230(%rbp), %rdi
movl $0x60, %esi
callq 0xc370
jmp 0x1f7871
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4b1e0
jmp 0x1f7865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7859
movq -0x1e0(%rbp), %rdi
callq 0x25250
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jle 0x1f71de
jmp 0x1f71fd
leaq 0x69e4f(%rip), %rdi     # 0x261034
leaq 0x69dc8(%rip), %rsi     # 0x260fb4
movl $0x16, %edx
leaq 0x69dce(%rip), %rcx     # 0x260fc6
callq 0xc280
movl -0x84(%rbp), %esi
leaq 0x69e37(%rip), %rdi     # 0x261041
xorl %eax, %eax
callq 0xc070
jmp 0x1f7213
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x1f7283
movq -0x1e0(%rbp), %rdi
movl -0x88(%rbp), %eax
movl %eax, -0x274(%rbp)
movslq %eax, %rsi
callq 0x1fa960
movl -0x274(%rbp), %esi
movq (%rax), %rdx
leaq 0x69df9(%rip), %rdi     # 0x26104f
xorl %eax, %eax
callq 0xc070
jmp 0x1f725f
jmp 0x1f7261
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x1f721d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f784d
movq -0x1f0(%rbp), %rax
testb $0x1, 0x3a(%rax)
je 0x1f742c
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x1f7427
movq -0x1f0(%rbp), %rax
movq %rax, -0x288(%rbp)
movl $0x5c8, %edi            # imm = 0x5C8
callq 0xc360
movq %rax, -0x280(%rbp)
jmp 0x1f72d1
movq -0x1e0(%rbp), %rdi
movb $0x1, -0xc9(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x294(%rbp)
movslq %eax, %rsi
callq 0x1fa960
movq -0x1f8(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x290(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x1fa6f0
jmp 0x1f731d
movq -0x1f0(%rbp), %rsi
addq $0x50, %rsi
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x17ff90
movq -0x2a8(%rbp), %r8
movq -0x280(%rbp), %rdi
movq -0x2a0(%rbp), %rsi
movl -0x294(%rbp), %edx
movq -0x290(%rbp), %rcx
movq -0x28(%rbp), %r9
movq %rsp, %rax
movq %r9, 0x8(%rax)
movq %r8, (%rax)
xorl %eax, %eax
movl %eax, %r9d
leaq -0xb8(%rbp), %r8
callq 0x1f8880
jmp 0x1f737e
movq -0x288(%rbp), %rdi
movq -0x280(%rbp), %rax
movb $0x0, -0xc9(%rbp)
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x1fa980
jmp 0x1f73a8
leaq -0xc8(%rbp), %rdi
callq 0x4b1e0
leaq -0xb8(%rbp), %rdi
callq 0x49f40
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x1f729e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7406
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4b1e0
leaq -0xb8(%rbp), %rdi
callq 0x49f40
testb $0x1, -0xc9(%rbp)
jne 0x1f7411
jmp 0x1f7422
movq -0x280(%rbp), %rdi
movl $0x5c8, %esi            # imm = 0x5C8
callq 0xc370
jmp 0x1f784d
jmp 0x1f7622
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x1f7620
movq -0x1f0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movl $0x5c8, %edi            # imm = 0x5C8
callq 0xc360
movq %rax, -0x2b0(%rbp)
jmp 0x1f7469
movq -0x1e0(%rbp), %rdi
movb $0x1, -0x139(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0x2c4(%rbp)
movslq %eax, %rsi
callq 0x1fa960
movq %rax, %rcx
movq -0x1f0(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x2c0(%rbp)
leaq -0x79e81(%rip), %rcx    # 0x17d630
movq %rcx, -0x120(%rbp)
movq $0x0, -0x118(%rbp)
addq $0x60, %rax
movq %rax, -0x128(%rbp)
movq 0x156ae3(%rip), %rcx    # 0x34dfb8
leaq -0x110(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0x1faa00
jmp 0x1f74f1
leaq -0xf8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x1faa40
jmp 0x1f7506
movq -0x1f0(%rbp), %rsi
movq %rsi, %rax
addq $0x60, %rax
movq %rax, -0x2d8(%rbp)
addq $0x50, %rsi
leaq -0x138(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x17ff90
movq -0x2e0(%rbp), %r8
movq -0x2b0(%rbp), %rdi
movq -0x2d0(%rbp), %rsi
movl -0x2c4(%rbp), %edx
movq -0x2c0(%rbp), %rcx
movq -0x2d8(%rbp), %r9
movq -0x28(%rbp), %r10
movq %rsp, %rax
movq %r10, 0x8(%rax)
movq %r8, (%rax)
leaq -0xf8(%rbp), %r8
callq 0x1f8880
jmp 0x1f7577
movq -0x2b8(%rbp), %rdi
movq -0x2b0(%rbp), %rax
movb $0x0, -0x139(%rbp)
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x1fa980
jmp 0x1f75a1
leaq -0x138(%rbp), %rdi
callq 0x4b1e0
leaq -0xf8(%rbp), %rdi
callq 0x49f40
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x1f7436
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f75ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x4b1e0
leaq -0xf8(%rbp), %rdi
callq 0x49f40
testb $0x1, -0x139(%rbp)
jne 0x1f760a
jmp 0x1f761b
movq -0x2b0(%rbp), %rdi
movl $0x5c8, %esi            # imm = 0x5C8
callq 0xc370
jmp 0x1f784d
jmp 0x1f7622
movl $0x0, -0x140(%rbp)
movl -0x140(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x1f76ce
movq -0x1f0(%rbp), %rax
leaq 0x254(%rip), %rcx       # 0x1f78a0
movq %rcx, -0x168(%rbp)
movq $0x0, -0x160(%rbp)
movq %rax, -0x170(%rbp)
movq 0x15694c(%rip), %rcx    # 0x34dfb8
leaq -0x158(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x170(%rbp), %rdx
callq 0x1faae0
jmp 0x1f7688
movq -0x1f0(%rbp), %rdi
movslq -0x140(%rbp), %rsi
callq 0x49fa0
movq %rax, %rdi
callq 0x49fc0
movq %rax, %rdi
addq $0x38, %rdi
leaq -0x158(%rbp), %rsi
callq 0x1fab20
jmp 0x1f76b8
jmp 0x1f76ba
movl -0x140(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x140(%rbp)
jmp 0x1f762c
movq -0x1f0(%rbp), %rax
addq $0x750, %rax            # imm = 0x750
movq %rax, -0x2f0(%rbp)
leaq -0x191(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0xc5e0
movq -0x2e8(%rbp), %rdx
leaq 0x69960(%rip), %rsi     # 0x261063
leaq -0x190(%rbp), %rdi
callq 0x17a40
jmp 0x1f7711
movq -0x2f0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x2c990
movq %rax, -0x2f8(%rbp)
jmp 0x1f772d
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0xc5e0
movq -0x300(%rbp), %rdx
leaq 0x69920(%rip), %rsi     # 0x26106e
leaq -0x1b8(%rbp), %rdi
callq 0x17a40
jmp 0x1f775c
movq -0x2f8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x2cd70
movq %rax, -0x308(%rbp)
jmp 0x1f7778
movq -0x308(%rbp), %rdi
xorl %esi, %esi
callq 0x2cda0
jmp 0x1f7788
leaq -0x1b8(%rbp), %rdi
callq 0xc6b8
leaq -0x1b9(%rbp), %rdi
callq 0xc3c0
leaq -0x190(%rbp), %rdi
callq 0xc6b8
leaq -0x191(%rbp), %rdi
callq 0xc3c0
movq -0x1f0(%rbp), %rdi
movl $0x0, -0x1c0(%rbp)
addq $0x750, %rdi            # imm = 0x750
leaq -0x1c0(%rbp), %rsi
callq 0x1fab70
jmp 0x1f77de
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7841
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7835
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f7829
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0xc6b8
leaq -0x1b9(%rbp), %rdi
callq 0xc3c0
leaq -0x190(%rbp), %rdi
callq 0xc6b8
leaq -0x191(%rbp), %rdi
callq 0xc3c0
movq -0x270(%rbp), %rdi
callq 0x262b0
movq -0x258(%rbp), %rdi
callq 0x4b0d0
movq -0x238(%rbp), %rdi
callq 0x4b1e0
movq -0x1d8(%rbp), %rdi
callq 0x2e600
movq -0x1e8(%rbp), %rdi
callq 0x4b200
movq -0x40(%rbp), %rdi
callq 0xc5d0
nopw %cs:(%rax,%rax)