// File: /workspace/github_cpp_makefile_star2_O2/NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: finish_warmup()
void finish_warmup()
{
    uint64_t elapsed_second = (uint64_t)(time(NULL) - start_time),
             elapsed_minute = elapsed_second / 60,
             elapsed_hour = elapsed_minute / 60;
    elapsed_minute -= elapsed_hour*60;
    elapsed_second -= (elapsed_hour*3600 + elapsed_minute*60);

    // reset core latency
    SCHEDULING_LATENCY = 6;
    EXEC_LATENCY = 1;
    PAGE_TABLE_LATENCY = 100;
    SWAP_LATENCY = 100000;

    cout << endl;
    for (uint32_t i=0; i<NUM_CPUS; i++) {
        cout << "Warmup complete CPU " << i << " instructions: " << ooo_cpu[i].num_retired << " cycles: " << current_core_cycle[i];
        cout << " (Simulation time: " << elapsed_hour << " hr " << elapsed_minute << " min " << elapsed_second << " sec) " << endl;

        ooo_cpu[i].begin_sim_cycle = current_core_cycle[i]; 
        ooo_cpu[i].begin_sim_instr = ooo_cpu[i].num_retired;

        // reset branch stats
        ooo_cpu[i].num_branch = 0;
        ooo_cpu[i].branch_mispredictions = 0;

        reset_cache_stats(i, &ooo_cpu[i].L1I);
        reset_cache_stats(i, &ooo_cpu[i].L1D);
        reset_cache_stats(i, &ooo_cpu[i].L2C);
        reset_cache_stats(i, &uncore.LLC);
    }
    cout << endl;

    // reset DRAM stats
    uncore.DRAM.RQ.ROW_BUFFER_HIT = 0;
    uncore.DRAM.RQ.ROW_BUFFER_MISS = 0;
    uncore.DRAM.WQ.ROW_BUFFER_HIT = 0;
    uncore.DRAM.WQ.ROW_BUFFER_MISS = 0;

    // set actual cache latency
    for (uint32_t i=0; i<NUM_CPUS; i++) {
        ooo_cpu[i].ITLB.LATENCY = ITLB_LATENCY;
        ooo_cpu[i].DTLB.LATENCY = DTLB_LATENCY;
        ooo_cpu[i].STLB.LATENCY = STLB_LATENCY;
        ooo_cpu[i].L1I.LATENCY  = L1I_LATENCY;
        ooo_cpu[i].L1D.LATENCY  = L1D_LATENCY;
        ooo_cpu[i].L2C.LATENCY  = L2C_LATENCY;
    }
    uncore.LLC.LATENCY = LLC_LATENCY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %edi, %edi
callq 0x21e0
movq %rax, %rcx
subq 0xf9f1(%rip), %rcx      # 0x16338
pushq $0x3c
popq %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %rsi
movl $0xe10, %edi            # imm = 0xE10
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq %rax, %r12
imulq $-0x3c, %rax, %r15
addq %rsi, %r15
imulq $-0xe10, %rax, %r14     # imm = 0xF1F0
imulq $-0x3c, %r15, %rax
addq %rcx, %r14
addq %rax, %r14
leaq 0x7653c(%rip), %rax     # 0x7cec0
movl $0x6, (%rax)
leaq 0x76533(%rip), %rax     # 0x7cec4
pushq $0x1
popq %rcx
movl %ecx, (%rax)
movl $0x64, 0xf9a8(%rip)     # 0x16348
movl $0x186a0, 0xf9a2(%rip)  # imm = 0x186A0
movq 0xf61f(%rip), %rbx      # 0x15fd0
movq %rbx, %rdi
callq 0x2110
leaq 0x9bbd(%rip), %rsi      # 0x1057d
movq %rbx, %rdi
callq 0x2230
movq %rax, %rdi
xorl %esi, %esi
callq 0x2170
leaq 0x9bb9(%rip), %rsi      # 0x10592
movq %rax, %rdi
callq 0x2230
leaq 0x11848(%rip), %r13     # 0x18230
movq 0x918(%r13), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x9ba4(%rip), %rsi      # 0x105a2
movq %rax, %rdi
callq 0x2230
leaq 0x764a3(%rip), %rbp     # 0x7ceb0
movq (%rbp), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x9b8c(%rip), %rsi      # 0x105ac
movq %rbx, %rdi
callq 0x2230
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
leaq 0x9b86(%rip), %rsi      # 0x105c0
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
leaq 0x9b71(%rip), %rsi      # 0x105c5
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
movq %r14, %rsi
callq 0x2170
leaq 0x9b5d(%rip), %rsi      # 0x105cb
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
callq 0x2110
movq (%rbp), %rax
movq %rax, 0x8c0(%r13)
movq 0x918(%r13), %rax
movq %rax, 0x8c8(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, 0x3680(%r13)
leaq 0x34188(%r13), %rsi
xorl %edi, %edi
callq 0x68a7
leaq 0x44530(%r13), %rsi
xorl %edi, %edi
callq 0x68a7
leaq 0x548d8(%r13), %rsi
xorl %edi, %edi
callq 0x68a7
leaq 0x763fd(%rip), %r14     # 0x7ced0
xorl %edi, %edi
movq %r14, %rsi
callq 0x68a7
movq %rbx, %rdi
callq 0x2110
xorps %xmm0, %xmm0
movups %xmm0, 0x18680(%r14)
movups %xmm0, 0x1a320(%r14)
pushq $0x1
popq %rax
movl %eax, 0xaa1c(%r13)
movl %eax, 0x1adc4(%r13)
movl %eax, %ecx
pushq $0x8
popq %rax
movl %eax, 0x2b16c(%r13)
movl %ecx, 0x3b514(%r13)
movl $0x4, 0x4b8bc(%r13)
movl %eax, 0x5bc64(%r13)
movl $0x14, 0x738c(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq