// File: /workspace/github_cpp_makefile_star2_O1/NishadSaraf[P]Championship-Simulator/src/cache.cc
// Function: CACHE::fill_cache(unsigned int, unsigned int, PACKET*)
void CACHE::fill_cache(uint32_t set, uint32_t way, PACKET *packet)
{
#ifdef SANITY_CHECK
    if (cache_type == IS_ITLB) {
        if (packet->data == 0)
            assert(0);
    }

    if (cache_type == IS_DTLB) {
        if (packet->data == 0)
            assert(0);
    }

    if (cache_type == IS_STLB) {
        if (packet->data == 0)
            assert(0);
    }
#endif
    if (block[set][way].prefetch && (block[set][way].used == 0))
        STATS.pf_useless++;

    if (block[set][way].valid == 0)
        block[set][way].valid = 1;
    block[set][way].dirty = 0;
    block[set][way].prefetch = (packet->type == PREFETCH) ? 1 : 0;
    block[set][way].used = 0;

    if (block[set][way].prefetch)
        STATS.pf_fill++;

    block[set][way].delta = packet->delta;
    block[set][way].depth = packet->depth;
    block[set][way].signature = packet->signature;
    block[set][way].confidence = packet->confidence;

    block[set][way].tag = packet->address;
    block[set][way].address = packet->address;
    block[set][way].full_addr = packet->full_addr;
    block[set][way].data = packet->data;
    block[set][way].cpu = packet->cpu;
    block[set][way].instr_id = packet->instr_id;

    DP ( if (warmup_complete[packet->cpu]) {
    cout << "[" << NAME << "] " << __func__ << " set: " << set << " way: " << way;
    cout << " lru: " << block[set][way].lru << " tag: " << hex << block[set][way].tag << " full_addr: " << block[set][way].full_addr;
    cout << " data: " << block[set][way].data << dec << endl; });
}

// Assembly:
pushq %rax
movzbl 0x73a4(%rdi), %eax
cmpl $0x2, %eax
je 0x4085
cmpl $0x1, %eax
je 0x4072
testl %eax, %eax
jne 0x4093
cmpq $0x0, 0x360(%rcx)
je 0x4168
cmpl $0x2, %eax
je 0x4085
cmpl $0x1, %eax
jne 0x4093
cmpq $0x0, 0x360(%rcx)
je 0x4149
cmpl $0x2, %eax
jne 0x4093
cmpq $0x0, 0x360(%rcx)
je 0x412a
movq 0x7390(%rdi), %rax
movl %esi, %esi
movq (%rax,%rsi,8), %rax
movl %edx, %edx
leaq (%rdx,%rdx,4), %rdx
shlq $0x4, %rdx
leaq (%rax,%rdx), %rsi
cmpb $0x0, 0x1(%rax,%rdx)
je 0x40c2
cmpb $0x0, 0x3(%rsi)
jne 0x40c2
incq 0x102d8(%rdi)
cmpb $0x0, (%rsi)
jne 0x40ca
movb $0x1, (%rsi)
xorl %esi, %esi
movb %sil, 0x2(%rax,%rdx)
cmpb $0x2, 0x32f(%rcx)
sete 0x1(%rax,%rdx)
movb %sil, 0x3(%rax,%rdx)
jne 0x40eb
incq 0x102e0(%rdi)
movups 0x18(%rcx), %xmm0
movups %xmm0, 0x4(%rax,%rdx)
movups 0x340(%rcx), %xmm0
movlps %xmm0, 0x28(%rax,%rdx)
movups %xmm0, 0x18(%rax,%rdx)
movq 0x360(%rcx), %rsi
movq %rsi, 0x30(%rax,%rdx)
movl 0x330(%rcx), %esi
movq %rsi, 0x38(%rax,%rdx)
movq 0x368(%rcx), %rcx
movq %rcx, 0x40(%rax,%rdx)
popq %rax
retq
leaq 0xff36(%rip), %rdi      # 0x14067
leaq 0xff31(%rip), %rsi      # 0x14069
leaq 0xffe5(%rip), %rcx      # 0x14124
movl $0x341, %edx            # imm = 0x341
callq 0x3160
leaq 0xff17(%rip), %rdi      # 0x14067
leaq 0xff12(%rip), %rsi      # 0x14069
leaq 0xffc6(%rip), %rcx      # 0x14124
movl $0x33c, %edx            # imm = 0x33C
callq 0x3160
leaq 0xfef8(%rip), %rdi      # 0x14067
leaq 0xfef3(%rip), %rsi      # 0x14069
leaq 0xffa7(%rip), %rcx      # 0x14124
movl $0x337, %edx            # imm = 0x337
callq 0x3160
nop