// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %eax
cmpl $0x2, %eax
je 0x1324a4
cmpl $0x1, %eax
je 0x132266
testl %eax, %eax
jne 0x132838
movups 0x2d30(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2d30(%rbx)
movq 0x2d40(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x355d(%rip), %rcx      # 0x13559a
movq %rcx, 0x2d40(%rbx)
movq 0x2d48(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3535(%rip), %rcx      # 0x13558c
movq %rcx, 0x2d48(%rbx)
testq %rax, %rax
je 0x132070
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2ef0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movq 0x2f00(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3548(%rip), %rcx      # 0x1355e0
movq %rcx, 0x2f00(%rbx)
movq 0x2f08(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3500(%rip), %rcx      # 0x1355b2
movq %rcx, 0x2f08(%rbx)
testq %rax, %rax
je 0x1320cb
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2d70(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2d70(%rbx)
movq 0x2d80(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3533(%rip), %rcx      # 0x135626
movq %rcx, 0x2d80(%rbx)
movq 0x2d88(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34eb(%rip), %rcx      # 0x1355f8
movq %rcx, 0x2d88(%rbx)
testq %rax, %rax
je 0x132126
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x2d70(%rbx), %rsi
leaq 0x2ed0(%rbx), %rdi
callq 0x135fe0
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movq 0x2be0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x354d(%rip), %rcx      # 0x1356ae
movq %rcx, 0x2be0(%rbx)
movq 0x2be8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34c3(%rip), %rcx      # 0x13563e
movq %rcx, 0x2be8(%rbx)
testq %rax, %rax
je 0x132194
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2df0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2df0(%rbx)
movq 0x2e00(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3538(%rip), %rcx      # 0x1356f4
movq %rcx, 0x2e00(%rbx)
movq 0x2e08(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34f0(%rip), %rcx      # 0x1356c6
movq %rcx, 0x2e08(%rbx)
testq %rax, %rax
je 0x1321ef
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x2df0(%rbx), %rsi
leaq 0x2e10(%rbx), %rdi
callq 0x135fe0
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movq 0x2ca0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x351c(%rip), %rcx      # 0x135746
movq %rcx, 0x2ca0(%rbx)
movq 0x2ca8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34c8(%rip), %rcx      # 0x13570c
movq %rcx, 0x2ca8(%rbx)
testq %rax, %rax
je 0x132721
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x132721
movups 0x2ef0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movq 0x2f00(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34fe(%rip), %rcx      # 0x13578c
movq %rcx, 0x2f00(%rbx)
movq 0x2f08(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34b6(%rip), %rcx      # 0x13575e
movq %rcx, 0x2f08(%rbx)
testq %rax, %rax
je 0x1322c1
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2f30(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f30(%rbx)
movq 0x2f40(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34d5(%rip), %rcx      # 0x1357be
movq %rcx, 0x2f40(%rbx)
movq 0x2f48(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x34a1(%rip), %rcx      # 0x1357a4
movq %rcx, 0x2f48(%rbx)
testq %rax, %rax
je 0x13231c
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x2f30(%rbx), %rsi
leaq 0x3090(%rbx), %rdi
callq 0x135fe0
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movq 0x2be0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34e5(%rip), %rcx      # 0x13583c
movq %rcx, 0x2be0(%rbx)
movq 0x2be8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3465(%rip), %rcx      # 0x1357d6
movq %rcx, 0x2be8(%rbx)
testq %rax, %rax
je 0x13238a
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2fb0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fb0(%rbx)
movq 0x2fc0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34bc(%rip), %rcx      # 0x13586e
movq %rcx, 0x2fc0(%rbx)
movq 0x2fc8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3488(%rip), %rcx      # 0x135854
movq %rcx, 0x2fc8(%rbx)
testq %rax, %rax
je 0x1323e5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2fd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fd0(%rbx)
movq 0x2fe0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3493(%rip), %rcx      # 0x1358a0
movq %rcx, 0x2fe0(%rbx)
movq 0x2fe8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x345f(%rip), %rcx      # 0x135886
movq %rcx, 0x2fe8(%rbx)
testq %rax, %rax
je 0x132440
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movq 0x2ca0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34a6(%rip), %rcx      # 0x13590e
movq %rcx, 0x2ca0(%rbx)
movq 0x2ca8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3436(%rip), %rcx      # 0x1358b8
movq %rcx, 0x2ca8(%rbx)
testq %rax, %rax
je 0x132721
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x132721
movups 0x2ef0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ef0(%rbx)
movq 0x2f00(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34c8(%rip), %rcx      # 0x135994
movq %rcx, 0x2f00(%rbx)
movq 0x2f08(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3440(%rip), %rcx      # 0x135926
movq %rcx, 0x2f08(%rbx)
testq %rax, %rax
je 0x1324ff
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2f10(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f10(%rbx)
movq 0x2f20(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34cf(%rip), %rcx      # 0x1359f6
movq %rcx, 0x2f20(%rbx)
movq 0x2f28(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x346b(%rip), %rcx      # 0x1359ac
movq %rcx, 0x2f28(%rbx)
testq %rax, %rax
je 0x13255a
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2f30(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2f30(%rbx)
movq 0x2f40(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34a6(%rip), %rcx      # 0x135a28
movq %rcx, 0x2f40(%rbx)
movq 0x2f48(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3472(%rip), %rcx      # 0x135a0e
movq %rcx, 0x2f48(%rbx)
testq %rax, %rax
je 0x1325b5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2bd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2bd0(%rbx)
movq 0x2be0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34c9(%rip), %rcx      # 0x135aa6
movq %rcx, 0x2be0(%rbx)
movq 0x2be8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3449(%rip), %rcx      # 0x135a40
movq %rcx, 0x2be8(%rbx)
testq %rax, %rax
je 0x132610
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2fb0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fb0(%rbx)
movq 0x2fc0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x34a0(%rip), %rcx      # 0x135ad8
movq %rcx, 0x2fc0(%rbx)
movq 0x2fc8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x346c(%rip), %rcx      # 0x135abe
movq %rcx, 0x2fc8(%rbx)
testq %rax, %rax
je 0x13266b
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2fd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2fd0(%rbx)
movq 0x2fe0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3477(%rip), %rcx      # 0x135b0a
movq %rcx, 0x2fe0(%rbx)
movq 0x2fe8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3443(%rip), %rcx      # 0x135af0
movq %rcx, 0x2fe8(%rbx)
testq %rax, %rax
je 0x1326c6
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2c90(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c90(%rbx)
movq 0x2ca0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x348a(%rip), %rcx      # 0x135b78
movq %rcx, 0x2ca0(%rbx)
movq 0x2ca8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x341a(%rip), %rcx      # 0x135b22
movq %rcx, 0x2ca8(%rbx)
testq %rax, %rax
je 0x132721
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2cb0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cb0(%rbx)
movq 0x2cc0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3455(%rip), %rcx      # 0x135b9e
movq %rcx, 0x2cc0(%rbx)
movq 0x2cc8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x342d(%rip), %rcx      # 0x135b90
movq %rcx, 0x2cc8(%rbx)
testq %rax, %rax
je 0x13277c
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2cd0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cd0(%rbx)
movq 0x2ce0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3420(%rip), %rcx      # 0x135bc4
movq %rcx, 0x2ce0(%rbx)
movq 0x2ce8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33f8(%rip), %rcx      # 0x135bb6
movq %rcx, 0x2ce8(%rbx)
testq %rax, %rax
je 0x1327d7
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2cf0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2cf0(%rbx)
movq 0x2d00(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x33eb(%rip), %rcx      # 0x135bea
movq %rcx, 0x2d00(%rbx)
movq 0x2d08(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33c3(%rip), %rcx      # 0x135bdc
movq %rcx, 0x2d08(%rbx)
testq %rax, %rax
je 0x132832
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $0x20, %rsp
popq %rbx
retq
leaq 0x17b5a(%rip), %rdi     # 0x14a399
leaq 0x28d44(%rip), %rsi     # 0x15b58a
leaq 0x28e07(%rip), %rcx     # 0x15b654
movl $0x1a8, %edx            # imm = 0x1A8
callq 0xb200
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
jmp 0x132881
movq %rax, %rdi
callq 0x171a3
nop