// File: CMU-SAFARI[P]ramulator/src/Main.cpp
// Function: void start_run<ramulator::DDR3>(ramulator::Config const&, ramulator::DDR3*, std::vector<char const*, std::allocator<char const*>> const&)
void start_run(const Config& configs, T* spec, const vector<const char*>& files) {
  // initiate controller and memory
  int C = configs.get_channels(), R = configs.get_ranks();
  // Check and Set channel, rank number
  spec->set_channel_number(C);
  spec->set_rank_number(R);
  std::vector<Controller<T>*> ctrls;
  for (int c = 0 ; c < C ; c++) {
    DRAM<T>* channel = new DRAM<T>(spec, T::Level::Channel);
    channel->id = c;
    channel->regStats("");
    Controller<T>* ctrl = new Controller<T>(configs, channel);
    ctrls.push_back(ctrl);
  }
  Memory<T, Controller> memory(configs, ctrls);

  assert(files.size() != 0);
  if (configs["trace_type"] == "CPU") {
    run_cputrace(configs, memory, files);
  } else if (configs["trace_type"] == "DRAM") {
    run_dramtrace(configs, memory, files[0]);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe00, %rsp            # imm = 0xE00
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1a4e0
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1dc70
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x18d640
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x18d660
leaq -0x38(%rbp), %rdi
callq 0x1dc90
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x18119
movl $0x898, %edi            # imm = 0x898
callq 0xc360
movq %rax, -0xda0(%rbp)
jmp 0x17fb6
movq -0xda0(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x1dcb0
jmp 0x17fca
movq -0xda0(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x39c(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0xdb0(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xda8(%rbp)
callq 0xc5e0
movq -0xda8(%rbp), %rdx
leaq 0x239047(%rip), %rsi    # 0x251052
leaq -0x78(%rbp), %rdi
callq 0x17a40
jmp 0x18016
movq -0xdb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1e2a0
jmp 0x18028
leaq -0x78(%rbp), %rdi
callq 0xc6b8
leaq -0x79(%rbp), %rdi
callq 0xc3c0
movl $0x11e0, %edi           # imm = 0x11E0
callq 0xc360
movq %rax, -0xdb8(%rbp)
jmp 0x1804d
movq -0xdb8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x1f340
jmp 0x18063
movq -0xdb8(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x228e0
jmp 0x18083
jmp 0x18085
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x17f97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x183de
movq -0xda0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x898, %esi            # imm = 0x898
callq 0xc370
jmp 0x183de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x180e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xc6b8
leaq -0x79(%rbp), %rdi
callq 0xc3c0
jmp 0x183de
movq -0xdb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x11e0, %esi           # imm = 0x11E0
callq 0xc370
jmp 0x183de
movq -0x8(%rbp), %rax
movq %rax, -0xdc0(%rbp)
leaq -0xd08(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x22950
jmp 0x18136
movq -0xdc0(%rbp), %rsi
leaq -0xcf0(%rbp), %rdi
leaq -0xd08(%rbp), %rdx
callq 0x22a40
jmp 0x18152
leaq -0xd08(%rbp), %rdi
callq 0x251f0
movq -0x18(%rbp), %rdi
callq 0x25250
cmpq $0x0, %rax
je 0x1816f
jmp 0x181ab
leaq 0x237b83(%rip), %rdi    # 0x24fcf9
leaq 0x23798a(%rip), %rsi    # 0x24fb07
movl $0xaa, %edx
leaq 0x237b82(%rip), %rcx    # 0x24fd0b
callq 0xc280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd08(%rbp), %rdi
callq 0x251f0
jmp 0x183de
movq -0x8(%rbp), %rax
movq %rax, -0xdd0(%rbp)
leaq -0xd49(%rbp), %rdi
movq %rdi, -0xdc8(%rbp)
callq 0xc5e0
movq -0xdc8(%rbp), %rdx
leaq 0x23795e(%rip), %rsi    # 0x24fb35
leaq -0xd48(%rbp), %rdi
callq 0x17a40
jmp 0x181e5
movq -0xdd0(%rbp), %rsi
leaq -0xd28(%rbp), %rdi
leaq -0xd48(%rbp), %rdx
callq 0x17af0
jmp 0x18201
leaq -0xd28(%rbp), %rdi
leaq 0x237931(%rip), %rsi    # 0x24fb40
callq 0x17f10
movb %al, -0xdd1(%rbp)
leaq -0xd28(%rbp), %rdi
callq 0xc6b8
leaq -0xd48(%rbp), %rdi
callq 0xc6b8
leaq -0xd49(%rbp), %rdi
callq 0xc3c0
movb -0xdd1(%rbp), %al
testb $0x1, %al
jne 0x1824a
jmp 0x182ad
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0xcf0(%rbp), %rsi
callq 0x25270
jmp 0x18260
jmp 0x183b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1828b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd48(%rbp), %rdi
callq 0xc6b8
leaq -0xd49(%rbp), %rdi
callq 0xc3c0
jmp 0x183d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x183d2
movq -0x8(%rbp), %rax
movq %rax, -0xde8(%rbp)
leaq -0xd91(%rbp), %rdi
movq %rdi, -0xde0(%rbp)
callq 0xc5e0
movq -0xde0(%rbp), %rdx
leaq 0x23785c(%rip), %rsi    # 0x24fb35
leaq -0xd90(%rbp), %rdi
callq 0x17a40
jmp 0x182e7
movq -0xde8(%rbp), %rsi
leaq -0xd70(%rbp), %rdi
leaq -0xd90(%rbp), %rdx
callq 0x17af0
jmp 0x18303
leaq -0xd70(%rbp), %rdi
leaq 0x2387eb(%rip), %rsi    # 0x250afc
callq 0x17f10
movb %al, -0xde9(%rbp)
leaq -0xd70(%rbp), %rdi
callq 0xc6b8
leaq -0xd90(%rbp), %rdi
callq 0xc6b8
leaq -0xd91(%rbp), %rdi
callq 0xc3c0
movb -0xde9(%rbp), %al
testb $0x1, %al
jne 0x1834c
jmp 0x183b2
movq -0x8(%rbp), %rax
movq %rax, -0xdf8(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x25b10
movq -0xdf8(%rbp), %rdi
movq (%rax), %rdx
leaq -0xcf0(%rbp), %rsi
callq 0x257a0
jmp 0x1837c
jmp 0x183b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x183a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd90(%rbp), %rdi
callq 0xc6b8
leaq -0xd91(%rbp), %rdi
callq 0xc3c0
jmp 0x183d2
jmp 0x183b4
leaq -0xcf0(%rbp), %rdi
callq 0x25b30
leaq -0x38(%rbp), %rdi
callq 0x251f0
addq $0xe00, %rsp            # imm = 0xE00
popq %rbp
retq
leaq -0xcf0(%rbp), %rdi
callq 0x25b30
leaq -0x38(%rbp), %rdi
callq 0x251f0
movq -0x50(%rbp), %rdi
callq 0xc5d0