// File: /workspace/github_cpp_makefile_star2_O3/estwings57[P]CasHMC/sources/VaultController.cpp
// Function: CasHMC::VaultController::ReturnCommand(CasHMC::DRAMCommand*)
void VaultController::ReturnCommand(DRAMCommand *retCMD)
{
	//Read and write data commands share one data bus
	if(dataBus != NULL) {
		ERROR(header<<"  == Error - Data Bus Collision  (dataBus:"<<*dataBus<<", retCMD:"<<*retCMD<<")  (CurrentClock : "<<currentClockCycle<<")");
		exit(0);
	}
	
	bool foundMatch = false;
	for(int i=0; i<pendingReadData.size(); i++) {
		if(retCMD->packetTAG == pendingReadData[i]) {
			if(retCMD->lastCMD == true) {
				if(retCMD->atomic) {
					atomicCMD = retCMD;
					atomicOperLeft = 1;
					DE_CR(ALI(18)<<header<<ALI(15)<<*atomicCMD<<"Up)   RETURNING ATOMIC read data");
				}
				else {
					MakeRespondPacket(retCMD);
					delete retCMD;
				}
			}
			else {
				delete retCMD;
			}
			pendingReadData.erase(pendingReadData.begin()+i);
			foundMatch = true;
			break;
		}
	}
	if(!foundMatch) {
		ERROR(header<<"  == Error - Can't find a matching transaction  "<<*retCMD<<" 0x"<<hex<<retCMD->packetTAG<<dec<<"  (CurrentClock : "<<currentClockCycle<<")");
		exit(0);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x268(%rdi)
jne 0x2d5e7
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rcx
subq %rax, %rcx
je 0x2d377
sarq $0x2, %rcx
movl 0x14(%r14), %edx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movl $0x4, %r12d
cmpl -0x4(%rax,%r12), %edx
je 0x2d468
addq $0x4, %r12
decq %rcx
jne 0x2d363
movq 0xdc72(%rip), %rdi      # 0x3aff0
leaq 0x2c9d(%rip), %rsi      # 0x30022
callq 0x42e0
leaq 0x687f(%rip), %rsi      # 0x33c10
movq %rax, %rdi
callq 0x42e0
leaq 0x34f7(%rip), %rsi      # 0x30897
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x73, %esi
callq 0x4500
leaq 0x2c85(%rip), %rsi      # 0x30041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0x6968(%rip), %rsi      # 0x33d3f
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x1c32a
leaq 0x5b73(%rip), %rsi      # 0x32f64
movq %rax, %rdi
callq 0x42e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rax,%rcx)
movl 0x14(%r14), %esi
movq %rax, %rdi
callq 0x43a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x68d5(%rip), %rsi      # 0x33d0b
movq %rax, %rdi
callq 0x42e0
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x6090(%rip), %rsi      # 0x334e1
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360
cmpb $0x1, 0x29(%r14)
jne 0x2d596
cmpb $0x1, 0x30(%r14)
jne 0x2d58b
movq %r14, 0x228(%rbx)
movl $0x1, 0x230(%rbx)
leaq 0xdff2(%rip), %rax      # 0x3b488
cmpb $0x1, (%rax)
jne 0x2d59f
movq 0xdb2a(%rip), %rax      # 0x3afd0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x12, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %r14
cmpb $0x0, 0xe1(%rax,%rcx)
jne 0x2d4dd
movq %r14, %rdi
movl $0x20, %esi
callq 0x42d0
movb $0x1, 0xe1(%r14)
movb $0x20, 0xe0(%r14)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0xdadc(%rip), %rdi      # 0x3afd0
callq 0x4340
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x10(%r14,%rcx)
movq -0x18(%rax), %rax
leaq (%r14,%rax), %r15
cmpb $0x0, 0xe1(%r14,%rax)
jne 0x2d534
movq %r15, %rdi
movl $0x20, %esi
callq 0x42d0
movb $0x1, 0xe1(%r15)
movb $0x20, 0xe0(%r15)
movq 0x228(%rbx), %rsi
movq %r14, %rdi
callq 0x1c32a
movq %rax, %r14
leaq 0x67c9(%rip), %rsi      # 0x33d1e
movl $0x20, %edx
movq %rax, %rdi
callq 0x4340
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
jmp 0x2d59f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2d684
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rdx
leaq (%rax,%r12), %rsi
cmpq %rdx, %rsi
je 0x2d5d0
leaq (%rax,%r12), %rdi
addq $-0x4, %rdi
subq %rax, %rdx
subq %r12, %rdx
callq 0x4480
movq 0x240(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x240(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xda02(%rip), %rdi      # 0x3aff0
leaq 0x2a2d(%rip), %rsi      # 0x30022
callq 0x42e0
leaq 0x660f(%rip), %rsi      # 0x33c10
movq %rax, %rdi
callq 0x42e0
leaq 0x3287(%rip), %rsi      # 0x30897
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x58, %esi
callq 0x4500
leaq 0x2a15(%rip), %rsi      # 0x30041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0x668e(%rip), %rsi      # 0x33cd5
movq %rax, %rdi
callq 0x42e0
movq 0x268(%rbx), %rsi
movq %rax, %rdi
callq 0x1c32a
leaq 0x669b(%rip), %rsi      # 0x33d00
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x1c32a
leaq 0x668b(%rip), %rsi      # 0x33d0a
jmp 0x2d436