// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movups 0x2880(%rdi), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2880(%rdi)
movq 0x2890(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x344e(%rip), %rcx      # 0x115110
movq %rcx, 0x2890(%rdi)
movq 0x2898(%rdi), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33a8(%rip), %rcx      # 0x115084
movq %rcx, 0x2898(%rdi)
testq %rax, %rax
je 0x111cf5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2920(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2920(%rbx)
movq 0x2930(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x340d(%rip), %rcx      # 0x11512a
movq %rcx, 0x2930(%rbx)
movq 0x2938(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33f1(%rip), %rcx      # 0x115128
movq %rcx, 0x2938(%rbx)
testq %rax, %rax
je 0x111d50
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2960(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2960(%rbx)
movq 0x2970(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3404(%rip), %rcx      # 0x11517c
movq %rcx, 0x2970(%rbx)
movq 0x2978(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33b0(%rip), %rcx      # 0x115142
movq %rcx, 0x2978(%rbx)
testq %rax, %rax
je 0x111dab
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2980(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2980(%rbx)
movq 0x2990(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x33cf(%rip), %rcx      # 0x1151a2
movq %rcx, 0x2990(%rbx)
movq 0x2998(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x33a7(%rip), %rcx      # 0x115194
movq %rcx, 0x2998(%rbx)
testq %rax, %rax
je 0x111e06
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x29a0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x29a0(%rbx)
movq 0x29b0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x339a(%rip), %rcx      # 0x1151c8
movq %rcx, 0x29b0(%rbx)
movq 0x29b8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3372(%rip), %rcx      # 0x1151ba
movq %rcx, 0x29b8(%rbx)
testq %rax, %rax
je 0x111e61
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x29c0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x29c0(%rbx)
movq 0x29d0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3365(%rip), %rcx      # 0x1151ee
movq %rcx, 0x29d0(%rbx)
movq 0x29d8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x333d(%rip), %rcx      # 0x1151e0
movq %rcx, 0x29d8(%rbx)
testq %rax, %rax
je 0x111ebc
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x29e0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x29e0(%rbx)
movq 0x29f0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3350(%rip), %rcx      # 0x115234
movq %rcx, 0x29f0(%rbx)
movq 0x29f8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3308(%rip), %rcx      # 0x115206
movq %rcx, 0x29f8(%rbx)
testq %rax, %rax
je 0x111f17
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2b80(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2b80(%rbx)
movq 0x2b90(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x333b(%rip), %rcx      # 0x11527a
movq %rcx, 0x2b90(%rbx)
movq 0x2b98(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x32f3(%rip), %rcx      # 0x11524c
movq %rcx, 0x2b98(%rbx)
testq %rax, %rax
je 0x111f72
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2a00(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a00(%rbx)
movq 0x2a10(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3350(%rip), %rcx      # 0x1152ea
movq %rcx, 0x2a10(%rbx)
movq 0x2a18(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x32de(%rip), %rcx      # 0x115292
movq %rcx, 0x2a18(%rbx)
testq %rax, %rax
je 0x111fcd
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2a40(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a40(%rbx)
movq 0x2a50(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x330f(%rip), %rcx      # 0x115304
movq %rcx, 0x2a50(%rbx)
movq 0x2a58(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x32f3(%rip), %rcx      # 0x115302
movq %rcx, 0x2a58(%rbx)
testq %rax, %rax
je 0x112028
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2a60(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a60(%rbx)
movq 0x2a70(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x32ce(%rip), %rcx      # 0x11531e
movq %rcx, 0x2a70(%rbx)
movq 0x2a78(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x32b2(%rip), %rcx      # 0x11531c
movq %rcx, 0x2a78(%rbx)
testq %rax, %rax
je 0x112083
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2a80(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a80(%rbx)
movq 0x2a90(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x32a5(%rip), %rcx      # 0x115350
movq %rcx, 0x2a90(%rbx)
movq 0x2a98(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3271(%rip), %rcx      # 0x115336
movq %rcx, 0x2a98(%rbx)
testq %rax, %rax
je 0x1120de
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2aa0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2aa0(%rbx)
movq 0x2ab0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x327c(%rip), %rcx      # 0x115382
movq %rcx, 0x2ab0(%rbx)
movq 0x2ab8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3248(%rip), %rcx      # 0x115368
movq %rcx, 0x2ab8(%rbx)
testq %rax, %rax
je 0x112139
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2ae0(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2ae0(%rbx)
movq 0x2af0(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3271(%rip), %rcx      # 0x1153d2
movq %rcx, 0x2af0(%rbx)
movq 0x2af8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x321f(%rip), %rcx      # 0x11539a
movq %rcx, 0x2af8(%rbx)
testq %rax, %rax
je 0x112194
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2c20(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c20(%rbx)
movq 0x2c30(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3248(%rip), %rcx      # 0x115404
movq %rcx, 0x2c30(%rbx)
movq 0x2c38(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x3214(%rip), %rcx      # 0x1153ea
movq %rcx, 0x2c38(%rbx)
testq %rax, %rax
je 0x1121ef
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movups 0x2c40(%rbx), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c40(%rbx)
movq 0x2c50(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x321f(%rip), %rcx      # 0x115436
movq %rcx, 0x2c50(%rbx)
movq 0x2c58(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x31eb(%rip), %rcx      # 0x11541c
movq %rcx, 0x2c58(%rbx)
testq %rax, %rax
je 0x11224a
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x2960(%rbx), %rax
movups (%rax), %xmm0
movaps %xmm0, (%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq 0x2970(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x3233(%rip), %rcx      # 0x1154a4
movq %rcx, 0x2970(%rbx)
movq 0x2978(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x31c3(%rip), %rcx      # 0x11544e
movq %rcx, 0x2978(%rbx)
testq %rax, %rax
je 0x1122a4
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $0x20, %rsp
popq %rbx
retq
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
jmp 0x1122ca
movq %rax, %rdi
callq 0x171a3