// File: CMU-SAFARI[P]ramulator/src/TLDRAM.cpp
// Function: ramulator::TLDRAM::init_lambda()
void TLDRAM::init_lambda()
{
    lambda[int(Level::Bank)][int(Command::ACT)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Opened;
        node->row_state[id] = State::Opened;
    };
    lambda[int(Level::Bank)][int(Command::ACTF)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Opened;
        node->row_state[id] = State::Opened;
    };
    lambda[int(Level::Bank)][int(Command::ACTM)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Opened;
        node->row_state[id] = State::Opened;
    };
    lambda[int(Level::Bank)][int(Command::PRE)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();
    };
    lambda[int(Level::Bank)][int(Command::PREF)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();
    };
    lambda[int(Level::Bank)][int(Command::PREM)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();
    };
    lambda[int(Level::Rank)][int(Command::PREA)] = [] (DRAM<TLDRAM>* node, int id) {
        for (auto bank : node->children) {
            bank->state = State::Closed;
            bank->row_state.clear();
        }
    };
    lambda[int(Level::Rank)][int(Command::PREAF)] = [] (DRAM<TLDRAM>* node, int id) {
        for (auto bank : node->children) {
            bank->state = State::Closed;
            bank->row_state.clear();
        }
    };
    lambda[int(Level::Rank)][int(Command::PREAM)] = [] (DRAM<TLDRAM>* node, int id) {
        for (auto bank : node->children) {
            bank->state = State::Closed;
            bank->row_state.clear();
        }
    };
    lambda[int(Level::Rank)][int(Command::REF)] = [] (DRAM<TLDRAM>* node, int id) {};
    lambda[int(Level::Rank)][int(Command::REF)] = [] (DRAM<TLDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::RD)] = [] (DRAM<TLDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::WR)] = [] (DRAM<TLDRAM>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::MIG)] = [] (DRAM<TLDRAM>* node, int id) {};
    lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<TLDRAM>* 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<TLDRAM>* node, int id) {
        node->state = State::PowerUp;
    };
    lambda[int(Level::Rank)][int(Command::SRE)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::SelfRefresh;
    };
    lambda[int(Level::Rank)][int(Command::SRX)] = [] (DRAM<TLDRAM>* node, int id) {
        node->state = State::PowerUp;
    };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
leaq -0x9(%rbp), %rsi
callq 0x22a320
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x140, %rdi            # imm = 0x140
leaq -0xa(%rbp), %rsi
callq 0x22a370
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x1c0, %rdi            # imm = 0x1C0
leaq -0xb(%rbp), %rsi
callq 0x22a3c0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x20, %rdi
leaq -0xc(%rbp), %rsi
callq 0x22a410
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x160, %rdi            # imm = 0x160
leaq -0xd(%rbp), %rsi
callq 0x22a460
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x1e0, %rdi            # imm = 0x1E0
leaq -0xe(%rbp), %rsi
callq 0x22a4b0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0x40, %rdi
leaq -0xf(%rbp), %rsi
callq 0x22a500
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0x180, %rdi            # imm = 0x180
leaq -0x10(%rbp), %rsi
callq 0x22a550
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0x200, %rdi            # imm = 0x200
leaq -0x11(%rbp), %rsi
callq 0x22a5a0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0xa0, %rdi
leaq -0x12(%rbp), %rsi
callq 0x22a5f0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0xa0, %rdi
leaq -0x13(%rbp), %rsi
callq 0x22a640
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x60, %rdi
leaq -0x14(%rbp), %rsi
callq 0x22a690
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x80, %rdi
leaq -0x15(%rbp), %rsi
callq 0x22a6e0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x440, %rdi            # imm = 0x440
addq $0x1a0, %rdi            # imm = 0x1A0
leaq -0x16(%rbp), %rsi
callq 0x22a730
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0xc0, %rdi
leaq -0x17(%rbp), %rsi
callq 0x22a780
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0xe0, %rdi
leaq -0x18(%rbp), %rsi
callq 0x22a7d0
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0x100, %rdi            # imm = 0x100
leaq -0x19(%rbp), %rsi
callq 0x22a820
movq -0x28(%rbp), %rdi
addq $0x2a70, %rdi           # imm = 0x2A70
addq $0x220, %rdi            # imm = 0x220
addq $0x120, %rdi            # imm = 0x120
leaq -0x1a(%rbp), %rsi
callq 0x22a870
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)