// File: /workspace/github_cpp_makefile_star2_O1/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, %eax
shll $0x4, %eax
movq 0x1e0(%rdi), %rcx
movl 0x1c8(%rdi), %edx
cmpb $0x1, 0x1cc(%rdi)
jne 0x2273d
movq 0x130(%rcx), %rdi
addq %rax, (%rdi,%rdx,8)
movl $0x160, %edi            # imm = 0x160
cmpl $0x1, %esi
ja 0x22752
jmp 0x2275d
movq 0x148(%rcx), %rdi
addq %rax, (%rdi,%rdx,8)
movl $0x178, %edi            # imm = 0x178
cmpl $0x2, %esi
jb 0x2275d
addl $-0x10, %eax
movq (%rcx,%rdi), %rcx
addq %rax, (%rcx,%rdx,8)
movl 0x10(%rbx), %eax
cmpl $0x2, %eax
je 0x227dd
cmpl $0x1, %eax
je 0x227d6
testl %eax, %eax
jne 0x22823
movq 0x1e0(%r14), %rax
movl 0x1c8(%r14), %ecx
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 0x227d0
movl %edx, %esi
andl $-0x8, %esi
cmpl $0x18, %esi
setne %dil
cmpl $0x5f, %edx
setne %r8b
testb %dil, %r8b
jne 0x22806
subq $-0x80, %rax
jmp 0x227f0
movl $0xc8, %eax
jmp 0x227e2
movl $0xe0, %eax
addq 0x1e0(%r14), %rax
movl 0x1c8(%r14), %ecx
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 0x22815
cmpl $0x77, %edx
je 0x22815
cmpl $0x28, %edx
jne 0x2281b
addq $0x68, %rax
jmp 0x227f0
addq $0x98, %rax
jmp 0x227f0
movq 0x197c6(%rip), %rdi     # 0x3bff0
leaq 0xe7f1(%rip), %r12      # 0x31022
movq %r12, %rsi
callq 0x42e0
leaq 0x10f0f(%rip), %r13     # 0x3374f
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
leaq 0xefe5(%rip), %rbp      # 0x31837
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42e0
movq %rax, %rdi
movl $0x88, %esi
callq 0x4500
leaq 0xe7d0(%rip), %r15      # 0x31041
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
addq $0x20, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x4290
leaq 0x10ece(%rip), %rsi     # 0x33760
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
movq 0x19747(%rip), %rdi     # 0x3bff0
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 0xe79c(%rip), %rsi      # 0x31082
movq %rax, %rdi
callq 0x42e0
movl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x4500
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360