// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/WideIO.cpp
// Function: ramulator::WideIO::init_prereq()
void WideIO::init_prereq()
{
    // RD
    prereq[int(Level::Rank)][int(Command::RD)] = [] (DRAM<WideIO>* node, Command cmd, int id) {
        switch (int(node->state)) {
            case int(State::PowerUp): return Command::MAX;
            case int(State::ActPowerDown): return Command::PDX;
            case int(State::PrePowerDown): return Command::PDX;
            case int(State::SelfRefresh): return Command::SREFX;
            default: assert(false);
        }};
    prereq[int(Level::Bank)][int(Command::RD)] = [] (DRAM<WideIO>* node, Command cmd, int id) {
        switch (int(node->state)) {
            case int(State::Closed): return Command::ACT;
            case int(State::Opened):
                if (node->row_state.find(id) != node->row_state.end())
                    return cmd;
                return Command::PRE;
            default: assert(false);
        }};

    // WR
    prereq[int(Level::Rank)][int(Command::WR)] = prereq[int(Level::Rank)][int(Command::RD)];
    prereq[int(Level::Bank)][int(Command::WR)] = prereq[int(Level::Bank)][int(Command::RD)];

    // REF
    prereq[int(Level::Rank)][int(Command::REF)] = [] (DRAM<WideIO>* node, Command cmd, int id) {
        for (auto bank : node->children) {
            if (bank->state == State::Closed)
                continue;
            return Command::PRA;
        }
        return Command::REF;};

    // PD
    prereq[int(Level::Rank)][int(Command::PD)] = [] (DRAM<WideIO>* node, Command cmd, int id) {
        switch (int(node->state)) {
            case int(State::PowerUp): return Command::PD;
            case int(State::ActPowerDown): return Command::PD;
            case int(State::PrePowerDown): return Command::PD;
            case int(State::SelfRefresh): return Command::SREFX;
            default: assert(false);
        }};

    // SR
    prereq[int(Level::Rank)][int(Command::SREF)] = [] (DRAM<WideIO>* node, Command cmd, int id) {
        switch (int(node->state)) {
            case int(State::PowerUp): return Command::SREF;
            case int(State::ActPowerDown): return Command::PDX;
            case int(State::PrePowerDown): return Command::PDX;
            case int(State::SelfRefresh): return Command::SREF;
            default: assert(false);
        }};
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x3c0(%rdi), %r14
movups 0x3c0(%rdi), %xmm0
movq %rsp, %r15
movaps %xmm0, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x3c0(%rdi)
movups 0x3d0(%rdi), %xmm0
leaq 0x124d(%rip), %rax      # 0xcc114
movq %rax, 0x3d0(%rdi)
movaps %xmm0, 0x10(%r15)
leaq 0x11fe(%rip), %rax      # 0xcc0d8
movq %rax, 0x3d8(%rdi)
movq %r15, %rdi
callq 0x96b6a
leaq 0x540(%rbx), %r12
movups 0x540(%rbx), %xmm0
movaps %xmm0, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x540(%rbx)
movups 0x550(%rbx), %xmm0
leaq 0x1283(%rip), %rax      # 0xcc196
movq %rax, 0x550(%rbx)
movaps %xmm0, 0x10(%r15)
leaq 0x1206(%rip), %rax      # 0xcc12c
movq %rax, 0x558(%rbx)
movq %rsp, %r15
movq %r15, %rdi
callq 0x96b6a
leaq 0x3e0(%rbx), %rdi
movq %r14, %rsi
callq 0xcc754
leaq 0x560(%rbx), %rdi
movq %r12, %rsi
callq 0xcc754
movups 0x440(%rbx), %xmm0
movaps %xmm0, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x440(%rbx)
movups 0x450(%rbx), %xmm0
leaq 0x1265(%rip), %rax      # 0xcc1de
movq %rax, 0x450(%rbx)
movaps %xmm0, 0x10(%r15)
leaq 0x1222(%rip), %rax      # 0xcc1ae
movq %rax, 0x458(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x460(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x460(%rbx)
movups 0x470(%rbx), %xmm0
leaq 0x1271(%rip), %rax      # 0xcc232
movq %rax, 0x470(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x1222(%rip), %rax      # 0xcc1f6
movq %rax, 0x478(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x96b6a
movups 0x4a0(%rbx), %xmm0
movaps %xmm0, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x4a0(%rbx)
movups 0x4b0(%rbx), %xmm0
leaq 0x127f(%rip), %rax      # 0xcc288
movq %rax, 0x4b0(%rbx)
movaps %xmm0, 0x10(%r14)
leaq 0x122e(%rip), %rax      # 0xcc24a
movq %rax, 0x4b8(%rbx)
movq %rsp, %rdi
callq 0x96b6a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop