// File: /workspace/github_cpp_makefile_star2_O2/NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: print_sim_stats(unsigned int, CACHE*)
void print_sim_stats(uint32_t cpu, CACHE *cache)
{
    uint64_t TOTAL_ACCESS = 0, TOTAL_HIT = 0, TOTAL_MISS = 0;

    for (uint32_t i=0; i<NUM_TYPES; i++) {
        TOTAL_ACCESS += cache->sim_access[cpu][i];
        TOTAL_HIT += cache->sim_hit[cpu][i];
        TOTAL_MISS += cache->sim_miss[cpu][i];
    }

    cout << cache->NAME;
    cout << " TOTAL     ACCESS: " << setw(10) << TOTAL_ACCESS << "  HIT: " << setw(10) << TOTAL_HIT << "  MISS: " << setw(10) << TOTAL_MISS << endl;

    cout << cache->NAME;
    cout << " LOAD      ACCESS: " << setw(10) << cache->sim_access[cpu][0] << "  HIT: " << setw(10) << cache->sim_hit[cpu][0] << "  MISS: " << setw(10) << cache->sim_miss[cpu][0] << endl;

    cout << cache->NAME;
    cout << " RFO       ACCESS: " << setw(10) << cache->sim_access[cpu][1] << "  HIT: " << setw(10) << cache->sim_hit[cpu][1] << "  MISS: " << setw(10) << cache->sim_miss[cpu][1] << endl;

    cout << cache->NAME;
    cout << " PREFETCH  ACCESS: " << setw(10) << cache->sim_access[cpu][2] << "  HIT: " << setw(10) << cache->sim_hit[cpu][2] << "  MISS: " << setw(10) << cache->sim_miss[cpu][2] << endl;

    cout << cache->NAME;
    cout << " WRITEBACK ACCESS: " << setw(10) << cache->sim_access[cpu][3] << "  HIT: " << setw(10) << cache->sim_hit[cpu][3] << "  MISS: " << setw(10) << cache->sim_miss[cpu][3] << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
leaq 0x102e8(%rsi), %rax
movq %rax, (%rsp)
movl %edi, %ebp
leaq 0x10308(%rsi), %rax
movq %rax, 0x8(%rsp)
leaq 0x10328(%rsi), %rax
movq %rax, 0x10(%rsp)
shlq $0x5, %rbp
leaq (%rsi,%rbp), %rax
addq $0x10328, %rax          # imm = 0x10328
pushq $-0x20
popq %rcx
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %r15d, %r15d
testq %rcx, %rcx
je 0x6244
addq -0x20(%rax,%rcx), %r15
addq (%rax,%rcx), %r12
addq 0x20(%rax,%rcx), %r13
addq $0x8, %rcx
jmp 0x622b
addq $0x7350, %rbx           # imm = 0x7350
movq 0xfd7e(%rip), %r14      # 0x15fd0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa187(%rip), %rsi      # 0x103eb
movq %r14, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
pushq $0xa
popq %r14
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
leaq 0xa171(%rip), %rsi      # 0x103ff
movq %rax, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
leaq 0xa153(%rip), %rsi      # 0x10407
movq %rax, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0xfcee(%rip), %r15      # 0x15fd0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa13f(%rip), %rsi      # 0x10433
movq %r15, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq (%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rcx, %r12
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa0da(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa0b6(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rcx, %r13
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa0b7(%rip), %rsi      # 0x10447
movq %r15, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa044(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%rsp), %r15
movq 0x8(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa01f(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%r13,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0xfbbb(%rip), %r12      # 0x15fd0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa034(%rip), %rsi      # 0x1045b
movq %r12, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq (%rsp), %r12
movq 0x10(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0x9fa9(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0x9f89(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%r13,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0xfb25(%rip), %r13      # 0x15fd0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0x9fb2(%rip), %rsi      # 0x1046f
movq %r13, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x18(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0x9f17(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x18(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0x9ef7(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%rsp), %rcx
movq 0x18(%rcx,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110