// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x1e5a(%rip), %rcx      # 0x1474e4
movq %rcx, 0x18(%rsp)
leaq 0x1e8c(%rip), %rdx      # 0x147522
movq %rdx, 0x10(%rsp)
movups 0x3c0(%rdi), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x3c0(%rdi)
movq 0x3d0(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x3d0(%rdi)
movq 0x3d8(%rdi), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x3d8(%rdi)
testq %rax, %rax
je 0x1456e5
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x1e47(%rip), %rcx      # 0x14753a
movq %rcx, 0x18(%rsp)
leaq 0x1ec3(%rip), %rdx      # 0x1475c2
movq %rdx, 0x10(%rsp)
movups 0x540(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x540(%rbx)
movq 0x550(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x550(%rbx)
movq 0x558(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x558(%rbx)
testq %rax, %rax
je 0x14574e
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x3c0(%rbx), %rsi
leaq 0x540(%rbx), %r14
leaq 0x3e0(%rbx), %rdi
callq 0x147c22
leaq 0x560(%rbx), %rdi
movq %r14, %rsi
callq 0x147c22
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x1e55(%rip), %rcx      # 0x1475da
movq %rcx, 0x18(%rsp)
leaq 0x1e7d(%rip), %rdx      # 0x14760e
movq %rdx, 0x10(%rsp)
movups 0x440(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x440(%rbx)
movq 0x450(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x450(%rbx)
movq 0x458(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x458(%rbx)
testq %rax, %rax
je 0x1457e0
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
leaq 0x1e38(%rip), %rcx      # 0x147626
movq %rcx, 0x18(%rsp)
leaq 0x1e6a(%rip), %rdx      # 0x147664
movq %rdx, 0x10(%rsp)
movups 0x460(%rbx), %xmm0
movaps %xmm0, (%rsp)
movups %xmm1, 0x460(%rbx)
movq 0x470(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x470(%rbx)
movq 0x478(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x478(%rbx)
testq %rax, %rax
je 0x145849
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0x1e25(%rip), %rcx      # 0x14767c
movq %rcx, 0x18(%rsp)
leaq 0x1e57(%rip), %rdx      # 0x1476ba
movq %rdx, 0x10(%rsp)
movups 0x4a0(%rbx), %xmm1
movaps %xmm1, (%rsp)
movups %xmm0, 0x4a0(%rbx)
movq 0x4b0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x4b0(%rbx)
movq 0x4b8(%rbx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x4b8(%rbx)
testq %rax, %rax
je 0x1458b2
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
jmp 0x1458c2
jmp 0x1458c2
jmp 0x1458c2
jmp 0x1458c2
movq %rax, %rdi
callq 0x1718f