// File: NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: print_roi_stats(unsigned int, CACHE*)
void print_roi_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->roi_access[cpu][i];
        TOTAL_HIT += cache->roi_hit[cpu][i];
        TOTAL_MISS += cache->roi_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->roi_access[cpu][0] << "  HIT: " << setw(10) << cache->roi_hit[cpu][0] << "  MISS: " << setw(10) << cache->roi_miss[cpu][0] << endl;

    cout << cache->NAME;
    cout << " RFO       ACCESS: " << setw(10) << cache->roi_access[cpu][1] << "  HIT: " << setw(10) << cache->roi_hit[cpu][1] << "  MISS: " << setw(10) << cache->roi_miss[cpu][1] << endl;

    cout << cache->NAME;
    cout << " PREFETCH  ACCESS: " << setw(10) << cache->roi_access[cpu][2] << "  HIT: " << setw(10) << cache->roi_hit[cpu][2] << "  MISS: " << setw(10) << cache->roi_miss[cpu][2] << endl;

    cout << cache->NAME;
    cout << " WRITEBACK ACCESS: " << setw(10) << cache->roi_access[cpu][3] << "  HIT: " << setw(10) << cache->roi_hit[cpu][3] << "  MISS: " << setw(10) << cache->roi_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 0xae3e
movq 0xd8(%rsp), %rax
addq $0x10348, %rax          # imm = 0x10348
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 $0x10368, %rax          # imm = 0x10368
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 $0x10388, %rax          # imm = 0x10388
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 0xad75
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1e17c(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1e170(%rip), %rdi     # 0x28fd0
leaq 0x1852c(%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 0x184fa(%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 0x184bc(%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 0x1e07f(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1e07c(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1e070(%rip), %rdi     # 0x28fd0
leaq 0x18474(%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 $0x10348, %rax          # imm = 0x10348
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x183e3(%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 $0x10368, %rax          # imm = 0x10368
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x1838e(%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 $0x10388, %rax          # imm = 0x10388
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1df3a(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1df37(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1df2b(%rip), %rdi     # 0x28fd0
leaq 0x18343(%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 $0x10348, %rax          # imm = 0x10348
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x1829d(%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 $0x10368, %rax          # imm = 0x10368
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x18247(%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 $0x10388, %rax          # imm = 0x10388
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1ddf2(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1ddef(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1dde3(%rip), %rdi     # 0x28fd0
leaq 0x1820f(%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 $0x10348, %rax          # imm = 0x10348
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x18155(%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 $0x10368, %rax          # imm = 0x10368
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x180ff(%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 $0x10388, %rax          # imm = 0x10388
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1dcaa(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0xd8(%rsp), %rsi
addq $0x7350, %rsi           # imm = 0x7350
movq 0x1dca7(%rip), %rdi     # 0x28fd0
callq 0x31c0
movq 0x1dc9b(%rip), %rdi     # 0x28fd0
leaq 0x180db(%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 $0x10348, %rax          # imm = 0x10348
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x1800d(%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 $0x10368, %rax          # imm = 0x10368
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x17fb7(%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 $0x10388, %rax          # imm = 0x10388
movl 0xe4(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1db62(%rip), %rsi     # 0x28fb8
callq 0x3250
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)