// File: NishadSaraf[P]Championship-Simulator/inc/cache.h
// Function: CACHE::CACHE(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
CACHE(string v1, uint32_t v2, int v3, uint32_t v4, uint32_t v5, uint32_t v6, uint32_t v7, uint32_t v8) 
        : NAME(v1), NUM_SET(v2), NUM_WAY(v3), NUM_LINE(v4), WQ_SIZE(v5), RQ_SIZE(v6), PQ_SIZE(v7), MSHR_SIZE(v8) {

        LATENCY = 0;

        // cache block
        block = new BLOCK* [NUM_SET];
        for (uint32_t i=0; i<NUM_SET; i++) {
            block[i] = new BLOCK[NUM_WAY]; 

            for (uint32_t j=0; j<NUM_WAY; j++) {
                block[i][j].lru = j;
            }
        }

        for (uint32_t i=0; i<NUM_CPUS; i++) {
            upper_level_icache[i] = NULL;
            upper_level_dcache[i] = NULL;

            for (uint32_t j=0; j<NUM_TYPES; j++) {
                sim_access[i][j] = 0;
                sim_hit[i][j] = 0;
                sim_miss[i][j] = 0;
                roi_access[i][j] = 0;
                roi_hit[i][j] = 0;
                roi_miss[i][j] = 0;
            }
        }

        lower_level = NULL;
        extra_interface = NULL;
        fill_level = -1;
        MAX_READ = 1;
        MAX_FILL = 1;
    }

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rsi, 0x68(%rsp)
movl 0x170(%rsp), %eax
movl 0x168(%rsp), %eax
movl 0x160(%rsp), %eax
movq %rdi, 0x150(%rsp)
movq %rsi, 0x148(%rsp)
movl %edx, 0x144(%rsp)
movl %ecx, 0x140(%rsp)
movl %r8d, 0x13c(%rsp)
movl %r9d, 0x138(%rsp)
movq 0x150(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x1d3e0
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0xc0c6(%rip), %rax      # 0x28c08
addq $0x10, %rax
movq %rax, (%rdi)
addq $0x7350, %rdi           # imm = 0x7350
movq %rdi, 0x70(%rsp)
callq 0x3100
jmp 0x1cb5c
movq 0x60(%rsp), %rsi
movl 0x144(%rsp), %eax
movl %eax, 0x7370(%rsi)
movl 0x140(%rsp), %eax
movl %eax, 0x7374(%rsi)
movl 0x13c(%rsp), %eax
movl %eax, 0x7378(%rsi)
movl 0x138(%rsp), %eax
movl %eax, 0x737c(%rsi)
movl 0x160(%rsp), %eax
movl %eax, 0x7380(%rsi)
movl 0x168(%rsp), %eax
movl %eax, 0x7384(%rsi)
movl 0x170(%rsp), %eax
movl %eax, 0x7388(%rsi)
movq %rsi, %rax
addq $0x73a8, %rax           # imm = 0x73A8
movq %rax, 0x58(%rsp)
addq $0x7350, %rsi           # imm = 0x7350
leaq 0x6f25(%rip), %rdx      # 0x23afd
leaq 0x108(%rsp), %rdi
callq 0x1d770
jmp 0x1cbe7
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rax
movl 0x737c(%rax), %edx
leaq 0x108(%rsp), %rsi
callq 0x1d800
jmp 0x1cc06
leaq 0x108(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rsi
movq %rsi, %rax
addq $0x9048, %rax           # imm = 0x9048
movq %rax, 0x50(%rsp)
addq $0x7350, %rsi           # imm = 0x7350
leaq 0x7313(%rip), %rdx      # 0x23f47
leaq 0xe8(%rsp), %rdi
callq 0x1d770
jmp 0x1cc43
movq 0x50(%rsp), %rdi
movq 0x60(%rsp), %rax
movl 0x7380(%rax), %edx
leaq 0xe8(%rsp), %rsi
callq 0x1d800
jmp 0x1cc62
leaq 0xe8(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rsi
movq %rsi, %rax
addq $0xace8, %rax           # imm = 0xACE8
movq %rax, 0x48(%rsp)
addq $0x7350, %rsi           # imm = 0x7350
leaq 0x72bb(%rip), %rdx      # 0x23f4b
leaq 0xc8(%rsp), %rdi
callq 0x1d770
jmp 0x1cc9f
movq 0x48(%rsp), %rdi
movq 0x60(%rsp), %rax
movl 0x7384(%rax), %edx
leaq 0xc8(%rsp), %rsi
callq 0x1d800
jmp 0x1ccbe
leaq 0xc8(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rsi
movq %rsi, %rax
addq $0xc988, %rax           # imm = 0xC988
movq %rax, 0x40(%rsp)
addq $0x7350, %rsi           # imm = 0x7350
leaq 0x7263(%rip), %rdx      # 0x23f4f
leaq 0xa8(%rsp), %rdi
callq 0x1d770
jmp 0x1ccfb
movq 0x40(%rsp), %rdi
movq 0x60(%rsp), %rax
movl 0x7388(%rax), %edx
leaq 0xa8(%rsp), %rsi
callq 0x1d800
jmp 0x1cd1a
leaq 0xa8(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rsi
movq %rsi, %rax
addq $0xe628, %rax           # imm = 0xE628
movq %rax, 0x38(%rsp)
addq $0x7350, %rsi           # imm = 0x7350
leaq 0x720d(%rip), %rdx      # 0x23f55
leaq 0x88(%rsp), %rdi
callq 0x1d770
jmp 0x1cd57
movq 0x38(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x1d800
jmp 0x1cd70
leaq 0x88(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rdi
addq $0x102c8, %rdi          # imm = 0x102C8
callq 0x1d9e0
jmp 0x1cd90
movq 0x60(%rsp), %rax
movl $0x0, 0x738c(%rax)
movl 0x7370(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x3030
movq %rax, 0x30(%rsp)
jmp 0x1cdb7
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x7390(%rax)
movl $0x0, 0x84(%rsp)
movq 0x60(%rsp), %rcx
movl 0x84(%rsp), %eax
cmpl 0x7370(%rcx), %eax
jae 0x1d08a
movq 0x60(%rsp), %rax
movl 0x7374(%rax), %eax
movq %rax, 0x20(%rsp)
shlq $0x4, %rax
leaq (%rax,%rax,4), %rdi
callq 0x3030
movq %rax, 0x28(%rsp)
jmp 0x1ce0f
movq 0x20(%rsp), %rax
cmpq $0x0, %rax
je 0x1ce61
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
imulq $0x50, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x1da10
jmp 0x1ce49
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rax
addq $0x50, %rax
cmpq %rcx, %rax
movq %rax, 0x18(%rsp)
jne 0x1ce38
movq 0x28(%rsp), %rdx
movq 0x60(%rsp), %rax
movq 0x7390(%rax), %rax
movl 0x84(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x80(%rsp)
movq 0x60(%rsp), %rcx
movl 0x80(%rsp), %eax
cmpl 0x7374(%rcx), %eax
jae 0x1d072
movq 0x60(%rsp), %rax
movl 0x80(%rsp), %ecx
movq 0x7390(%rax), %rax
movl 0x84(%rsp), %edx
movq (%rax,%rdx,8), %rax
movl 0x80(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x48(%rax)
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x1ce88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d22f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d225
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x3150
jmp 0x1d225
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d21b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x3150
jmp 0x1d21b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d211
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x3150
jmp 0x1d211
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x3150
jmp 0x1d207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d1fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x3150
jmp 0x1d1fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x1d1f3
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
callq 0x32b0
jmp 0x1d1f3
jmp 0x1d074
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x1cdd3
movl $0x0, 0x7c(%rsp)
cmpl $0x1, 0x7c(%rsp)
jae 0x1d1b8
movq 0x60(%rsp), %rax
movl 0x7c(%rsp), %ecx
movq $0x0, 0x8(%rax,%rcx,8)
movl 0x7c(%rsp), %ecx
movq $0x0, 0x10(%rax,%rcx,8)
movl $0x0, 0x78(%rsp)
cmpl $0x4, 0x78(%rsp)
jae 0x1d1a6
movq 0x60(%rsp), %rax
movq %rax, %rcx
addq $0x102e8, %rcx          # imm = 0x102E8
movl 0x7c(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x78(%rsp), %edx
movq $0x0, (%rcx,%rdx,8)
movq %rax, %rcx
addq $0x10308, %rcx          # imm = 0x10308
movl 0x7c(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x78(%rsp), %edx
movq $0x0, (%rcx,%rdx,8)
movq %rax, %rcx
addq $0x10328, %rcx          # imm = 0x10328
movl 0x7c(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x78(%rsp), %edx
movq $0x0, (%rcx,%rdx,8)
movq %rax, %rcx
addq $0x10348, %rcx          # imm = 0x10348
movl 0x7c(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x78(%rsp), %edx
movq $0x0, (%rcx,%rdx,8)
movq %rax, %rcx
addq $0x10368, %rcx          # imm = 0x10368
movl 0x7c(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x78(%rsp), %edx
movq $0x0, (%rcx,%rdx,8)
addq $0x10388, %rax          # imm = 0x10388
movl 0x7c(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x78(%rsp), %ecx
movq $0x0, (%rax,%rcx,8)
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x1d0c4
jmp 0x1d1a8
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x1d092
movq 0x60(%rsp), %rax
movq $0x0, 0x18(%rax)
movq $0x0, 0x20(%rax)
movl $0xffffffff, 0x7398(%rax) # imm = 0xFFFFFFFF
movl $0x1, 0x739c(%rax)
movl $0x1, 0x73a0(%rax)
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x38(%rsp), %rdi
callq 0x1da80
movq 0x40(%rsp), %rdi
callq 0x1da80
movq 0x48(%rsp), %rdi
callq 0x1da80
movq 0x50(%rsp), %rdi
callq 0x1da80
movq 0x58(%rsp), %rdi
callq 0x1da80
movq 0x70(%rsp), %rdi
callq 0x3150
movq 0x60(%rsp), %rdi
callq 0x1dac0
movq 0x130(%rsp), %rdi
callq 0x33c0
nopw %cs:(%rax,%rax)