// File: /workspace/github_cpp_makefile_star2_O3/dramninjasUMD[P]BOBSim/BOBWrapper.cpp
// Function: BOBSim::BOBWrapper::UpdateLatencyStats(BOBSim::Transaction*)
void BOBWrapper::UpdateLatencyStats(Transaction *returnedRead)
{
	if(returnedRead->transactionType==LOGIC_RESPONSE)
	{
		DEBUG("  == Got Logic Response : "<<*returnedRead);
		DEBUG("  == Logic All Done!");
		DEBUG("  == Took : "<<CPU_CLK_PERIOD*(currentClockCycle - returnedRead->fullStartTime)<<"ns");
		return;
	}
	else if(returnedRead->transactionType==RETURN_DATA)
	{
		returnedRead->fullTimeTotal = currentClockCycle - returnedRead->fullStartTime;
		returnedRead->cyclesRspPort = currentClockCycle - returnedRead->cyclesRspPort;

		unsigned chanID = returnedRead->mappedChannel;

		//add latencies to lists
		perChanFullLatencies[chanID].push_back(returnedRead->fullTimeTotal);
		perChanReqPort[chanID].push_back(returnedRead->cyclesReqPort);
		perChanRspPort[chanID].push_back(returnedRead->cyclesRspPort);
		perChanReqLink[chanID].push_back(returnedRead->cyclesReqLink);
		perChanRspLink[chanID].push_back(returnedRead->cyclesRspLink);
		perChanAccess[chanID].push_back(returnedRead->dramTimeTotal);
		perChanRRQ[chanID].push_back(returnedRead->cyclesInReadReturnQ);
		perChanWorkQTimes[chanID].push_back(returnedRead->cyclesInWorkQueue);
		/*
			DEBUGN("== Read Returned");
			DEBUGN(" full: "<< returnedRead->fullTimeTotal * CPU_CLK_PERIOD<<"ns");
			DEBUGN(" dram: "<< returnedRead->dramTimeTotal * CPU_CLK_PERIOD<<"ns");
			DEBUG(" chan: "<< returnedRead->channelTimeTotal * CPU_CLK_PERIOD<<"ns");
		*/
		fullLatencies.push_back(returnedRead->fullTimeTotal);
		fullSum+=returnedRead->fullTimeTotal;

		dramLatencies.push_back(returnedRead->dramTimeTotal);
		dramSum+=returnedRead->dramTimeTotal;

		chanLatencies.push_back(returnedRead->channelTimeTotal);
		chanSum+=returnedRead->channelTimeTotal;

		//latencies[((returnedRead->fullTimeTotal/10)*10)*CPU_CLK_PERIOD]++;

		returnedReads++;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
cmpl $0x2, %eax
je 0xa67f
cmpl $0x4, %eax
jne 0xa8f6
leaq 0xec34(%rip), %r13      # 0x191d4
cmpl $0x0, (%r13)
je 0xa8f6
movq 0xea16(%rip), %r15      # 0x18fc8
leaq 0x9779(%rip), %rsi      # 0x13d32
movl $0x1a, %edx
movq %r15, %rdi
callq 0x3200
movq %r15, %rdi
movq %r14, %rsi
callq 0x12307
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
cmpl $0x0, (%r13)
je 0xa8f6
leaq 0x9740(%rip), %rsi      # 0x13d4d
movl $0x14, %edx
movq %r15, %rdi
callq 0x3200
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
cmpl $0x0, (%r13)
je 0xa8f6
movq 0xe975(%rip), %r15      # 0x18fc8
leaq 0x9708(%rip), %rsi      # 0x13d62
movl $0xc, %edx
movq %r15, %rdi
callq 0x3200
movq 0x8(%rbx), %rax
subq 0x60(%r14), %rax
js 0xa904
cvtsi2ss %rax, %xmm0
jmp 0xa919
movq 0x8(%rbx), %rcx
movq %rcx, %rax
subq 0x60(%r14), %rax
movq %rax, 0x68(%r14)
subq 0x40(%r14), %rcx
movq %rcx, 0x40(%r14)
movl 0x10(%r14), %ecx
movq 0x170(%rbx), %rdx
leaq (%rcx,%rcx,2), %r15
leaq (%rdx,%r15,8), %rdi
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa6c3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa6cd
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x188(%rbx), %rax
leaq (%rax,%r15,8), %rdi
movl 0x38(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa6f6
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa700
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x1a0(%rbx), %rax
leaq (%rax,%r15,8), %rdi
movl 0x40(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa729
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa733
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x1b8(%rbx), %rax
leaq (%rax,%r15,8), %rdi
movl 0x48(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa75c
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa766
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x1d0(%rbx), %rax
leaq (%rax,%r15,8), %rdi
movl 0x50(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa78f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa799
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x1e8(%rbx), %rax
leaq (%rax,%r15,8), %rdi
movl 0x78(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa7c2
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa7cc
leaq 0xc(%rsp), %rdx
callq 0xc172
movq 0x200(%rbx), %rax
leaq (%rax,%r15,8), %rdi
leaq 0x58(%r14), %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa7f3
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa7f8
callq 0xc292
movq 0x218(%rbx), %rax
leaq (%rax,%r15,8), %rdi
leaq 0x5c(%r14), %rdx
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xa81f
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xa824
callq 0xc292
movl 0x68(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x238(%rbx), %rsi
cmpq 0x240(%rbx), %rsi
je 0xa84b
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x238(%rbx)
jmp 0xa860
leaq 0x230(%rbx), %rdi
leaq 0xc(%rsp), %rdx
callq 0xc172
movl 0x68(%r14), %eax
addl %eax, 0x248(%rbx)
movl 0x78(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x258(%rbx), %rsi
cmpq 0x260(%rbx), %rsi
je 0xa88d
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x258(%rbx)
jmp 0xa8a2
leaq 0x250(%rbx), %rdi
leaq 0xc(%rsp), %rdx
callq 0xc172
movl 0x78(%r14), %eax
addl %eax, 0x268(%rbx)
movl 0x88(%r14), %eax
movl %eax, 0xc(%rsp)
movq 0x278(%rbx), %rsi
cmpq 0x280(%rbx), %rsi
je 0xa8d2
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x278(%rbx)
jmp 0xa8ea
leaq 0x270(%rbx), %rdi
leaq 0xc(%rsp), %rdx
callq 0xc172
movl 0x88(%r14), %eax
addl %eax, 0x288(%rbx)
incl 0x298(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
mulss 0x87d3(%rip), %xmm0     # 0x130f4
cvtss2sd %xmm0, %xmm0
movq %r15, %rdi
callq 0x32e0
movq %rax, %rbx
leaq 0x9551(%rip), %rsi      # 0x13e88
movl $0x2, %edx
movq %rax, %rdi
callq 0x3200
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3130