// File: /workspace/github_cpp_makefile_star2_O3/dramninjasUMD[P]BOBSim/SimpleController.cpp
// Function: BOBSim::SimpleController::IsIssuable(BOBSim::BusPacket*)
bool SimpleController::IsIssuable(BusPacket *busPacket)
{
	unsigned rank = busPacket->rank;
	unsigned bank = busPacket->bank;

	//if((channel->readReturnQueue.size()+outstandingReads) * TRANSACTION_SIZE >= CHANNEL_RETURN_Q_MAX)
	//if((channel->readReturnQueue.size()) * TRANSACTION_SIZE >= CHANNEL_RETURN_Q_MAX)
	//	{
	//RRQFull++;
	//DEBUG("!!!!!!!!!"<<*busPacket)
	//exit(0);
	//return false;
	//}


	switch(busPacket->busPacketType)
	{
	case READ_P:
		if(bankStates[rank][bank].currentBankState == ROW_ACTIVE &&
		        bankStates[rank][bank].openRowAddress == busPacket->row &&
		        currentClockCycle >= bankStates[rank][bank].nextRead &&
		        (channel->readReturnQueue.size()+outstandingReads) * TRANSACTION_SIZE < CHANNEL_RETURN_Q_MAX)
		{
			return true;
		}
		else
		{

			if((channel->readReturnQueue.size()+outstandingReads) * TRANSACTION_SIZE >= CHANNEL_RETURN_Q_MAX)
			{
				RRQFull++;
			}

			return false;
		}

		break;
	case WRITE_P:
		if(bankStates[rank][bank].currentBankState == ROW_ACTIVE &&
		        bankStates[rank][bank].openRowAddress == busPacket->row &&
		        currentClockCycle >= bankStates[rank][bank].nextWrite &&
		        (channel->readReturnQueue.size()+outstandingReads) * TRANSACTION_SIZE < CHANNEL_RETURN_Q_MAX)
		{
			return true;
		}
		else
		{
			if((channel->readReturnQueue.size()+outstandingReads) * TRANSACTION_SIZE >= CHANNEL_RETURN_Q_MAX)
			{
				RRQFull++;
			}
			return false;
		}
		break;
	case ACTIVATE:
		if(bankStates[rank][bank].currentBankState == IDLE &&
		        currentClockCycle >= bankStates[rank][bank].nextActivate &&
		        refreshCounters[rank]>0 &&
		        tFAWWindow[rank].size()<4)
		{
			return true;
		}
		else return false;
		break;
	default:
		ERROR("== Error - Checking issuability on unknown packet type: " << *busPacket);
		exit(0);
	}
}

// Assembly:
pushq %rbx
movl 0x14(%rsi), %edx
movl 0x4(%rsi), %eax
movl 0x10(%rsi), %ecx
cmpl $0x4, %eax
je 0x11839
movq %rsi, %rbx
cmpl $0x3, %eax
je 0x1173c
cmpl $0x1, %eax
jne 0x11889
movabsq $0x3fffffffffffff0, %rax # imm = 0x3FFFFFFFFFFFFF0
movq 0x78(%rdi), %rsi
movq (%rsi,%rdx,8), %rdx
shlq $0x6, %rcx
cmpl $0x1, (%rdx,%rcx)
jne 0x117d1
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
cmpl 0xc(%rbx), %ecx
jne 0x117d1
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdx), %rcx
jae 0x1176d
jmp 0x117d1
movabsq $0x3fffffffffffff0, %rax # imm = 0x3FFFFFFFFFFFFF0
movq 0x78(%rdi), %rsi
movq (%rsi,%rdx,8), %rdx
shlq $0x6, %rcx
cmpl $0x1, (%rdx,%rcx)
jne 0x117d1
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
cmpl 0xc(%rbx), %ecx
jne 0x117d1
movq 0x8(%rdi), %rcx
cmpq 0x18(%rdx), %rcx
jb 0x117d1
movq 0x170(%rdi), %rcx
movq 0x248(%rcx), %rdx
movq %rdx, %rsi
subq 0x228(%rcx), %rsi
shrq $0x3, %rsi
cmpq $0x1, %rdx
adcq $-0x1, %rsi
shlq $0x6, %rsi
movq 0x220(%rcx), %rdx
movq 0x230(%rcx), %r8
subq 0x238(%rcx), %r8
shrq $0x3, %r8
subq 0x210(%rcx), %rdx
shrq $0x3, %rdx
movl 0xf0(%rdi), %ecx
addq %r8, %rcx
addq %rdx, %rcx
addq %rsi, %rcx
testq %rax, %rcx
je 0x11885
movq 0x170(%rdi), %rcx
movq 0x248(%rcx), %rdx
movq %rdx, %rsi
subq 0x228(%rcx), %rsi
shrq $0x3, %rsi
cmpq $0x1, %rdx
adcq $-0x1, %rsi
shlq $0x6, %rsi
movq 0x220(%rcx), %rdx
movq 0x230(%rcx), %r8
subq 0x238(%rcx), %r8
shrq $0x3, %r8
subq 0x210(%rcx), %rdx
shrq $0x3, %rdx
movl 0xf0(%rdi), %ecx
addq %r8, %rcx
addq %rdx, %rcx
addq %rsi, %rcx
testq %rax, %rcx
je 0x11881
incl 0xec(%rdi)
jmp 0x11881
movq 0x78(%rdi), %rax
movq (%rax,%rdx,8), %rax
shlq $0x6, %rcx
cmpl $0x0, (%rax,%rcx)
jne 0x11881
addq %rcx, %rax
movq 0x8(%rdi), %rcx
cmpq 0x8(%rax), %rcx
jb 0x11881
movq 0xc8(%rdi), %rax
cmpl $0x0, (%rax,%rdx,4)
je 0x11881
movq 0xb0(%rdi), %rax
leaq (%rdx,%rdx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
subq (%rax,%rcx,8), %rdx
movb $0x1, %al
cmpq $0x10, %rdx
jb 0x11883
xorl %eax, %eax
popq %rbx
retq
movb $0x1, %al
jmp 0x11883
movq 0x7760(%rip), %rdi      # 0x18ff0
leaq 0x1931(%rip), %rsi      # 0x131c8
callq 0x31c0
leaq 0x31dd(%rip), %rsi      # 0x14a80
movq %rax, %rdi
callq 0x31c0
leaq 0x18bf(%rip), %rsi      # 0x13171
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
movl $0x259, %esi            # imm = 0x259
callq 0x3330
leaq 0x190b(%rip), %rsi      # 0x131d9
movq %rax, %rdi
callq 0x31c0
leaq 0x31e9(%rip), %rsi      # 0x14ac6
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0xc7bb
movq %rax, %rdi
callq 0x30d0
xorl %edi, %edi
callq 0x3220
nop