// File: /workspace/github_cpp_makefile_star2_O1/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 0x2df3e
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rcx
subq %rax, %rcx
je 0x2dcc5
sarq $0x2, %rcx
movl 0x14(%r14), %edx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movl $0x4, %r12d
cmpl -0x4(%rax,%r12), %edx
je 0x2ddb6
addq $0x4, %r12
decq %rcx
jne 0x2dcb1
movq 0xe324(%rip), %rdi      # 0x3bff0
leaq 0x334f(%rip), %rsi      # 0x31022
callq 0x42e0
leaq 0x6eb1(%rip), %rsi      # 0x34b90
movq %rax, %rdi
callq 0x42e0
leaq 0x3b49(%rip), %rsi      # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x73, %esi
callq 0x4500
leaq 0x3337(%rip), %rsi      # 0x31041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0x6f9a(%rip), %rsi      # 0x34cbf
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x1caba
leaq 0x61a9(%rip), %rsi      # 0x33ee8
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 0x6f07(%rip), %rsi      # 0x34c8b
movq %rax, %rdi
callq 0x42e0
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x66c2(%rip), %rsi      # 0x34461
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360
cmpb $0x1, 0x29(%r14)
jne 0x2def2
cmpb $0x1, 0x30(%r14)
jne 0x2dee7
movq %r14, 0x228(%rbx)
movl $0x1, 0x230(%rbx)
leaq 0xe6a4(%rip), %rax      # 0x3c488
cmpb $0x1, (%rax)
jne 0x2df00
movq 0xe1dc(%rip), %rax      # 0x3bfd0
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 0x2de32
movq %r14, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r14)
movb $0x1, 0xe1(%r14)
movb $0x20, 0xe0(%r14)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0xe187(%rip), %rdi      # 0x3bfd0
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 0x2de90
movq %r15, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x20, 0xe0(%r15)
movq 0x228(%rbx), %rsi
movq %r14, %rdi
callq 0x1caba
movq %rax, %r14
leaq 0x6ded(%rip), %rsi      # 0x34c9e
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 0x2df00
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dfdc
testq %r14, %r14
je 0x2df00
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 0x2df2a
leaq (%rax,%r12), %rdi
addq $-0x4, %rdi
subq %rax, %rdx
subq %r12, %rdx
callq 0x4480
addq $-0x4, 0x240(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xe0ab(%rip), %rdi      # 0x3bff0
leaq 0x30d6(%rip), %rsi      # 0x31022
callq 0x42e0
leaq 0x6c38(%rip), %rsi      # 0x34b90
movq %rax, %rdi
callq 0x42e0
leaq 0x38d0(%rip), %rsi      # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x58, %esi
callq 0x4500
leaq 0x30be(%rip), %rsi      # 0x31041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0x6cb7(%rip), %rsi      # 0x34c55
movq %rax, %rdi
callq 0x42e0
movq 0x268(%rbx), %rsi
movq %rax, %rdi
callq 0x1caba
leaq 0x6cc4(%rip), %rsi      # 0x34c80
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x1caba
leaq 0x6cb4(%rip), %rsi      # 0x34c8a
jmp 0x2dd84
nop