// File: 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:
subq $0xe8, %rsp
movl %edi, 0xe4(%rsp)
movq %rsi, 0xd8(%rsp)
movq $0x0, 0xd0(%rsp)
movq $0x0, 0xc8(%rsp)
movq $0x0, 0xc0(%rsp)
movl $0x0, 0xbc(%rsp)
cmpl $0x4, 0xbc(%rsp)
jae 0xb57e
movq 0xd8(%rsp), %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xbc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
addq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rax
addq $0x10308, %rax          # imm = 0x10308
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xbc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
addq 0xc8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xd8(%rsp), %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xbc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
addq 0xc0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0xb4b5
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1da3c(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1da30(%rip), %rdi     # 0x28fd0
leaq 0x17dec(%rip), %rsi     # 0x23393
callq 0x3220
movq %rax, 0x8(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x8(%rsp), %rdi
movl %eax, 0xb8(%rsp)
movl 0xb8(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd0(%rsp), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17dba(%rip), %rsi     # 0x233a7
callq 0x3220
movq %rax, 0x10(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x10(%rsp), %rdi
movl %eax, 0xb4(%rsp)
movl 0xb4(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xc8(%rsp), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17d7c(%rip), %rsi     # 0x233af
callq 0x3220
movq %rax, 0x18(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x18(%rsp), %rdi
movl %eax, 0xb0(%rsp)
movl 0xb0(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xc0(%rsp), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1d93f(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1d93c(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1d930(%rip), %rdi     # 0x28fd0
leaq 0x17d34(%rip), %rsi     # 0x233db
callq 0x3220
movq %rax, 0x20(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x20(%rsp), %rdi
movl %eax, 0xac(%rsp)
movl 0xac(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17ca3(%rip), %rsi     # 0x233a7
callq 0x3220
movq %rax, 0x28(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x28(%rsp), %rdi
movl %eax, 0xa8(%rsp)
movl 0xa8(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10308, %rax          # imm = 0x10308
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17c4e(%rip), %rsi     # 0x233af
callq 0x3220
movq %rax, 0x30(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x30(%rsp), %rdi
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1d7fa(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1d7f7(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1d7eb(%rip), %rdi     # 0x28fd0
leaq 0x17c03(%rip), %rsi     # 0x233ef
callq 0x3220
movq %rax, 0x38(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x38(%rsp), %rdi
movl %eax, 0xa0(%rsp)
movl 0xa0(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17b5d(%rip), %rsi     # 0x233a7
callq 0x3220
movq %rax, 0x40(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x40(%rsp), %rdi
movl %eax, 0x9c(%rsp)
movl 0x9c(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10308, %rax          # imm = 0x10308
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17b07(%rip), %rsi     # 0x233af
callq 0x3220
movq %rax, 0x48(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x48(%rsp), %rdi
movl %eax, 0x98(%rsp)
movl 0x98(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1d6b2(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1d6af(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1d6a3(%rip), %rdi     # 0x28fd0
leaq 0x17acf(%rip), %rsi     # 0x23403
callq 0x3220
movq %rax, 0x50(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x50(%rsp), %rdi
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17a15(%rip), %rsi     # 0x233a7
callq 0x3220
movq %rax, 0x58(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x58(%rsp), %rdi
movl %eax, 0x90(%rsp)
movl 0x90(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10308, %rax          # imm = 0x10308
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x179bf(%rip), %rsi     # 0x233af
callq 0x3220
movq %rax, 0x60(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x60(%rsp), %rdi
movl %eax, 0x8c(%rsp)
movl 0x8c(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1d56a(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1d567(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1d55b(%rip), %rdi     # 0x28fd0
leaq 0x1799b(%rip), %rsi     # 0x23417
callq 0x3220
movq %rax, 0x68(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x68(%rsp), %rdi
movl %eax, 0x88(%rsp)
movl 0x88(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x178cd(%rip), %rsi     # 0x233a7
callq 0x3220
movq %rax, 0x70(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x70(%rsp), %rdi
movl %eax, 0x84(%rsp)
movl 0x84(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10308, %rax          # imm = 0x10308
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17877(%rip), %rsi     # 0x233af
callq 0x3220
movq %rax, 0x78(%rsp)
movl $0xa, %edi
callq 0xfda0
movq 0x78(%rsp), %rdi
movl %eax, 0x80(%rsp)
movl 0x80(%rsp), %esi
callq 0x3270
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1d422(%rip), %rsi     # 0x28fb8
callq 0x3250
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)