// File: CMU-SAFARI[P]ramulator/src/Controller.h
// Function: ramulator::Controller<ramulator::SALP>::issue_cmd(ramulator::SALP::Command, std::vector<int, std::allocator<int>> const&)
void issue_cmd(typename T::Command cmd, const vector<int>& addr_vec)
    {
        cmd_issue_autoprecharge(cmd, addr_vec);
        assert(is_ready(cmd, addr_vec));
        channel->update(cmd, addr_vec.data(), clk);

        if(cmd == T::Command::PRE){
            if(rowtable->get_hits(addr_vec, true) == 0){
                useless_activates++;
            }
        }
 
        rowtable->update(cmd, addr_vec, clk);
        if (record_cmd_trace){
            // select rank
            auto& file = cmd_trace_files[addr_vec[1]];
            string& cmd_name = channel->spec->command_name[int(cmd)];
            file<<clk<<','<<cmd_name;
            // TODO bad coding here
            if (cmd_name == "PREA" || cmd_name == "REF")
                file<<endl;
            else{
                int bank_id = addr_vec[int(T::Level::Bank)];
                if (channel->spec->standard_name == "DDR4" || channel->spec->standard_name == "GDDR5")
                    bank_id += addr_vec[int(T::Level::Bank) - 1] * channel->spec->org_entry.count[int(T::Level::Bank)];
                file<<','<<bank_id<<endl;
            }
        }
        if (print_cmd_trace){
            printf("%5s %10ld:", channel->spec->command_name[int(cmd)].c_str(), clk);
            for (int lev = 0; lev < int(T::Level::MAX); lev++)
                printf(" %5d", addr_vec[lev]);
            printf("\n");
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq -0x18(%rbp), %rdx
leaq -0xc(%rbp), %rsi
callq 0x783c0
movq -0x38(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x70b70
testb $0x1, %al
jne 0x7744e
jmp 0x77450
jmp 0x7746f
leaq 0x1d9df4(%rip), %rdi    # 0x25124b
leaq 0x1d9e05(%rip), %rsi    # 0x251263
movl $0x259, %edx            # imm = 0x259
leaq 0x1dabfc(%rip), %rcx    # 0x252066
callq 0xc280
movq -0x38(%rbp), %rax
movq 0x1098(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31c80
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq %rax, %rdx
movq -0x38(%rbp), %rax
movq 0x1090(%rax), %rcx
callq 0x788f0
cmpl $0x2, -0xc(%rbp)
jne 0x774df
movq -0x38(%rbp), %rax
movq 0x10b0(%rax), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x6f850
cmpl $0x0, %eax
jne 0x774dd
movq -0x38(%rbp), %rdi
addq $0x718, %rdi            # imm = 0x718
xorl %esi, %esi
callq 0x40970
jmp 0x774df
movq -0x38(%rbp), %rax
movq 0x10b0(%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq 0x1090(%rax), %rcx
callq 0x78940
movq -0x38(%rbp), %rax
testb $0x1, 0x11d8(%rax)
je 0x7767f
movq -0x38(%rbp), %rax
addq $0x11c0, %rax           # imm = 0x11C0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x44ef0
movq -0x50(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2da50
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq 0x1098(%rax), %rcx
movq 0x390(%rcx), %rcx
addq $0x28, %rcx
movslq -0xc(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq 0x1090(%rax), %rsi
callq 0xc600
movq %rax, %rdi
movl $0x2c, %esi
callq 0xc400
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0xc330
movq -0x28(%rbp), %rdi
leaq 0x1d9d55(%rip), %rsi    # 0x2512eb
callq 0x17f10
testb $0x1, %al
jne 0x775b5
movq -0x28(%rbp), %rdi
leaq 0x1ed5b6(%rip), %rsi    # 0x264b60
callq 0x17f10
testb $0x1, %al
jne 0x775b5
jmp 0x775ca
movq -0x20(%rbp), %rdi
movq 0x2d69e0(%rip), %rsi    # 0x34dfa0
callq 0xc3a0
jmp 0x7767d
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0x44ef0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x2c(%rbp)
movq 0x1098(%rax), %rax
movq 0x390(%rax), %rdi
leaq 0x1d85b3(%rip), %rsi    # 0x24fbac
callq 0x17f10
testb $0x1, %al
jne 0x77626
movq -0x38(%rbp), %rax
movq 0x1098(%rax), %rax
movq 0x390(%rax), %rdi
leaq 0x1d8596(%rip), %rsi    # 0x24fbb1
callq 0x17f10
testb $0x1, %al
jne 0x77626
jmp 0x77655
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x44ef0
movq -0x38(%rbp), %rcx
movl (%rax), %eax
movq 0x1098(%rcx), %rcx
movq 0x390(%rcx), %rcx
imull 0x3624(%rcx), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
movl $0x2c, %esi
callq 0xc400
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0xc5c0
movq %rax, %rdi
movq 0x2d6928(%rip), %rsi    # 0x34dfa0
callq 0xc3a0
jmp 0x7767f
movq -0x38(%rbp), %rax
testb $0x1, 0x11d9(%rax)
je 0x77715
movq -0x38(%rbp), %rax
movq 0x1098(%rax), %rax
movq 0x390(%rax), %rdi
addq $0x28, %rdi
movslq -0xc(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0xc1b0
movq %rax, %rsi
movq -0x38(%rbp), %rax
movq 0x1090(%rax), %rdx
leaq 0x1d9c25(%rip), %rdi    # 0x2512f0
movb $0x0, %al
callq 0xc070
movl $0x0, -0x30(%rbp)
cmpl $0x6, -0x30(%rbp)
jge 0x77707
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x44ef0
movl (%rax), %esi
leaq 0x1d9c06(%rip), %rdi    # 0x2512fb
movb $0x0, %al
callq 0xc070
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x776d9
leaq 0x1da099(%rip), %rdi    # 0x2517a7
movb $0x0, %al
callq 0xc070
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)