// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %eax
cmpl $0x2, %eax
je 0x131dc0
cmpl $0x1, %eax
je 0x131d63
testl %eax, %eax
jne 0x131e37
movups 0x1290(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x35f7(%rip), %rcx      # 0x13531e
movq %rcx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x355b(%rip), %rcx      # 0x13529c
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x131e1b
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x131e1b
movups 0x1290(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x362d(%rip), %rcx      # 0x1353b8
movq %rcx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3591(%rip), %rcx      # 0x135336
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x131e1b
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x131e1b
movups 0x1290(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x36a0(%rip), %rcx      # 0x135488
movq %rcx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x35ce(%rip), %rcx      # 0x1353d0
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x131e1b
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x1290(%rbx), %rsi
addq $0x12b0, %rbx           # imm = 0x12B0
movq %rbx, %rdi
callq 0x135f7a
addq $0x20, %rsp
popq %rbx
retq
leaq 0x1855b(%rip), %rdi     # 0x14a399
leaq 0x29745(%rip), %rsi     # 0x15b58a
leaq 0x297bf(%rip), %rcx     # 0x15b60b
movl $0x10f, %edx            # imm = 0x10F
callq 0xb200
jmp 0x131e5a
jmp 0x131e5a
movq %rax, %rdi
callq 0x171a3