// File: CMU-SAFARI[P]ramulator/src/ALDRAM.cpp
// Function: ramulator::ALDRAM::init_lambda()
void ALDRAM::init_lambda()
{
    lambda[int(Level::Bank)][int(Command::ACT)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::Opened;
        node->row_state[id] = State::Opened;};
    lambda[int(Level::Bank)][int(Command::PRE)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Rank)][int(Command::PREA)] = [] (DRAM<ALDRAM>* node, int id) {
        for (auto bank : node->children) {
            bank->state = State::Closed;
            bank->row_state.clear();}};
    lambda[int(Level::Rank)][int(Command::REF)] = [] (DRAM<ALDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::RD)] = [] (DRAM<ALDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::WR)] = [] (DRAM<ALDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::RDA)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Bank)][int(Command::WRA)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<ALDRAM>* node, int id) {
        for (auto bank : node->children) {
            if (bank->state == State::Closed)
                continue;
            node->state = State::ActPowerDown;
            return;
        }
        node->state = State::PrePowerDown;};
    lambda[int(Level::Rank)][int(Command::PDX)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::PowerUp;};
    lambda[int(Level::Rank)][int(Command::SRE)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::SelfRefresh;};
    lambda[int(Level::Rank)][int(Command::SRX)] = [] (DRAM<ALDRAM>* node, int id) {
        node->state = State::PowerUp;};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
leaq -0x9(%rbp), %rsi
callq 0x171c90
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
addq $0x20, %rdi
leaq -0xa(%rbp), %rsi
callq 0x171ce0
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0x40, %rdi
leaq -0xb(%rbp), %rsi
callq 0x171d30
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0xe0, %rdi
leaq -0xc(%rbp), %rsi
callq 0x171d80
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
addq $0x60, %rdi
leaq -0xd(%rbp), %rsi
callq 0x171dd0
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
addq $0x80, %rdi
leaq -0xe(%rbp), %rsi
callq 0x171e20
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
addq $0xa0, %rdi
leaq -0xf(%rbp), %rsi
callq 0x171e70
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x300, %rdi            # imm = 0x300
addq $0xc0, %rdi
leaq -0x10(%rbp), %rsi
callq 0x171ec0
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0x100, %rdi            # imm = 0x100
leaq -0x11(%rbp), %rsi
callq 0x171f10
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0x120, %rdi            # imm = 0x120
leaq -0x12(%rbp), %rsi
callq 0x171f60
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0x140, %rdi            # imm = 0x140
leaq -0x13(%rbp), %rsi
callq 0x171fb0
movq -0x20(%rbp), %rdi
addq $0x1e00, %rdi           # imm = 0x1E00
addq $0x180, %rdi            # imm = 0x180
addq $0x160, %rdi            # imm = 0x160
leaq -0x14(%rbp), %rsi
callq 0x172000
addq $0x20, %rsp
popq %rbp
retq
nop