// File: /workspace/github_cpp_makefile_star2_O3/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 0x650e
movq (%r14), %rdx
leaq 0x47bf1(%rip), %rdi     # 0x4e0f0
movq %rdx, %rsi
xorl %eax, %eax
callq 0x5060
jmp 0x6cf2
movl %edi, %ebx
movq 0x8(%r14), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6f3c
leaq 0xf8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x3d9f8
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x655c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47c27(%rip), %rsi     # 0x4e194
leaq 0x47c28(%rip), %rdx     # 0x4e19c
leaq 0x20(%rsp), %rdi
callq 0x80d6
leaq 0x80(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x6f7a
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x65af
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x47cfe(%rip), %rsi     # 0x4e2b4
leaq 0x80(%rsp), %rdi
callq 0x50f0
movq 0x10(%r14), %rdi
movl $0x3d, %esi
callq 0x5140
movq %rax, %r15
incq %r15
leaq 0x47be9(%rip), %rsi     # 0x4e1c7
movq %r15, %rdi
callq 0x5380
testl %eax, %eax
je 0x6652
leaq 0x47be9(%rip), %rsi     # 0x4e1da
movq %r15, %rdi
callq 0x5380
testl %eax, %eax
jne 0x6d06
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x47bbb(%rip), %rsi     # 0x4e1cb
leaq 0x47bbe(%rip), %rdx     # 0x4e1d5
callq 0x80d6
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x48ace(%rip), %rsi     # 0x4f0fa
leaq 0x48acb(%rip), %rdx     # 0x4f0fe
movq %rsp, %rdi
callq 0x80d6
leaq 0xf8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x6fe6
jmp 0x66a1
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x47b6a(%rip), %rsi     # 0x4e1cb
leaq 0x47b6d(%rip), %rdx     # 0x4e1d5
callq 0x80d6
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x47b59(%rip), %rsi     # 0x4e1d6
leaq 0x47b55(%rip), %rdx     # 0x4e1d9
movq %rsp, %rdi
callq 0x80d6
leaq 0xf8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x6fe6
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x66b7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x66ce
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 0x47b11(%rip), %rsi     # 0x4e1fd
callq 0x5380
testl %eax, %eax
je 0x67d7
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x7ce4
leaq 0x47ad9(%rip), %rsi     # 0x4e205
leaq 0xd8(%rsp), %rdi
callq 0x5500
leaq 0x5fc90(%rip), %rdi     # 0x663d0
leaq 0xd8(%rsp), %rsi
callq 0x709a
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x676a
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47a8a(%rip), %rsi     # 0x4e205
leaq 0x47a89(%rip), %rdx     # 0x4e20b
leaq 0x40(%rsp), %rdi
callq 0x80d6
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 0x6850
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x6858
movq 0x20(%r14), %rsi
leaq 0x148(%rsp), %rdi
movq %rsp, %rdx
callq 0x6f3c
leaq 0x5fbde(%rip), %rdi     # 0x663d0
leaq 0x148(%rsp), %rsi
callq 0x709a
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6820
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 0x68b0
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 0x6894
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x68ab
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 0x70e0
subl %ebp, %ebx
movl %ebx, 0x13c(%rsp)
leaq 0x47930(%rip), %rsi     # 0x4e20c
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x6a47
leaq 0x47925(%rip), %rsi     # 0x4e21d
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
leaq 0x30(%rsp), %rbx
je 0x6b65
leaq 0x4790d(%rip), %rsi     # 0x4e226
leaq 0x80(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
jne 0x6c79
movl $0x2780, %edi           # imm = 0x2780
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x478c8(%rip), %rsi     # 0x4e213
leaq 0x478c4(%rip), %rdx     # 0x4e216
leaq 0x40(%rsp), %rdi
callq 0x80d6
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f7a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47895(%rip), %rsi     # 0x4e217
leaq 0x47893(%rip), %rdx     # 0x4e21c
leaq 0x60(%rsp), %rdi
callq 0x80d6
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f7a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x47ae4
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69e1
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x69f8
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6a13
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a2a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x7895
jmp 0x6c79
movl $0x2780, %edi           # imm = 0x2780
leaq 0x30(%rsp), %rbx
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x477aa(%rip), %rsi     # 0x4e213
leaq 0x477a6(%rip), %rdx     # 0x4e216
leaq 0x40(%rsp), %rdi
callq 0x80d6
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f7a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x47777(%rip), %rsi     # 0x4e217
leaq 0x47775(%rip), %rdx     # 0x4e21c
leaq 0x60(%rsp), %rdi
callq 0x80d6
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f7a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x4bbc8
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6aff
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6b16
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6b31
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6b48
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x7121
jmp 0x6c79
movl $0x2780, %edi           # imm = 0x2780
callq 0x52c0
movq %rax, %r14
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x47691(%rip), %rsi     # 0x4e213
leaq 0x4768d(%rip), %rdx     # 0x4e216
leaq 0x40(%rsp), %rdi
callq 0x80d6
movq %rsp, %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x6f7a
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x4765e(%rip), %rsi     # 0x4e217
leaq 0x4765c(%rip), %rdx     # 0x4e21c
leaq 0x60(%rsp), %rdi
callq 0x80d6
leaq 0xa0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x6f7a
movq %rsp, %rsi
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x440a8
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6c18
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6c2f
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6c4a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6c61
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0x74db
movq 0x20(%rsp), %rsi
leaq 0x475aa(%rip), %rdi     # 0x4e22f
xorl %eax, %eax
callq 0x5060
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x6ca9
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6cc0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6ce5
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
callq 0x807a
xorl %eax, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x474d2(%rip), %rdi     # 0x4e1df
movq %r15, %rsi
xorl %eax, %eax
callq 0x5060
leaq 0x474d9(%rip), %rdi     # 0x4e1f7
leaq 0x47478(%rip), %rsi     # 0x4e19d
leaq 0x4747e(%rip), %rcx     # 0x4e1aa
movl $0x8f, %edx
callq 0x51f0
jmp 0x6d55
jmp 0x6d7b
jmp 0x6d97
jmp 0x6db7
jmp 0x6dd3
jmp 0x6d55
jmp 0x6d7b
jmp 0x6d97
jmp 0x6db7
jmp 0x6dd3
jmp 0x6e7b
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6d7e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6d7e
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x6d9a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6d9a
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6dba
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6dba
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x6dd6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6dd6
movq %rax, %rbx
movl $0x2780, %esi           # imm = 0x2780
movq %r14, %rdi
callq 0x52d0
jmp 0x6e7e
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6ea2
movq 0x158(%rsp), %rsi
jmp 0x6e47
jmp 0x6e9f
jmp 0x6e4c
jmp 0x6e67
jmp 0x6e76
jmp 0x6e7b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x6ea2
movq 0x50(%rsp), %rsi
jmp 0x6e47
jmp 0x6e9f
jmp 0x6e2f
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6ea2
movq 0xe8(%rsp), %rsi
incq %rsi
jmp 0x6e96
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x6e6a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6e6a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
jne 0x6eb1
jmp 0x6ebe
movq %rax, %rbx
jmp 0x6ebe
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x6ea2
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x6ea2
jmp 0x6e9f
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x6ebe
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x52d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6ee3
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
leaq 0xf8(%rsp), %rdi
callq 0x807a
movq %rbx, %rdi
callq 0x54c0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x6ee3
movq 0x30(%rsp), %rsi
jmp 0x6edb
movq %rax, %rbx
jmp 0x6ee3
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6ef0
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x52d0
jmp 0x6ef0
movq %rax, %rbx
jmp 0x6ef0