// File: CMU-SAFARI[P]ramulator/src/SALP.cpp
// Function: ramulator::SALP::init_rowopen()
void SALP::init_rowopen()
{
    switch(int(type)) {
        case int(Type::SALP_1):
            // RD
            rowopen[int(Level::Bank)][int(Command::RD)] = [] (DRAM<SALP>* node, Command cmd, int id) {
                switch (int(node->state)){
                    case int(State::Closed): return false;
                    case int(State::Opened): return true;
                    default: assert(false);
                }};
            // WR
            rowopen[int(Level::Bank)][int(Command::WR)] = rowopen[int(Level::Bank)][int(Command::RD)];
            break;
        case int(Type::SALP_2):
            // RD
            rowopen[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): return true;
                    default: assert(false);
                }};
            // WR
            rowopen[int(Level::SubArray)][int(Command::WR)] = rowopen[int(Level::SubArray)][int(Command::RD)];
            break;
        case int(Type::MASA):
            // RD
            rowopen[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): return true;
                    case int(State::Selected): return true;
                    default: assert(false);
                }};
            // WR
            rowopen[int(Level::SubArray)][int(Command::WR)] = rowopen[int(Level::SubArray)][int(Command::RD)];
            break;
        default: assert(false);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl 0x20(%rax), %eax
movl %eax, -0x10(%rbp)
testl %eax, %eax
je 0x20428b
jmp 0x204270
movl -0x10(%rbp), %eax
subl $0x1, %eax
je 0x2042e8
jmp 0x20427a
movl -0x10(%rbp), %eax
subl $0x2, %eax
je 0x204342
jmp 0x20439c
movq -0x18(%rbp), %rdi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x380, %rdi            # imm = 0x380
addq $0x80, %rdi
leaq -0x9(%rbp), %rsi
callq 0x206b70
movq -0x18(%rbp), %rdi
movq %rdi, %rsi
addq $0x1750, %rsi           # imm = 0x1750
addq $0x380, %rsi            # imm = 0x380
addq $0x80, %rsi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x380, %rdi            # imm = 0x380
addq $0xa0, %rdi
callq 0x212320
jmp 0x2043bb
movq -0x18(%rbp), %rdi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x540, %rdi            # imm = 0x540
addq $0x80, %rdi
leaq -0xa(%rbp), %rsi
callq 0x206bc0
movq -0x18(%rbp), %rdi
movq %rdi, %rsi
addq $0x1750, %rsi           # imm = 0x1750
addq $0x540, %rsi            # imm = 0x540
addq $0x80, %rsi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x540, %rdi            # imm = 0x540
addq $0xa0, %rdi
callq 0x212320
jmp 0x2043bb
movq -0x18(%rbp), %rdi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x540, %rdi            # imm = 0x540
addq $0x80, %rdi
leaq -0xb(%rbp), %rsi
callq 0x206c10
movq -0x18(%rbp), %rdi
movq %rdi, %rsi
addq $0x1750, %rsi           # imm = 0x1750
addq $0x540, %rsi            # imm = 0x540
addq $0x80, %rsi
addq $0x1750, %rdi           # imm = 0x1750
addq $0x540, %rdi            # imm = 0x540
addq $0xa0, %rdi
callq 0x212320
jmp 0x2043bb
leaq 0x4b7be(%rip), %rdi     # 0x24fb61
leaq 0x5e82b(%rip), %rsi     # 0x262bd5
movl $0x138, %edx            # imm = 0x138
leaq 0x5e8c4(%rip), %rcx     # 0x262c7a
callq 0xc280
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)