// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/SALP.cpp
// Function: ramulator::SALP::init_rowhit()
void SALP::init_rowhit()
{
    switch(int(type)) {
        case int(Type::SALP_1):
            // RD
            rowhit[int(Level::SubArray)][int(Command::RD)] = [] (DRAM<SALP>* node, Command cmd, int id) {
              switch (int(node->state)) {
                case int(State::Closed): return false;
                case int(State::Opened):
                  if (node->row_state.find(id) != node->row_state.end())  return true;
                  else return false;
                default: assert(false);
              }
            };
            // WR
            rowhit[int(Level::SubArray)][int(Command::WR)] = rowhit[int(Level::SubArray)][int(Command::RD)];
            break;
        case int(Type::SALP_2):
            // RD
            rowhit[int(Level::SubArray)][int(Command::RD)] = [] (DRAM<SALP>* node, Command cmd, int id) {
                switch (int(node->state)){
                    case int(State::Closed): return false;
                    case int(State::Opened):
                        if (node->row_state.find(id) != node->row_state.end()) return true;
                        else return false;
                    default: assert(false);
                }};
            // WR
            rowhit[int(Level::SubArray)][int(Command::WR)] = rowhit[int(Level::SubArray)][int(Command::RD)];
            break;
        case int(Type::MASA):
            // RD
            rowhit[int(Level::SubArray)][int(Command::RD)] = [] (DRAM<SALP>* node, Command cmd, int id) {
                switch (int(node->state)){
                    case int(State::Closed): return false;
                    case int(State::Opened):
                        // opened but not selected still counts as a row hit
                        if (node->row_state.find(id) != node->row_state.end()) return true;
                        else return false;
                    case int(State::Selected):
                        if (node->row_state.find(id) != node->row_state.end()) return true;
                        else return false;
                    default: assert(false);
                }};
            // WR
            rowhit[int(Level::SubArray)][int(Command::WR)] = rowhit[int(Level::SubArray)][int(Command::RD)];
            break;
        default: assert(false);
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %eax
cmpl $0x2, %eax
je 0xbe6c9
cmpl $0x1, %eax
je 0xbe689
testl %eax, %eax
jne 0xbe72d
leaq 0x1290(%rbx), %r14
movups 0x1290(%rbx), %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movups 0x12a0(%rbx), %xmm0
leaq 0x22cb(%rip), %rax      # 0xc0940
movq %rax, 0x12a0(%rbx)
movaps %xmm0, 0x10(%rdi)
leaq 0x2255(%rip), %rax      # 0xc08dc
jmp 0xbe707
leaq 0x1290(%rbx), %r14
movups 0x1290(%rbx), %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movups 0x12a0(%rbx), %xmm0
leaq 0x2307(%rip), %rax      # 0xc09bc
movq %rax, 0x12a0(%rbx)
movaps %xmm0, 0x10(%rdi)
leaq 0x2291(%rip), %rax      # 0xc0958
jmp 0xbe707
leaq 0x1290(%rbx), %r14
movups 0x1290(%rbx), %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movups 0x12a0(%rbx), %xmm0
leaq 0x2349(%rip), %rax      # 0xc0a3e
movq %rax, 0x12a0(%rbx)
movaps %xmm0, 0x10(%rdi)
leaq 0x22cd(%rip), %rax      # 0xc09d4
movq %rax, 0x12a8(%rbx)
callq 0x96b6a
addq $0x12b0, %rbx           # imm = 0x12B0
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc150a
addq $0x28, %rsp
popq %rbx
popq %r14
retq
leaq 0x12c25(%rip), %rdi     # 0xd1359
leaq 0x23e0f(%rip), %rsi     # 0xe254a
leaq 0x23e89(%rip), %rcx     # 0xe25cb
movl $0x10f, %edx            # imm = 0x10F
callq 0xb210