// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
leaq 0x10348(%rsi), %rax
movq %rax, 0x8(%rsp)
movl %edi, %r12d
leaq 0x10368(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x10388(%rsi), %rax
movq %rax, 0x20(%rsp)
shlq $0x5, %r12
leaq (%rsi,%r12), %rax
addq $0x10388, %rax          # imm = 0x10388
pxor %xmm1, %xmm1
movq $-0x4, %rcx
pxor %xmm2, %xmm2
pxor %xmm0, %xmm0
movdqu -0x20(%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm1
movdqu (%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm2
movdqu 0x20(%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm0
addq $0x2, %rcx
jne 0x757b
pshufd $0xee, %xmm1, %xmm3     # xmm3 = xmm1[2,3,2,3]
paddq %xmm1, %xmm3
movq %xmm3, %r15
pshufd $0xee, %xmm2, %xmm1     # xmm1 = xmm2[2,3,2,3]
paddq %xmm2, %xmm1
movq %xmm1, %r13
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddq %xmm0, %xmm1
movq %xmm1, 0x18(%rsp)
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq 0x129f2(%rip), %r14     # 0x19fd0
movq %r14, %rdi
callq 0x3280
leaq 0xce2e(%rip), %rsi      # 0x1441b
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3170
movq %rax, %rbp
leaq 0xce0f(%rip), %rsi      # 0x1442f
movl $0x7, %edx
movq %rax, %rdi
callq 0x3280
movq (%rbp), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%rbp,%rax)
movl $0xa, %r15d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3170
movq %rax, %rbp
leaq 0xcddd(%rip), %rsi      # 0x14437
movl $0x8, %edx
movq %rax, %rdi
callq 0x3280
movq (%rbp), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%rbp,%rax)
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcd9b(%rip), %rsi      # 0x14463
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %r15d
movq %r15, 0x10(%r14,%rax)
movq 0x8(%rsp), %rax
movq (%rax,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcd25(%rip), %rsi      # 0x1442f
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movl $0xa, %r15d
movq 0x10(%rsp), %rax
movq (%rax,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
leaq 0xccf2(%rip), %rsi      # 0x14437
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movl $0xa, %r15d
movq 0x20(%rsp), %rbp
movq (%rbp,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xccc1(%rip), %rsi      # 0x14477
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r14,%rax)
movq 0x8(%rsp), %r15
movq 0x8(%r15,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcc3c(%rip), %rsi      # 0x1442f
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r13,%rax)
movq 0x10(%rsp), %rax
movq 0x8(%rax,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
leaq 0xcc09(%rip), %rsi      # 0x14437
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r13,%rax)
movq 0x8(%rbp,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcbf2(%rip), %rsi      # 0x1448b
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r14,%rax)
movq 0x10(%r15,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcb59(%rip), %rsi      # 0x1442f
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r13,%rax)
movq 0x10(%rsp), %r15
movq 0x10(%r15,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
leaq 0xcb26(%rip), %rsi      # 0x14437
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r13,%rax)
movq 0x10(%rbp,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcb23(%rip), %rsi      # 0x1449f
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %r13d
movq %r13, 0x10(%r14,%rax)
movq 0x8(%rsp), %rax
movq 0x18(%rax,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %rbx
movl $0x7, %edx
movq %rax, %rdi
leaq 0xca70(%rip), %rsi      # 0x1442f
callq 0x3280
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %r13, 0x10(%rbx,%rax)
movl $0xa, %r14d
movq 0x18(%r15,%r12), %rsi
movq %rbx, %rdi
callq 0x3170
movq %rax, %rbx
movl $0x8, %edx
movq %rax, %rdi
leaq 0xca42(%rip), %rsi      # 0x14437
callq 0x3280
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %r14, 0x10(%rbx,%rax)
movq 0x18(%rbp,%r12), %rsi
movq %rbx, %rdi
callq 0x3170
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3180