// File: /workspace/github_cpp_makefile_star2_O1/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
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x32e0(%rip), %rcx      # 0x118040
movq %rcx, 0x18(%rsp)
leaq 0x3360(%rip), %rdx      # 0x1180cc
movq %rdx, 0x10(%rsp)
movups 0x2880(%rdi), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2880(%rdi)
movq 0x2890(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2890(%rdi)
movq 0x2898(%rdi), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2898(%rdi)
testq %rax, %rax
je 0x114dbb
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x331b(%rip), %rcx      # 0x1180e4
movq %rcx, 0x18(%rsp)
leaq 0x3311(%rip), %rdx      # 0x1180e6
movq %rdx, 0x10(%rsp)
movups 0x2920(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2920(%rbx)
movq 0x2930(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2930(%rbx)
movq 0x2938(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2938(%rbx)
testq %rax, %rax
je 0x114e24
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x32cc(%rip), %rcx      # 0x1180fe
movq %rcx, 0x18(%rsp)
leaq 0x330c(%rip), %rdx      # 0x11814a
movq %rdx, 0x10(%rsp)
movups 0x2960(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2960(%rbx)
movq 0x2970(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2970(%rbx)
movq 0x2978(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2978(%rbx)
testq %rax, %rax
je 0x114e8d
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x32c7(%rip), %rcx      # 0x118162
movq %rcx, 0x18(%rsp)
leaq 0x32c9(%rip), %rdx      # 0x118170
movq %rdx, 0x10(%rsp)
movups 0x2980(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2980(%rbx)
movq 0x2990(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2990(%rbx)
movq 0x2998(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2998(%rbx)
testq %rax, %rax
je 0x114ef6
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x3284(%rip), %rcx      # 0x118188
movq %rcx, 0x18(%rsp)
leaq 0x3286(%rip), %rdx      # 0x118196
movq %rdx, 0x10(%rsp)
movups 0x29a0(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x29a0(%rbx)
movq 0x29b0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x29b0(%rbx)
movq 0x29b8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x29b8(%rbx)
testq %rax, %rax
je 0x114f5f
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x3241(%rip), %rcx      # 0x1181ae
movq %rcx, 0x18(%rsp)
leaq 0x3243(%rip), %rdx      # 0x1181bc
movq %rdx, 0x10(%rsp)
movups 0x29c0(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x29c0(%rbx)
movq 0x29d0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x29d0(%rbx)
movq 0x29d8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x29d8(%rbx)
testq %rax, %rax
je 0x114fc8
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x31fe(%rip), %rcx      # 0x1181d4
movq %rcx, 0x18(%rsp)
leaq 0x3220(%rip), %rdx      # 0x118202
movq %rdx, 0x10(%rsp)
movups 0x29e0(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x29e0(%rbx)
movq 0x29f0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x29f0(%rbx)
movq 0x29f8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x29f8(%rbx)
testq %rax, %rax
je 0x115031
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x31db(%rip), %rcx      # 0x11821a
movq %rcx, 0x18(%rsp)
leaq 0x31fd(%rip), %rdx      # 0x118248
movq %rdx, 0x10(%rsp)
movups 0x2b80(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2b80(%rbx)
movq 0x2b90(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2b90(%rbx)
movq 0x2b98(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2b98(%rbx)
testq %rax, %rax
je 0x11509a
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x31b8(%rip), %rcx      # 0x118260
movq %rcx, 0x18(%rsp)
leaq 0x3204(%rip), %rdx      # 0x1182b8
movq %rdx, 0x10(%rsp)
movups 0x2a00(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2a00(%rbx)
movq 0x2a10(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2a10(%rbx)
movq 0x2a18(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2a18(%rbx)
testq %rax, %rax
je 0x115103
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x31bf(%rip), %rcx      # 0x1182d0
movq %rcx, 0x18(%rsp)
leaq 0x31b5(%rip), %rdx      # 0x1182d2
movq %rdx, 0x10(%rsp)
movups 0x2a40(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2a40(%rbx)
movq 0x2a50(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2a50(%rbx)
movq 0x2a58(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2a58(%rbx)
testq %rax, %rax
je 0x11516c
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x3170(%rip), %rcx      # 0x1182ea
movq %rcx, 0x18(%rsp)
leaq 0x3166(%rip), %rdx      # 0x1182ec
movq %rdx, 0x10(%rsp)
movups 0x2a60(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2a60(%rbx)
movq 0x2a70(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2a70(%rbx)
movq 0x2a78(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2a78(%rbx)
testq %rax, %rax
je 0x1151d5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x3121(%rip), %rcx      # 0x118304
movq %rcx, 0x18(%rsp)
leaq 0x312f(%rip), %rdx      # 0x11831e
movq %rdx, 0x10(%rsp)
movups 0x2a80(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2a80(%rbx)
movq 0x2a90(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2a90(%rbx)
movq 0x2a98(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2a98(%rbx)
testq %rax, %rax
je 0x11523e
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x30ea(%rip), %rcx      # 0x118336
movq %rcx, 0x18(%rsp)
leaq 0x30f8(%rip), %rdx      # 0x118350
movq %rdx, 0x10(%rsp)
movups 0x2aa0(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2aa0(%rbx)
movq 0x2ab0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2ab0(%rbx)
movq 0x2ab8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2ab8(%rbx)
testq %rax, %rax
je 0x1152a7
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x30b3(%rip), %rcx      # 0x118368
movq %rcx, 0x18(%rsp)
leaq 0x30df(%rip), %rdx      # 0x1183a0
movq %rdx, 0x10(%rsp)
movups 0x2ae0(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2ae0(%rbx)
movq 0x2af0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2af0(%rbx)
movq 0x2af8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2af8(%rbx)
testq %rax, %rax
je 0x115310
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x309a(%rip), %rcx      # 0x1183b8
movq %rcx, 0x18(%rsp)
leaq 0x30a8(%rip), %rdx      # 0x1183d2
movq %rdx, 0x10(%rsp)
movups 0x2c20(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2c20(%rbx)
movq 0x2c30(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2c30(%rbx)
movq 0x2c38(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2c38(%rbx)
testq %rax, %rax
je 0x115379
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x3063(%rip), %rcx      # 0x1183ea
movq %rcx, 0x18(%rsp)
leaq 0x3071(%rip), %rdx      # 0x118404
movq %rdx, 0x10(%rsp)
movups 0x2c40(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x2c40(%rbx)
movq 0x2c50(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2c50(%rbx)
movq 0x2c58(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2c58(%rbx)
testq %rax, %rax
je 0x1153e2
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x2960(%rbx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x3025(%rip), %rcx      # 0x11841c
movq %rcx, 0x18(%rsp)
leaq 0x309b(%rip), %rdx      # 0x11849e
movq %rdx, 0x10(%rsp)
movups (%rax), %xmm1
movaps %xmm1, (%rsp)
movups %xmm0, (%rax)
movq 0x2970(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x2970(%rbx)
movq 0x2978(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x2978(%rbx)
testq %rax, %rax
je 0x11544a
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $0x20, %rsp
popq %rbx
retq
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
jmp 0x115470
movq %rax, %rdi
callq 0x1718f