// File: /workspace/github_cpp_makefile_star2_O1/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 0x11947
movq %rsi, %rbx
cmpl $0x3, %eax
je 0x1184a
cmpl $0x1, %eax
jne 0x11997
movabsq $0x3fffffffffffff0, %rax # imm = 0x3FFFFFFFFFFFFF0
movq 0x78(%rdi), %rsi
movq (%rsi,%rdx,8), %rdx
shlq $0x6, %rcx
cmpl $0x1, (%rdx,%rcx)
jne 0x118df
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
cmpl 0xc(%rbx), %ecx
jne 0x118df
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdx), %rcx
jae 0x1187b
jmp 0x118df
movabsq $0x3fffffffffffff0, %rax # imm = 0x3FFFFFFFFFFFFF0
movq 0x78(%rdi), %rsi
movq (%rsi,%rdx,8), %rdx
shlq $0x6, %rcx
cmpl $0x1, (%rdx,%rcx)
jne 0x118df
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
cmpl 0xc(%rbx), %ecx
jne 0x118df
movq 0x8(%rdi), %rcx
cmpq 0x18(%rdx), %rcx
jb 0x118df
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 0x11993
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 0x1198f
incl 0xec(%rdi)
jmp 0x1198f
movq 0x78(%rdi), %rax
movq (%rax,%rdx,8), %rax
shlq $0x6, %rcx
cmpl $0x0, (%rax,%rcx)
jne 0x1198f
addq %rcx, %rax
movq 0x8(%rdi), %rcx
cmpq 0x8(%rax), %rcx
jb 0x1198f
movq 0xc8(%rdi), %rax
cmpl $0x0, (%rax,%rdx,4)
je 0x1198f
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 0x11991
xorl %eax, %eax
popq %rbx
retq
movb $0x1, %al
jmp 0x11991
movq 0x7652(%rip), %rdi      # 0x18ff0
leaq 0x17d3(%rip), %rsi      # 0x13178
callq 0x31c0
leaq 0x2fd7(%rip), %rsi      # 0x14988
movq %rax, %rdi
callq 0x31c0
leaq 0x1761(%rip), %rsi      # 0x13121
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
movl $0x259, %esi            # imm = 0x259
callq 0x3330
leaq 0x17ad(%rip), %rsi      # 0x13189
movq %rax, %rdi
callq 0x31c0
leaq 0x2fe3(%rip), %rsi      # 0x149ce
movq %rax, %rdi
callq 0x31c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0xc9a7
movq %rax, %rdi
callq 0x30d0
xorl %edi, %edi
callq 0x3220
nop