// File: estwings57[P]CasHMC/sources/LinkMaster.cpp
// Function: CasHMC::LinkMaster::CRCCountdown(int, CasHMC::Packet*)
void LinkMaster::CRCCountdown(int writeP, Packet *packet)
{
	if(CRC_CHECK && !startCRC) {
		startCRC = true;
		countdownCRC = ceil((double)CRC_CAL_CYCLE * packet->LNG);
	}
	
	if(CRC_CHECK && countdownCRC > 0) {
		DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<(downstream ? "Down) " : "Up)   ")
				<<"WAITING CRC calculation ("<<countdownCRC<<"/"<<ceil((double)CRC_CAL_CYCLE*packet->LNG)<<")");
	}
	else {
		UpdateField(writeP, packet);
	}
	countdownCRC = (countdownCRC>0) ? countdownCRC-1 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x2781a(%rip), %rax     # 0x6656c
testb $0x1, (%rax)
je 0x3eda0
movq -0x30(%rbp), %rax
testb $0x1, 0x240(%rax)
jne 0x3eda0
movq -0x30(%rbp), %rax
movb $0x1, 0x240(%rax)
leaq 0x277fa(%rip), %rax     # 0x66570
movsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movl 0x430(%rax), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
callq 0x40a0
movq -0x30(%rbp), %rax
cvttsd2si %xmm0, %ecx
movl %ecx, 0x23c(%rax)
leaq 0x277c5(%rip), %rax     # 0x6656c
testb $0x1, (%rax)
je 0x3ef2d
movq -0x30(%rbp), %rax
cmpl $0x0, 0x23c(%rax)
jle 0x3ef2d
leaq 0x27760(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3ef2b
leaq 0x27751(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x3ef2b
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
movq 0x271d8(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x50(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x50(%rbp), %rdi
movb %al, -0x1d(%rbp)
movzbl -0x1d(%rbp), %esi
callq 0x4550
movq -0x30(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x48(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x48(%rbp), %rdi
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
callq 0x4440
movq %rax, -0x40(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x40(%rbp), %rdi
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x44960
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x38(%rbp)
testb $0x1, 0x1cc(%rax)
je 0x3ee93
leaq 0x147bb(%rip), %rax     # 0x53648
movq %rax, -0x58(%rbp)
jmp 0x3eea0
leaq 0x147b5(%rip), %rax     # 0x5364f
movq %rax, -0x58(%rbp)
jmp 0x3eea0
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x4380
movq %rax, %rdi
leaq 0x14bea(%rip), %rsi     # 0x53aa1
callq 0x4380
movq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x23c(%rax), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x123c0(%rip), %rsi     # 0x51298
callq 0x4380
movq %rax, -0x60(%rbp)
leaq 0x27688(%rip), %rax     # 0x66570
movsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movl 0x430(%rax), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
callq 0x40a0
movq -0x60(%rbp), %rdi
callq 0x4690
movq %rax, %rdi
leaq 0x15462(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2708a(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3ef3d
movq -0x30(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x3ef80
movq -0x30(%rbp), %rax
cmpl $0x0, 0x23c(%rax)
jle 0x3ef5c
movq -0x30(%rbp), %rax
movl 0x23c(%rax), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x3ef63
xorl %eax, %eax
movl %eax, -0x64(%rbp)
jmp 0x3ef63
movq -0x30(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, 0x23c(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)