// File: probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryPid13()
void Signal::tryPid13()
// GD 2009 Added comment:  Decode assumes frame contains at least one 1 bit
{
	// {37.9k,1082}<0,-1|1,-0>(1,-1,F:6,-26)+
	if ( nFrameL > 5 )	
		return;
	if (   pFrame[0] < 900.
		|| pFrame[0] > 1200. )
	{
		return;
	}

	if ( ! framed(nTotDur) )
		return;
	m_rawUnit =  1. / pFrame[0];
	m_rawPulseAdjust = .4f;  // Pulse from -.4 to +.2
	m_rawGapAdjust = .2f;    // Gap from -.2 to +.4
	m_rawErrorLimit = .6f;

	cleanup();
	pBit += 1;
	if ( ! decodeRaw(7) || pBit < pFrameEnd )	
	{
		return;
	}

	// GD 2009 Start: Add any trailing 0's concatenated with lead-out into 
	// nTotDur and re-test framing.  Eliminates spurious decodes of final
	// 2 frames of G.I.4DTV and probably others.
	float n = 7.f;	// number of trailing 0's
	unsigned char xBits = cBits[0];
	for ( ; xBits != 0; n-- ) { xBits >>= 1; }
	if ( ! framed(nTotDur + (n - m_rawGapAdjust) / m_rawUnit ) )
	{
		return;
	}
	// GD 2009 End

	strcpy(pProtocol,"pid-0013");
	*pOBC = getLsb(1,6);
	*pHex = ((msb(cBits[0]) >> 1) & 0x3F) | 0x80;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpl $0x5, 0x48(%rax)
jle 0x1388f
jmp 0x13a58
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x6a59(%rip), %xmm0     # 0x1a300
ucomisd %xmm1, %xmm0
ja 0x138cb
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x6e63(%rip), %xmm1     # 0x1a728
ucomisd %xmm1, %xmm0
jbe 0x138d0
jmp 0x13a58
movq -0x18(%rbp), %rdi
movss 0x98(%rdi), %xmm0
callq 0x18840
cmpl $0x0, %eax
jne 0x138eb
jmp 0x13a58
movq -0x18(%rbp), %rdi
movq 0x38(%rdi), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x68dd(%rip), %xmm0     # 0x1a1e0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xfc(%rdi)
movss 0x6881(%rip), %xmm0     # 0x1a19c
movss %xmm0, 0x100(%rdi)
movss 0x686d(%rip), %xmm0     # 0x1a198
movss %xmm0, 0x104(%rdi)
movss 0x6859(%rip), %xmm0     # 0x1a194
movss %xmm0, 0x108(%rdi)
callq 0x16180
movq -0x18(%rbp), %rdi
movq 0xc8(%rdi), %rax
addq $0x4, %rax
movq %rax, 0xc8(%rdi)
movl $0x7, %esi
callq 0x16540
cmpl $0x0, %eax
je 0x1397e
movq -0x18(%rbp), %rcx
movq 0xc8(%rcx), %rax
cmpq 0x40(%rcx), %rax
jae 0x13983
jmp 0x13a58
movq -0x18(%rbp), %rax
movss 0x6699(%rip), %xmm0     # 0x1a028
movss %xmm0, -0xc(%rbp)
movb 0xa0(%rax), %al
movb %al, -0xd(%rbp)
movzbl -0xd(%rbp), %eax
cmpl $0x0, %eax
je 0x139c3
movzbl -0xd(%rbp), %eax
sarl %eax
movb %al, -0xd(%rbp)
movss 0x66c9(%rip), %xmm0     # 0x1a080
addss -0xc(%rbp), %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x1399d
movq -0x18(%rbp), %rdi
movss 0x98(%rdi), %xmm0
movss -0xc(%rbp), %xmm1
subss 0x104(%rdi), %xmm1
divss 0xfc(%rdi), %xmm1
addss %xmm1, %xmm0
callq 0x18840
cmpl $0x0, %eax
jne 0x139f4
jmp 0x13a58
movq -0x18(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x70b8(%rip), %rsi      # 0x1aabe
callq 0x2120
movq -0x18(%rbp), %rdi
movl $0x1, %esi
movl $0x6, %edx
callq 0x16030
movq -0x18(%rbp), %rdi
movl %eax, %ecx
movq 0x170(%rdi), %rax
movl %ecx, (%rax)
movzbl 0xa0(%rdi), %esi
movl $0x8, %edx
callq 0x15e70
movl %eax, %ecx
movq -0x18(%rbp), %rax
sarl %ecx
andl $0x3f, %ecx
orl $0x80, %ecx
movq 0x178(%rax), %rax
movl %ecx, (%rax)
addq $0x20, %rsp
popq %rbp
retq
nop