// File: /workspace/github_cpp_makefile_star2_O2/estwings57[P]CasHMC/sources/Link.cpp
// Function: CasHMC::Link::UpdateStatistic(CasHMC::Packet*)
void Link::UpdateStatistic(Packet *packet)
{
	if(downstream) {
		statis->downLinkTransmitSize[linkID] += packet->LNG * 16;
		if(packet->LNG > 1) {
			statis->downLinkDataSize[linkID] += (packet->LNG-1) * 16;
		}
	}
	else {
		statis->upLinkTransmitSize[linkID] += packet->LNG * 16;
		if(packet->LNG > 1) {
			statis->upLinkDataSize[linkID] += (packet->LNG-1) * 16;
		}
	}
	
	switch(packet->packetType) {
		case REQUEST:
			statis->reqPerLink[linkID]++;
			packet->trace->linkTransmitTime = linkMasterP->currentClockCycle;

			if((WR16 <= packet->CMD && packet->CMD <= MD_WR)
			|| packet->CMD == WR256
			|| (P_WR16 <= packet->CMD && packet->CMD <= P_WR128)
			|| packet->CMD == P_WR256) {
				statis->writePerLink[linkID]++;
			}
			else if((RD16 <= packet->CMD && packet->CMD <= RD128)
			|| packet->CMD == RD256
			|| packet->CMD == MD_RD) {
				statis->readPerLink[linkID]++;
			}
			else {
				statis->atomicPerLink[linkID]++;
			}
			break;
		case RESPONSE:
			statis->resPerLink[linkID]++;
			break;
		case FLOW:
			statis->flowPerLink[linkID]++;
			break;
		default:
			ERROR(header<<"  == Error - Unknown packet type");
			ERROR("         Type : "<<packet->packetType);
			exit(0);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x430(%rsi), %esi
movl %esi, %edx
shll $0x4, %edx
movq 0x1e0(%rdi), %rax
movl 0x1c8(%rdi), %ecx
cmpb $0x1, 0x1cc(%rdi)
jne 0x19b6d
movq 0x130(%rax), %rdi
addq %rdx, (%rdi,%rcx,8)
movl $0x160, %edi            # imm = 0x160
cmpl $0x1, %esi
ja 0x19b82
jmp 0x19b8d
movq 0x148(%rax), %rdi
addq %rdx, (%rdi,%rcx,8)
movl $0x178, %edi            # imm = 0x178
cmpl $0x2, %esi
jb 0x19b8d
addl $-0x10, %edx
movq (%rax,%rdi), %rsi
addq %rdx, (%rsi,%rcx,8)
movl 0x10(%rbx), %edx
cmpl $0x2, %edx
je 0x19c00
cmpl $0x1, %edx
je 0x19bf8
testl %edx, %edx
jne 0x19c39
movq 0xb0(%rax), %rdx
incq (%rdx,%rcx,8)
movq 0x1d8(%r14), %rdx
movl 0x8(%rdx), %edx
movq 0x8(%rbx), %rsi
movl %edx, 0x10(%rsi)
movl 0x434(%rbx), %edx
leal -0x8(%rdx), %esi
cmpl $0x9, %esi
setb %sil
cmpl $0x4f, %edx
sete %dil
orb %sil, %dil
jne 0x19bf2
movl %edx, %esi
andl $-0x8, %esi
cmpl $0x18, %esi
setne %dil
cmpl $0x5f, %edx
setne %r8b
testb %dil, %r8b
jne 0x19c1c
subq $-0x80, %rax
jmp 0x19c06
addq $0xc8, %rax
jmp 0x19c06
addq $0xe0, %rax
movq (%rax), %rax
incq (%rax,%rcx,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x30, %esi
je 0x19c2b
cmpl $0x77, %edx
je 0x19c2b
cmpl $0x28, %edx
jne 0x19c31
addq $0x68, %rax
jmp 0x19c06
addq $0x98, %rax
jmp 0x19c06
movq 0x173b0(%rip), %rdi     # 0x30ff0
leaq 0xa3db(%rip), %r12      # 0x24022
movq %r12, %rsi
callq 0x4300
leaq 0xcb71(%rip), %r13      # 0x267c7
movq %rax, %rdi
movq %r13, %rsi
callq 0x4300
leaq 0xac0f(%rip), %rbp      # 0x24877
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4300
movq %rax, %rdi
movl $0x88, %esi
callq 0x44f0
leaq 0xa3ba(%rip), %r15      # 0x24041
movq %rax, %rdi
movq %r15, %rsi
callq 0x4300
addq $0x20, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x42b0
leaq 0xcb30(%rip), %rsi      # 0x267d8
movq %rax, %rdi
callq 0x4300
movq %rax, %rdi
callq 0x4180
movq 0x17331(%rip), %rdi     # 0x30ff0
movq %r12, %rsi
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x4300
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4300
movq %rax, %rdi
movl $0x89, %esi
callq 0x44f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4300
leaq 0xa386(%rip), %rsi      # 0x24082
movq %rax, %rdi
callq 0x4300
movl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x44f0
movq %rax, %rdi
callq 0x4180
xorl %edi, %edi
callq 0x4370