// File: /workspace/github_cpp_makefile_star2_O3/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 0x22029
movq 0x130(%rax), %rdi
addq %rdx, (%rdi,%rcx,8)
movl $0x160, %edi            # imm = 0x160
cmpl $0x1, %esi
ja 0x2203e
jmp 0x22049
movq 0x148(%rax), %rdi
addq %rdx, (%rdi,%rcx,8)
movl $0x178, %edi            # imm = 0x178
cmpl $0x2, %esi
jb 0x22049
addl $-0x10, %edx
movq (%rax,%rdi), %rsi
addq %rdx, (%rsi,%rcx,8)
movl 0x10(%rbx), %edx
cmpl $0x2, %edx
je 0x220bc
cmpl $0x1, %edx
je 0x220b4
testl %edx, %edx
jne 0x220f5
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 0x220ae
movl %edx, %esi
andl $-0x8, %esi
cmpl $0x18, %esi
setne %dil
cmpl $0x5f, %edx
setne %r8b
testb %dil, %r8b
jne 0x220d8
subq $-0x80, %rax
jmp 0x220c2
addq $0xc8, %rax
jmp 0x220c2
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 0x220e7
cmpl $0x77, %edx
je 0x220e7
cmpl $0x28, %edx
jne 0x220ed
addq $0x68, %rax
jmp 0x220c2
addq $0x98, %rax
jmp 0x220c2
movq 0x18ef4(%rip), %rdi     # 0x3aff0
leaq 0xdf1f(%rip), %r12      # 0x30022
movq %r12, %rsi
callq 0x42e0
leaq 0x106c5(%rip), %r13     # 0x327d7
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
leaq 0xe773(%rip), %rbp      # 0x30897
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42e0
movq %rax, %rdi
movl $0x88, %esi
callq 0x4500
leaq 0xdefe(%rip), %r15      # 0x30041
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
addq $0x20, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x4290
leaq 0x10684(%rip), %rsi     # 0x327e8
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
movq 0x18e75(%rip), %rdi     # 0x3aff0
movq %r12, %rsi
callq 0x42e0
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42e0
movq %rax, %rdi
movl $0x89, %esi
callq 0x4500
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
leaq 0xdeca(%rip), %rsi      # 0x30082
movq %rax, %rdi
callq 0x42e0
movl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x4500
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360