// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/DSARP.cpp
// Function: ramulator::DSARP::init_lambda()
void DSARP::init_lambda()
{
  // RANK
  lambda[int(Level::Rank)][int(Command::PREA)] = [] (DRAM<DSARP>* node, int id) {
    node->row_state.clear();
    for (auto bank : node->children) {
      bank->state = State::Closed;
      bank->row_state.clear();
      for (auto sa : bank->children){
        sa->state = State::Closed;
        sa->row_state.clear();}}};
  lambda[int(Level::Rank)][int(Command::REF)] = [] (DRAM<DSARP>* node, int id) {};

  // Power down related commands
  lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<DSARP>* 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<DSARP>* node, int id) {
    node->state = State::PowerUp;};
  lambda[int(Level::Rank)][int(Command::SRE)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::SelfRefresh;};
  lambda[int(Level::Rank)][int(Command::SRX)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::PowerUp;};

  // Open a row
  lambda[int(Level::Bank)][int(Command::ACT)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Opened;
    node->row_state[id] = State::Opened;};
  lambda[int(Level::SubArray)][int(Command::ACT)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Opened;
    node->row_state[id] = State::Opened;};

  // Close a bank
  lambda[int(Level::Bank)][int(Command::PRE)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Closed;
    node->row_state.clear();
    for (auto sa : node->children){
      sa->state = State::Closed;
      sa->row_state.clear();}};

  lambda[int(Level::Bank)][int(Command::RD)] = [] (DRAM<DSARP>* node, int id) {};
  lambda[int(Level::Bank)][int(Command::WR)] = [] (DRAM<DSARP>* node, int id) {};

  // Make sure the bank is closed after the column command
  lambda[int(Level::Bank)][int(Command::RDA)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Closed;
    node->row_state.clear();};

  lambda[int(Level::Bank)][int(Command::WRA)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Closed;
    node->row_state.clear();};

  // Nothing much, just make sure the bank is closed
  lambda[int(Level::Bank)][int(Command::REFPB)] = [] (DRAM<DSARP>* node, int id) {
    assert(node->state == State::Closed);
    node->row_state.clear();};

  // COL
  lambda[int(Level::SubArray)][int(Command::RDA)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Closed;
    node->row_state.clear();};
  lambda[int(Level::SubArray)][int(Command::WRA)] = [] (DRAM<DSARP>* node, int id) {
    node->state = State::Closed;
    node->row_state.clear();};

  // PowerDown -- this has not been tested
  lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<DSARP>* 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;};
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movups 0x2880(%rdi), %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2880(%rdi)
movups 0x2890(%rdi), %xmm0
leaq 0x1ebe(%rip), %rax      # 0xa7ca2
movq %rax, 0x2890(%rdi)
movaps %xmm0, 0x10(%r14)
leaq 0x1e1f(%rip), %rax      # 0xa7c16
movq %rax, 0x2898(%rdi)
movq %r14, %rdi
callq 0x96b6a
movups 0x2920(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2920(%rbx)
movups 0x2930(%rbx), %xmm0
leaq 0x1e93(%rip), %rax      # 0xa7cbc
movq %rax, 0x2930(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e7e(%rip), %rax      # 0xa7cba
movq %rax, 0x2938(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2960(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2960(%rbx)
movups 0x2970(%rbx), %xmm0
leaq 0x1e99(%rip), %rax      # 0xa7d0a
movq %rax, 0x2970(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e50(%rip), %rax      # 0xa7cd4
movq %rax, 0x2978(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2980(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2980(%rbx)
movups 0x2990(%rbx), %xmm0
leaq 0x1e77(%rip), %rax      # 0xa7d30
movq %rax, 0x2990(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e56(%rip), %rax      # 0xa7d22
movq %rax, 0x2998(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x29a0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x29a0(%rbx)
movups 0x29b0(%rbx), %xmm0
leaq 0x1e55(%rip), %rax      # 0xa7d56
movq %rax, 0x29b0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e34(%rip), %rax      # 0xa7d48
movq %rax, 0x29b8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x29c0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x29c0(%rbx)
movups 0x29d0(%rbx), %xmm0
leaq 0x1e33(%rip), %rax      # 0xa7d7c
movq %rax, 0x29d0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e12(%rip), %rax      # 0xa7d6e
movq %rax, 0x29d8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x29e0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x29e0(%rbx)
movups 0x29f0(%rbx), %xmm0
leaq 0x1e29(%rip), %rax      # 0xa7dba
movq %rax, 0x29f0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1df0(%rip), %rax      # 0xa7d94
movq %rax, 0x29f8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2b80(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2b80(%rbx)
movups 0x2b90(%rbx), %xmm0
leaq 0x1e1f(%rip), %rax      # 0xa7df8
movq %rax, 0x2b90(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1de6(%rip), %rax      # 0xa7dd2
movq %rax, 0x2b98(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2a00(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a00(%rbx)
movups 0x2a10(%rbx), %xmm0
leaq 0x1e47(%rip), %rax      # 0xa7e68
movq %rax, 0x2a10(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1ddc(%rip), %rax      # 0xa7e10
movq %rax, 0x2a18(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2a40(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a40(%rbx)
movups 0x2a50(%rbx), %xmm0
leaq 0x1e19(%rip), %rax      # 0xa7e82
movq %rax, 0x2a50(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1e04(%rip), %rax      # 0xa7e80
movq %rax, 0x2a58(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2a60(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a60(%rbx)
movups 0x2a70(%rbx), %xmm0
leaq 0x1deb(%rip), %rax      # 0xa7e9c
movq %rax, 0x2a70(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1dd6(%rip), %rax      # 0xa7e9a
movq %rax, 0x2a78(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2a80(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a80(%rbx)
movups 0x2a90(%rbx), %xmm0
leaq 0x1dd5(%rip), %rax      # 0xa7ece
movq %rax, 0x2a90(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1da8(%rip), %rax      # 0xa7eb4
movq %rax, 0x2a98(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2aa0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2aa0(%rbx)
movups 0x2ab0(%rbx), %xmm0
leaq 0x1dbf(%rip), %rax      # 0xa7f00
movq %rax, 0x2ab0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1d92(%rip), %rax      # 0xa7ee6
movq %rax, 0x2ab8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2ae0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ae0(%rbx)
movups 0x2af0(%rbx), %xmm0
leaq 0x1dc7(%rip), %rax      # 0xa7f50
movq %rax, 0x2af0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1d7c(%rip), %rax      # 0xa7f18
movq %rax, 0x2af8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2c20(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c20(%rbx)
movups 0x2c30(%rbx), %xmm0
leaq 0x1db1(%rip), %rax      # 0xa7f82
movq %rax, 0x2c30(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1d84(%rip), %rax      # 0xa7f68
movq %rax, 0x2c38(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2c40(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c40(%rbx)
movups 0x2c50(%rbx), %xmm0
leaq 0x1d9b(%rip), %rax      # 0xa7fb4
movq %rax, 0x2c50(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1d6e(%rip), %rax      # 0xa7f9a
movq %rax, 0x2c58(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x2960(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2960(%rbx)
movups 0x2970(%rbx), %xmm0
leaq 0x1dbf(%rip), %rax      # 0xa8020
movq %rax, 0x2970(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1d58(%rip), %rax      # 0xa7fcc
movq %rax, 0x2978(%rbx)
movq %rsp, %rdi
callq 0x96b6a
addq $0x28, %rsp
popq %rbx
popq %r14
retq
nop