// File: estwings57[P]CasHMC/sources/LinkMaster.cpp
// Function: CasHMC::LinkMaster::UpdateToken(CasHMC::Packet*)
void LinkMaster::UpdateToken(Packet *packet)
{
	if(packet->RTC != 0) {
		tokenCount += packet->RTC;
		DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<(downstream ? "Down) " : "Up)   ")<<"Extracted RTC : "<<packet->RTC<<"  TOKEN COUNT register : "<<tokenCount);
		if(tokenCount > MAX_LINK_BUF) {
			ERROR(header<<"  == Error - TOKEN COUNT register is over the maximum  (CurrentClock : "<<currentClockCycle<<")");
			exit(0);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x43c(%rax)
je 0x3cebc
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x43c(%rcx), %ecx
addl 0x208(%rax), %ecx
movl %ecx, 0x208(%rax)
leaq 0x2985e(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3ce00
leaq 0x2984f(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x3ce00
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
movq 0x292d6(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x48(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x48(%rbp), %rdi
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %esi
callq 0x4550
movq -0x28(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x40(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x40(%rbp), %rdi
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
callq 0x4440
movq %rax, -0x38(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x38(%rbp), %rdi
movb %al, -0x1d(%rbp)
movzbl -0x1d(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x44960
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x30(%rbp)
testb $0x1, 0x1cc(%rax)
je 0x3cd95
leaq 0x168b9(%rip), %rax     # 0x53648
movq %rax, -0x50(%rbp)
jmp 0x3cda2
leaq 0x168b3(%rip), %rax     # 0x5364f
movq %rax, -0x50(%rbp)
jmp 0x3cda2
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x4380
movq %rax, %rdi
leaq 0x169c6(%rip), %rsi     # 0x5377f
callq 0x4380
movq %rax, %rdi
movq -0x10(%rbp), %rax
movl 0x43c(%rax), %esi
callq 0x44c0
movq %rax, %rdi
leaq 0x169b6(%rip), %rsi     # 0x53790
callq 0x4380
movq %rax, %rdi
movq -0x28(%rbp), %rax
movl 0x208(%rax), %esi
callq 0x44c0
movq %rax, %rdi
movq 0x291b5(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0x28(%rbp), %rax
movl 0x208(%rax), %eax
leaq 0x29747(%rip), %rcx     # 0x66558
cmpl (%rcx), %eax
jbe 0x3ceba
movq 0x291d0(%rip), %rdi     # 0x65ff0
leaq 0x14213(%rip), %rsi     # 0x5103a
callq 0x4380
movq %rax, %rdi
leaq 0x16974(%rip), %rsi     # 0x537aa
callq 0x4380
movq %rax, %rdi
leaq 0x149f0(%rip), %rsi     # 0x51835
callq 0x4380
movq %rax, %rdi
movl $0x71, %esi
callq 0x4610
movq %rax, %rdi
leaq 0x141f8(%rip), %rsi     # 0x51059
callq 0x4380
movq -0x28(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x16941(%rip), %rsi     # 0x537c1
callq 0x4380
movq %rax, %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x174da(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x29102(%rip), %rsi     # 0x65fb0
callq 0x43c0
xorl %edi, %edi
callq 0x4460
jmp 0x3cebc
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)