// File: /workspace/github_cpp_makefile_star2_O1/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 0x13518c
cmpl $0x1, %eax
je 0x135121
testl %eax, %eax
jne 0x135211
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x35db(%rip), %rcx      # 0x138698
movq %rcx, 0x18(%rsp)
leaq 0x3651(%rip), %rdx      # 0x13871a
movq %rdx, 0x10(%rsp)
movups 0x1290(%rbx), %xmm1
movaps %xmm1, (%rsp)
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x1351f5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1351f5
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x3603(%rip), %rcx      # 0x138732
movq %rcx, 0x18(%rsp)
leaq 0x3679(%rip), %rdx      # 0x1387b4
movq %rdx, 0x10(%rsp)
movups 0x1290(%rbx), %xmm1
movaps %xmm1, (%rsp)
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x1351f5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1351f5
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x3632(%rip), %rcx      # 0x1387cc
movq %rcx, 0x18(%rsp)
leaq 0x36de(%rip), %rdx      # 0x138884
movq %rdx, 0x10(%rsp)
movups 0x1290(%rbx), %xmm1
movaps %xmm1, (%rsp)
movups %xmm0, 0x1290(%rbx)
movq 0x12a0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x12a0(%rbx)
movq 0x12a8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x12a8(%rbx)
testq %rax, %rax
je 0x1351f5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x1290(%rbx), %rsi
addq $0x12b0, %rbx           # imm = 0x12B0
movq %rbx, %rdi
callq 0x1393e8
addq $0x20, %rsp
popq %rbx
retq
leaq 0x18141(%rip), %rdi     # 0x14d359
leaq 0x292f4(%rip), %rsi     # 0x15e513
leaq 0x2936e(%rip), %rcx     # 0x15e594
movl $0x10f, %edx            # imm = 0x10F
callq 0xb200
jmp 0x135234
jmp 0x135234
movq %rax, %rdi
callq 0x1718f