// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/SALP.cpp
// Function: ramulator::SALP::init_lambda()
void SALP::init_lambda()
{
    switch(int(type)){
        case int(Type::SALP_1):
            lambda[int(Level::Bank)][int(Command::ACT)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Opened;
            };
            lambda[int(Level::SubArray)][int(Command::ACT)] = [] (DRAM<SALP>* node, int id) {
              node->state = State::Opened;
              node->row_state[id] = State::Opened;
            };
            lambda[int(Level::Bank)][int(Command::PRE)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                // For SALP_1, we stick to original design that allows
                // only one row in a bank open, so here close subarray id
                // is equivalent to close the whole bank
                node->children[id]->state = State::Closed;
                node->children[id]->row_state.clear();
                };
            lambda[int(Level::Bank)][int(Command::PRE_OTHER)] = lambda[int(Level::Bank)][int(Command::PRE)];
            lambda[int(Level::Rank)][int(Command::PRER)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children) {
                    bank->state = State::Closed;
                    for (auto sa : bank->children){
                        sa->state = State::Closed;
                        sa->row_state.clear();}}};
            lambda[int(Level::Bank)][int(Command::RDA)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->children[id]->state = State::Closed;
                node->children[id]->row_state.clear();};
            lambda[int(Level::Bank)][int(Command::WRA)] = lambda[int(Level::Bank)][int(Command::RDA)];
            lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children) {
                    if (bank->state == State::Closed)
                        continue;
                    node->state = State::ActPowerDown;
                    return;
                }
                node->state = State::PrePowerDown;};
            break;
        case int(Type::SALP_2):
            lambda[int(Level::SubArray)][int(Command::ACT)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Opened;
                node->row_state[id] = State::Opened;};
            lambda[int(Level::SubArray)][int(Command::PRE)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};
            lambda[int(Level::SubArray)][int(Command::PRE_OTHER)] = lambda[int(Level::SubArray)][int(Command::PRE)];
            lambda[int(Level::Rank)][int(Command::PRER)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children)
                    for (auto sa : bank->children) {
                        sa->state = State::Closed;
                        sa->row_state.clear();}};
            lambda[int(Level::SubArray)][int(Command::RDA)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};
            lambda[int(Level::SubArray)][int(Command::WRA)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};
            lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children)
                    for (auto sa : bank->children) {
                        if (sa->state == State::Closed)
                            continue;
                        node->state = State::ActPowerDown;
                        return;
                    }
                node->state = State::PrePowerDown;};
            break;
        case int(Type::MASA):
            lambda[int(Level::SubArray)][int(Command::ACT)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Selected;
                node->row_state[id] = State::Opened;
                for (auto sa : node->parent->children)
                    if (sa != node && sa->state == State::Selected) {
                        sa->state = State::Opened;
                        break;}};
            lambda[int(Level::SubArray)][int(Command::SASEL)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Selected;
                for (auto sa : node->parent->children)
                    if (sa != node && sa->state == State::Selected) {
                        sa->state = State::Opened;
                        break;}};
            lambda[int(Level::SubArray)][int(Command::PRE)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};

            lambda[int(Level::Rank)][int(Command::PRER)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children)
                    for (auto sa : bank->children) {
                        sa->state = State::Closed;
                        sa->row_state.clear();}};
            lambda[int(Level::SubArray)][int(Command::RDA)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};
            lambda[int(Level::SubArray)][int(Command::WRA)] = [] (DRAM<SALP>* node, int id) {
                node->state = State::Closed;
                node->row_state.clear();};
            lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<SALP>* node, int id) {
                for (auto bank : node->children)
                    for (auto sa : bank->children) {
                        if (sa->state == State::Closed)
                            continue;
                        node->state = State::ActPowerDown;
                        return;
                    }
                node->state = State::PrePowerDown;};
            break;
        default: assert(false);
    }
    lambda[int(Level::Rank)][int(Command::PDX)] = [] (DRAM<SALP>* node, int id) {
        node->state = State::PowerUp;};
    lambda[int(Level::Rank)][int(Command::SRE)] = [] (DRAM<SALP>* node, int id) {
        node->state = State::SelfRefresh;};
    lambda[int(Level::Rank)][int(Command::SRX)] = [] (DRAM<SALP>* node, int id) {
        node->state = State::PowerUp;};
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %eax
cmpl $0x2, %eax
je 0xbec39
cmpl $0x1, %eax
je 0xbea80
testl %eax, %eax
jne 0xbef0d
movups 0x2d30(%rbx), %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2d30(%rbx)
movups 0x2d40(%rbx), %xmm0
leaq 0x2277(%rip), %rax      # 0xc0b4e
movq %rax, 0x2d40(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2258(%rip), %rax      # 0xc0b42
movq %rax, 0x2d48(%rbx)
movq %r14, %rdi
callq 0x96b6a
movups 0x2ef0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movups 0x2f00(%rbx), %xmm0
leaq 0x2270(%rip), %rax      # 0xc0b8c
movq %rax, 0x2f00(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2237(%rip), %rax      # 0xc0b66
movq %rax, 0x2f08(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
leaq 0x2d70(%rbx), %r15
movups 0x2d70(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2d70(%rbx)
movups 0x2d80(%rbx), %xmm0
leaq 0x2265(%rip), %rax      # 0xc0bd0
movq %rax, 0x2d80(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2226(%rip), %rax      # 0xc0ba4
movq %rax, 0x2d88(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
leaq 0x2ed0(%rbx), %rdi
movq %r15, %rsi
callq 0xc1558
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movups 0x2be0(%rbx), %xmm0
leaq 0x2296(%rip), %rax      # 0xc0c58
movq %rax, 0x2be0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2213(%rip), %rax      # 0xc0be8
movq %rax, 0x2be8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
leaq 0x2df0(%rbx), %r15
movups 0x2df0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2df0(%rbx)
movups 0x2e00(%rbx), %xmm0
leaq 0x228b(%rip), %rax      # 0xc0c9c
movq %rax, 0x2e00(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x224c(%rip), %rax      # 0xc0c70
movq %rax, 0x2e08(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
leaq 0x2e10(%rbx), %rdi
movq %r15, %rsi
callq 0xc1558
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movups 0x2ca0(%rbx), %xmm0
leaq 0x2282(%rip), %rax      # 0xc0cea
movq %rax, 0x2ca0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2239(%rip), %rax      # 0xc0cb4
jmp 0xbee1f
movups 0x2ef0(%rbx), %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movups 0x2f00(%rbx), %xmm0
leaq 0x2282(%rip), %rax      # 0xc0d28
movq %rax, 0x2f00(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2249(%rip), %rax      # 0xc0d02
movq %rax, 0x2f08(%rbx)
movq %r14, %rdi
callq 0x96b6a
leaq 0x2f30(%rbx), %r15
movups 0x2f30(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f30(%rbx)
movups 0x2f40(%rbx), %xmm0
leaq 0x2268(%rip), %rax      # 0xc0d5a
movq %rax, 0x2f40(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x223b(%rip), %rax      # 0xc0d40
movq %rax, 0x2f48(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
leaq 0x3090(%rbx), %rdi
movq %r15, %rsi
callq 0xc1558
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movups 0x2be0(%rbx), %xmm0
leaq 0x228f(%rip), %rax      # 0xc0dd8
movq %rax, 0x2be0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2216(%rip), %rax      # 0xc0d72
movq %rax, 0x2be8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2fb0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fb0(%rbx)
movups 0x2fc0(%rbx), %xmm0
leaq 0x2279(%rip), %rax      # 0xc0e0a
movq %rax, 0x2fc0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x224c(%rip), %rax      # 0xc0df0
movq %rax, 0x2fc8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2fd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fd0(%rbx)
movups 0x2fe0(%rbx), %xmm0
leaq 0x2263(%rip), %rax      # 0xc0e3c
movq %rax, 0x2fe0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2236(%rip), %rax      # 0xc0e22
movq %rax, 0x2fe8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movups 0x2ca0(%rbx), %xmm0
leaq 0x2287(%rip), %rax      # 0xc0ea8
movq %rax, 0x2ca0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2220(%rip), %rax      # 0xc0e54
jmp 0xbee1f
movups 0x2ef0(%rbx), %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movups 0x2f00(%rbx), %xmm0
leaq 0x22c9(%rip), %rax      # 0xc0f28
movq %rax, 0x2f00(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x224e(%rip), %rax      # 0xc0ec0
movq %rax, 0x2f08(%rbx)
movq %r14, %rdi
callq 0x96b6a
movups 0x2f10(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f10(%rbx)
movups 0x2f20(%rbx), %xmm0
leaq 0x22e2(%rip), %rax      # 0xc0f86
movq %rax, 0x2f20(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2289(%rip), %rax      # 0xc0f40
movq %rax, 0x2f28(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2f30(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f30(%rbx)
movups 0x2f40(%rbx), %xmm0
leaq 0x22cc(%rip), %rax      # 0xc0fb8
movq %rax, 0x2f40(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x229f(%rip), %rax      # 0xc0f9e
movq %rax, 0x2f48(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movups 0x2be0(%rbx), %xmm0
leaq 0x2302(%rip), %rax      # 0xc1036
movq %rax, 0x2be0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2289(%rip), %rax      # 0xc0fd0
movq %rax, 0x2be8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2fb0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fb0(%rbx)
movups 0x2fc0(%rbx), %xmm0
leaq 0x22ec(%rip), %rax      # 0xc1068
movq %rax, 0x2fc0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x22bf(%rip), %rax      # 0xc104e
movq %rax, 0x2fc8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2fd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fd0(%rbx)
movups 0x2fe0(%rbx), %xmm0
leaq 0x22d6(%rip), %rax      # 0xc109a
movq %rax, 0x2fe0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x22a9(%rip), %rax      # 0xc1080
movq %rax, 0x2fe8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movups 0x2ca0(%rbx), %xmm0
leaq 0x22fa(%rip), %rax      # 0xc1106
movq %rax, 0x2ca0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2293(%rip), %rax      # 0xc10b2
movq %rax, 0x2ca8(%rbx)
movq %rsp, %rdi
callq 0x96b6a
movups 0x2cb0(%rbx), %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cb0(%rbx)
movups 0x2cc0(%rbx), %xmm0
leaq 0x22d8(%rip), %rax      # 0xc112c
movq %rax, 0x2cc0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x22b7(%rip), %rax      # 0xc111e
movq %rax, 0x2cc8(%rbx)
movq %r14, %rdi
callq 0x96b6a
movups 0x2cd0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cd0(%rbx)
movups 0x2ce0(%rbx), %xmm0
leaq 0x22b9(%rip), %rax      # 0xc1152
movq %rax, 0x2ce0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2298(%rip), %rax      # 0xc1144
movq %rax, 0x2ce8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2cf0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cf0(%rbx)
movups 0x2d00(%rbx), %xmm0
leaq 0x2297(%rip), %rax      # 0xc1178
movq %rax, 0x2d00(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x2276(%rip), %rax      # 0xc116a
movq %rax, 0x2d08(%rbx)
movq %rsp, %rdi
callq 0x96b6a
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x12445(%rip), %rdi     # 0xd1359
leaq 0x2362f(%rip), %rsi     # 0xe254a
leaq 0x236f2(%rip), %rcx     # 0xe2614
movl $0x1a8, %edx            # imm = 0x1A8
callq 0xb210