// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]SMLA/src/Main.cpp
// Function: main
int main(int argc, const char *argv[])
{
    if (argc < 2) {
        printf("Usage: %s <configs-file> --mode=cpu,dram [--stats <filename>] <trace-filename1> <trace-filename2>\n"
            "Example: %s ramulator-configs.cfg --mode=cpu cpu.trace cpu.trace\n", argv[0], argv[0]);
        return 0;
    }

    Config configs(argv[1]);

    const std::string& standard = configs["standard"];
    assert(standard != "" || "DRAM standard should be specified.");

    const char *trace_type = strstr(argv[2], "=");
    trace_type++;
    if (strcmp(trace_type, "cpu") == 0) {
      configs.add("trace_type", "CPU");
    } else if (strcmp(trace_type, "dram") == 0) {
      configs.add("trace_type", "DRAM");
    } else {
      printf("invalid trace type: %s\n", trace_type);
      assert(false);
    }

    int trace_start = 3;
    string stats_out;
    if (strcmp(argv[3], "--stats") == 0) {
      Stats::statlist.output(argv[4]);
      stats_out = argv[4];
      trace_start = 5;
    } else {
      Stats::statlist.output(standard+".stats");
      stats_out = standard + string(".stats");
    }
    std::vector<const char*> files(&argv[trace_start], &argv[argc]);
    configs.set_core_num(argc - trace_start);

		if (standard == "WideIO") {
      WideIO* wio = new WideIO(configs["org"], configs["speed"]);
      start_run(configs, wio, files);
    } 
		else if (standard == "SMLA_CIO") {
      SMLA_CIO* scio = new SMLA_CIO(configs["org"], configs["speed"]);
      start_run(configs, scio, files);
    }
		else if (standard == "SMLA_DIO") {
      SMLA_DIO* sdio = new SMLA_DIO(configs["org"], configs["speed"]);
      start_run(configs, sdio, files);
    }

    printf("Simulation done. Statistics written to %s\n", stats_out.c_str());

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %r14
cmpl $0x1, %edi
jg 0x651e
movq (%r14), %rdx
leaq 0x47bb1(%rip), %rdi     # 0x4e0c0
movq %rdx, %rsi
xorl %eax, %eax
callq 0x5060
jmp 0x6d02
movl %edi, %ebx
movq 0x8(%r14), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6f4c
leaq 0xf8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x3e068
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x656c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47be7(%rip), %rsi     # 0x4e164
leaq 0x47be8(%rip), %rdx     # 0x4e16c
leaq 0x20(%rsp), %rdi
callq 0x80e0
leaq 0x80(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x6f8a
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x65bf
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x47cbe(%rip), %rsi     # 0x4e284
leaq 0x80(%rsp), %rdi
callq 0x50f0
movq 0x10(%r14), %rdi
movl $0x3d, %esi
callq 0x5140
movq %rax, %r15
incq %r15
leaq 0x47ba9(%rip), %rsi     # 0x4e197
movq %r15, %rdi
callq 0x5380
testl %eax, %eax
je 0x6662
leaq 0x47ba9(%rip), %rsi     # 0x4e1aa
movq %r15, %rdi
callq 0x5380
testl %eax, %eax
jne 0x6d16
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x47b7b(%rip), %rsi     # 0x4e19b
leaq 0x47b7e(%rip), %rdx     # 0x4e1a5
callq 0x80e0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x48a8e(%rip), %rsi     # 0x4f0ca
leaq 0x48a8b(%rip), %rdx     # 0x4f0ce
movq %rsp, %rdi
callq 0x80e0
leaq 0xf8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x6ff6
jmp 0x66b1
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x47b2a(%rip), %rsi     # 0x4e19b
leaq 0x47b2d(%rip), %rdx     # 0x4e1a5
callq 0x80e0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x47b19(%rip), %rsi     # 0x4e1a6
leaq 0x47b15(%rip), %rdx     # 0x4e1a9
movq %rsp, %rdi
callq 0x80e0
leaq 0xf8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x6ff6
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x66c7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x66de
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
movq %r12, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq 0x18(%r14), %rdi
leaq 0x47ad1(%rip), %rsi     # 0x4e1cd
callq 0x5380
testl %eax, %eax
je 0x67e7
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x7cf4
leaq 0x47a99(%rip), %rsi     # 0x4e1d5
leaq 0xd8(%rsp), %rdi
callq 0x5500
leaq 0x5fc80(%rip), %rdi     # 0x663d0
leaq 0xd8(%rsp), %rsi
callq 0x70aa
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x677a
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47a4a(%rip), %rsi     # 0x4e1d5
leaq 0x47a49(%rip), %rdx     # 0x4e1db
leaq 0x40(%rsp), %rdi
callq 0x80e0
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5310
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6860
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x6868
movq 0x20(%r14), %rsi
leaq 0x148(%rsp), %rdi
movq %rsp, %rdx
callq 0x6f4c
leaq 0x5fbce(%rip), %rdi     # 0x663d0
leaq 0x148(%rsp), %rsi
callq 0x70aa
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6830
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x20(%r14), %r15
leaq 0x20(%rsp), %r12
movq 0x8(%r12), %r13
movq %r15, %rdi
callq 0x5170
movl $0x5, %ebp
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x53f0
jmp 0x68c0
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rsp, %r15
movq %rdx, 0x8(%r15)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x5350
movq (%r15), %rdi
cmpq %r13, %rdi
je 0x68a4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x68bb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
movl $0x3, %ebp
movl %ebp, %eax
leaq (%r14,%rax,8), %rsi
movl %ebx, %eax
leaq (%r14,%rax,8), %rdx
leaq 0xc0(%rsp), %rdi
movq %rsp, %rcx
callq 0x70f0
subl %ebp, %ebx
movl %ebx, 0x13c(%rsp)
leaq 0x478f0(%rip), %rsi     # 0x4e1dc
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x6a57
leaq 0x478e5(%rip), %rsi     # 0x4e1ed
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
leaq 0x30(%rsp), %rbx
je 0x6b75
leaq 0x478cd(%rip), %rsi     # 0x4e1f6
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
jne 0x6c89
movl $0x2780, %edi           # imm = 0x2780
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x47888(%rip), %rsi     # 0x4e1e3
leaq 0x47884(%rip), %rdx     # 0x4e1e6
leaq 0x40(%rsp), %rdi
callq 0x80e0
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f8a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47855(%rip), %rsi     # 0x4e1e7
leaq 0x47853(%rip), %rdx     # 0x4e1ec
leaq 0x60(%rsp), %rdi
callq 0x80e0
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f8a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x48202
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69f1
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6a08
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6a23
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a3a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x78a5
jmp 0x6c89
movl $0x2780, %edi           # imm = 0x2780
leaq 0x30(%rsp), %rbx
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4776a(%rip), %rsi     # 0x4e1e3
leaq 0x47766(%rip), %rdx     # 0x4e1e6
leaq 0x40(%rsp), %rdi
callq 0x80e0
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f8a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47737(%rip), %rsi     # 0x4e1e7
leaq 0x47735(%rip), %rdx     # 0x4e1ec
leaq 0x60(%rsp), %rdi
callq 0x80e0
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f8a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x4c3e2
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6b0f
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6b26
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6b41
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6b58
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x7131
jmp 0x6c89
movl $0x2780, %edi           # imm = 0x2780
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x47651(%rip), %rsi     # 0x4e1e3
leaq 0x4764d(%rip), %rdx     # 0x4e1e6
leaq 0x40(%rsp), %rdi
callq 0x80e0
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f8a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x4761e(%rip), %rsi     # 0x4e1e7
leaq 0x4761c(%rip), %rdx     # 0x4e1ec
leaq 0x60(%rsp), %rdi
callq 0x80e0
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f8a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x44720
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6c28
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6c3f
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6c5a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6c71
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x74eb
movq 0x20(%rsp), %rsi
leaq 0x4756a(%rip), %rdi     # 0x4e1ff
xorl %eax, %eax
callq 0x5060
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x6cb9
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6cd0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6cf5
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
callq 0x8084
xorl %eax, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47492(%rip), %rdi     # 0x4e1af
movq %r15, %rsi
xorl %eax, %eax
callq 0x5060
leaq 0x47499(%rip), %rdi     # 0x4e1c7
leaq 0x47438(%rip), %rsi     # 0x4e16d
leaq 0x4743e(%rip), %rcx     # 0x4e17a
movl $0x8f, %edx
callq 0x51f0
jmp 0x6d65
jmp 0x6d8b
jmp 0x6da7
jmp 0x6dc7
jmp 0x6de3
jmp 0x6d65
jmp 0x6d8b
jmp 0x6da7
jmp 0x6dc7
jmp 0x6de3
jmp 0x6e8b
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6d8e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6d8e
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6daa
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6daa
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6dca
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6dca
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6de6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6de6
movq %rax, %rbx
movl $0x2780, %esi           # imm = 0x2780
movq %r14, %rdi
callq 0x52d0
jmp 0x6e8e
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6eb2
movq 0x158(%rsp), %rsi
jmp 0x6e57
jmp 0x6eaf
jmp 0x6e5c
jmp 0x6e77
jmp 0x6e86
jmp 0x6e8b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x6eb2
movq 0x50(%rsp), %rsi
jmp 0x6e57
jmp 0x6eaf
jmp 0x6e3f
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6eb2
movq 0xe8(%rsp), %rsi
incq %rsi
jmp 0x6ea6
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x6e7a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6e7a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
jne 0x6ec1
jmp 0x6ece
movq %rax, %rbx
jmp 0x6ece
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x6eb2
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x6eb2
jmp 0x6eaf
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6ece
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6ef3
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
callq 0x8084
movq %rbx, %rdi
callq 0x54c0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x6ef3
movq 0x30(%rsp), %rsi
jmp 0x6eeb
movq %rax, %rbx
jmp 0x6ef3
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f00
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6f00
movq %rax, %rbx
jmp 0x6f00