// File: NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: print_deadlock(unsigned int)
void print_deadlock(uint32_t i)
{
    cout << "DEADLOCK! CPU " << i << " instr_id: " << ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].instr_id;
    cout << " translated: " << +ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].translated;
    cout << " fetched: " << +ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].fetched;
    cout << " scheduled: " << +ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].scheduled;
    cout << " executed: " << +ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].executed;
    cout << " is_memory: " << +ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].is_memory;
    cout << " event: " << ooo_cpu[i].ROB.entry[ooo_cpu[i].ROB.head].event_cycle;
    cout << " current: " << current_core_cycle[i] << endl;

    // print LQ entry
    cout << endl << "Load Queue Entry" << endl;
    for (uint32_t j=0; j<LQ_SIZE; j++) {
        cout << "[LQ] entry: " << j << " instr_id: " << ooo_cpu[i].LQ.entry[j].instr_id << " address: " << hex << ooo_cpu[i].LQ.entry[j].physical_address << dec << " translated: " << +ooo_cpu[i].LQ.entry[j].translated << " fetched: " << +ooo_cpu[i].LQ.entry[i].fetched << endl;
    }

    // print SQ entry
    cout << endl << "Store Queue Entry" << endl;
    for (uint32_t j=0; j<SQ_SIZE; j++) {
        cout << "[SQ] entry: " << j << " instr_id: " << ooo_cpu[i].SQ.entry[j].instr_id << " address: " << hex << ooo_cpu[i].SQ.entry[j].physical_address << dec << " translated: " << +ooo_cpu[i].SQ.entry[j].translated << " fetched: " << +ooo_cpu[i].SQ.entry[i].fetched << endl;
    }

    // print L1D MSHR entry
    PACKET_QUEUE *queue;
    queue = &ooo_cpu[i].L1D.MSHR;
    cout << endl << queue->NAME << " Entry" << endl;
    for (uint32_t j=0; j<queue->SIZE; j++) {
        cout << "[" << queue->NAME << "] entry: " << j << " instr_id: " << queue->entry[j].instr_id << " rob_index: " << queue->entry[j].rob_index;
        cout << " address: " << hex << queue->entry[j].address << " full_addr: " << queue->entry[j].full_addr << dec << " type: " << +queue->entry[j].type;
        cout << " fill_level: " << queue->entry[j].fill_level << " lq_index: " << queue->entry[j].lq_index << " sq_index: " << queue->entry[j].sq_index << endl; 
    }

    // print DRC
    cout << "Last DRC read mode: " << last_drc_read_mode << " write mode: " << last_drc_write_mode << endl;

    assert(0);
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
movq 0x1c901(%rip), %rdi     # 0x28fd0
leaq 0x16ea4(%rip), %rsi     # 0x2357a
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %esi
callq 0x32c0
movq %rax, %rdi
leaq 0x1772e(%rip), %rsi     # 0x23e1f
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1eb3a(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1eb1c(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq 0x1c883(%rip), %rdi     # 0x28fd0
leaq 0x16e35(%rip), %rsi     # 0x23589
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1ead7(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1eab9(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movzbl 0x4c(%rax), %esi
callq 0x33b0
movq 0x1c81f(%rip), %rdi     # 0x28fd0
leaq 0x16ddf(%rip), %rsi     # 0x23597
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1ea73(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1ea55(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movl 0x64(%rax), %esi
callq 0x32c0
movq 0x1c7bc(%rip), %rdi     # 0x28fd0
leaq 0x16d87(%rip), %rsi     # 0x235a2
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1ea10(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1e9f2(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movl 0x68(%rax), %esi
callq 0x32c0
movq 0x1c759(%rip), %rdi     # 0x28fd0
leaq 0x16d31(%rip), %rsi     # 0x235af
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e9ad(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1e98f(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movl 0x78(%rax), %esi
callq 0x33b0
movq 0x1c6f6(%rip), %rdi     # 0x28fd0
leaq 0x16cda(%rip), %rsi     # 0x235bb
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e94a(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1e92c(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movzbl 0x49(%rax), %esi
callq 0x33b0
movq 0x1c692(%rip), %rdi     # 0x28fd0
leaq 0x167f3(%rip), %rsi     # 0x23138
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e8e6(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9b8(%rax), %rax
movl 0x24(%rsp), %ecx
movl %ecx, %edx
leaq 0x1e8c8(%rip), %rcx     # 0x2b240
imulq $0x64c80, %rdx, %rdx    # imm = 0x64C80
addq %rdx, %rcx
movl 0x958(%rcx), %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
addq %rcx, %rax
movq 0x40(%rax), %rsi
callq 0x3080
movq 0x1c62e(%rip), %rdi     # 0x28fd0
leaq 0x168c6(%rip), %rsi     # 0x2326f
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x83502(%rip), %rax     # 0x8fec0
movq (%rax,%rcx,8), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1c5e7(%rip), %rsi     # 0x28fb8
callq 0x3250
movq 0x1c5f3(%rip), %rdi     # 0x28fd0
movq 0x1c5d4(%rip), %rsi     # 0x28fb8
callq 0x3250
movq %rax, %rdi
leaq 0x16bd5(%rip), %rsi     # 0x235c8
callq 0x3220
movq %rax, %rdi
movq 0x1c5b6(%rip), %rsi     # 0x28fb8
callq 0x3250
movl $0x0, 0x20(%rsp)
cmpl $0x48, 0x20(%rsp)
jae 0xcb91
movq 0x1c5af(%rip), %rdi     # 0x28fd0
leaq 0x16bb1(%rip), %rsi     # 0x235d9
callq 0x3220
movq %rax, %rdi
movl 0x20(%rsp), %esi
callq 0x32c0
movq %rax, %rdi
leaq 0x173dc(%rip), %rsi     # 0x23e1f
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e7e8(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9f0(%rax), %rax
movl 0x20(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x16697(%rip), %rsi     # 0x23120
callq 0x3220
movq %rax, %rdi
leaq -0x31e8(%rip), %rsi     # 0x98b0
callq 0x30d0
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e793(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9f0(%rax), %rax
movl 0x20(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq -0x320f(%rip), %rsi     # 0x98d0
callq 0x30d0
movq %rax, %rdi
leaq 0x16a9b(%rip), %rsi     # 0x23589
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e73d(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9f0(%rax), %rax
movl 0x20(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movzbl 0x3c(%rax), %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x16a62(%rip), %rsi     # 0x23597
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e6f6(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0x9f0(%rax), %rax
movl 0x24(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movzbl 0x3d(%rax), %esi
callq 0x33b0
movq %rax, %rdi
movq 0x1c43c(%rip), %rsi     # 0x28fb8
callq 0x3250
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0xca0f
movq 0x1c438(%rip), %rdi     # 0x28fd0
movq 0x1c419(%rip), %rsi     # 0x28fb8
callq 0x3250
movq %rax, %rdi
leaq 0x16a38(%rip), %rsi     # 0x235e6
callq 0x3220
movq %rax, %rdi
movq 0x1c3fb(%rip), %rsi     # 0x28fb8
callq 0x3250
movl $0x0, 0x1c(%rsp)
cmpl $0x38, 0x1c(%rsp)
jae 0xcd4c
movq 0x1c3f4(%rip), %rdi     # 0x28fd0
leaq 0x16a15(%rip), %rsi     # 0x235f8
callq 0x3220
movq %rax, %rdi
movl 0x1c(%rsp), %esi
callq 0x32c0
movq %rax, %rdi
leaq 0x17221(%rip), %rsi     # 0x23e1f
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e62d(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0xa28(%rax), %rax
movl 0x1c(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x164dc(%rip), %rsi     # 0x23120
callq 0x3220
movq %rax, %rdi
leaq -0x33a3(%rip), %rsi     # 0x98b0
callq 0x30d0
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e5d8(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0xa28(%rax), %rax
movl 0x1c(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq -0x33ca(%rip), %rsi     # 0x98d0
callq 0x30d0
movq %rax, %rdi
leaq 0x168e0(%rip), %rsi     # 0x23589
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e582(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0xa28(%rax), %rax
movl 0x1c(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movzbl 0x3c(%rax), %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x168a7(%rip), %rsi     # 0x23597
callq 0x3220
movq %rax, %rdi
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e53b(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
movq 0xa28(%rax), %rax
movl 0x24(%rsp), %ecx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movzbl 0x3d(%rax), %esi
callq 0x33b0
movq %rax, %rdi
movq 0x1c281(%rip), %rsi     # 0x28fb8
callq 0x3250
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xcbca
movl 0x24(%rsp), %eax
movl %eax, %ecx
leaq 0x1e4e7(%rip), %rax     # 0x2b240
imulq $0x64c80, %rcx, %rcx    # imm = 0x64C80
addq %rcx, %rax
addq $0x44530, %rax          # imm = 0x44530
addq $0xc988, %rax           # imm = 0xC988
movq %rax, 0x10(%rsp)
movq 0x1c255(%rip), %rdi     # 0x28fd0
movq 0x1c236(%rip), %rsi     # 0x28fb8
callq 0x3250
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x31c0
movq %rax, %rdi
leaq 0x16834(%rip), %rsi     # 0x235d2
callq 0x3220
movq %rax, %rdi
movq 0x1c20b(%rip), %rsi     # 0x28fb8
callq 0x3250
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x20(%rcx), %eax
jae 0xd002
movq 0x1c1fd(%rip), %rdi     # 0x28fd0
leaq 0x16253(%rip), %rsi     # 0x2302d
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x31c0
movq %rax, %rdi
leaq 0x167e6(%rip), %rsi     # 0x235dc
callq 0x3220
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x32c0
movq %rax, %rdi
leaq 0x1700e(%rip), %rsi     # 0x23e1f
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x368(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x167bc(%rip), %rsi     # 0x23605
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movl 0x10(%rax), %esi
callq 0x33b0
movq 0x1c156(%rip), %rdi     # 0x28fd0
leaq 0x1629f(%rip), %rsi     # 0x23120
callq 0x3220
movq %rax, %rdi
leaq -0x35e0(%rip), %rsi     # 0x98b0
callq 0x30d0
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x340(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x16263(%rip), %rsi     # 0x2312b
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x348(%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq -0x3630(%rip), %rsi     # 0x98d0
callq 0x30d0
movq %rax, %rdi
leaq 0x16703(%rip), %rsi     # 0x23612
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movzbl 0x32f(%rax), %esi
callq 0x33b0
movq 0x1c08c(%rip), %rdi     # 0x28fd0
leaq 0x166cf(%rip), %rsi     # 0x2361a
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x166a9(%rip), %rsi     # 0x23628
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movl 0x338(%rax), %esi
callq 0x32c0
movq %rax, %rdi
leaq 0x1667e(%rip), %rsi     # 0x23634
callq 0x3220
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rax
movl 0xc(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movl 0x33c(%rax), %esi
callq 0x32c0
movq %rax, %rdi
movq 0x1bfcb(%rip), %rsi     # 0x28fb8
callq 0x3250
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xcdba
movq 0x1bfc7(%rip), %rdi     # 0x28fd0
leaq 0x16630(%rip), %rsi     # 0x23640
callq 0x3220
movq %rax, %rdi
leaq 0x9ee09(%rip), %rax     # 0xabe28
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
leaq 0x16624(%rip), %rsi     # 0x23655
callq 0x3220
movq %rax, %rdi
leaq 0x9edf0(%rip), %rax     # 0xabe30
movq (%rax), %rsi
callq 0x3080
movq %rax, %rdi
movq 0x1bf66(%rip), %rsi     # 0x28fb8
callq 0x3250
leaq 0x15fa6(%rip), %rdi     # 0x23004
leaq 0x165fe(%rip), %rsi     # 0x23663
movl $0x127, %edx            # imm = 0x127
leaq 0x165fe(%rip), %rcx     # 0x2366f
callq 0x3160
nopw %cs:(%rax,%rax)