// File: probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryQ2()
void Signal::tryQ2()
{
	// {38k}<-624,468|468-624>(1820,-590,0:1,D:4,F:7,S:1,C:4,1:1,-???)
	// {38k}<-624,468|468-624>(1820,-590,0:1,D:4,S:6,F:6,C:4,1:1,-???)
	if (   pFrameEnd[0] < 3000.
		|| pFrame[0]    < 1000.
		|| pFrame[0]    > 2000.
		|| pFrame[1]    < 500.
		|| pFrame[1]    > 1300.
		|| sortBurst.max2   > 2300.
		|| sortBurst.max2   > pFrame[0] + pFrame[1]
		|| sortBurst.min1    < 900. )
	{
		return;
	}

	if ( preemptValue >= prQ2 )		// GD 2009  Avoids spurious decode of OrtekMCE
	{
		// the tolerances for OrtekMCE overlap with those for S:17
		// signal, so potentially every OrtekMCE signal could be
		// mistaken for an S:17 one.
		return;
	}

	m_minShortPulse = 200. ;
	m_nominalShortPulse = 468. ;
	m_maxShortPulse = 525. ;
	m_nominalLongPulse = 936. ;
	m_maxLongPulse = 1050. ;

	// GD 2009 Added initializations of two "nominal" values whose omission
	// caused "Invalid floating point operation" in certain circumstances

	m_minShortGap = 500. ;
	m_nominalShortGap = 624. ;  // GD 2009
	m_maxShortGap = 850. ;
	m_minLongGap =  950. ;
	m_nominalLongGap = 1248. ;  // GD 2009
	m_maxLongGap = 1700. ;

	m_extra = 0. ;

   	cleanup();
	++pBit;
	nState = 0;

	do
	{
		if ( phaseBit2() <= 0 )
			return;

	} while ( pBit < pFrameEnd );

	if ( nBit < 10 )
		return;

	if ( (nBit&3)==2 && getBit(0)==1 && getBit(nBit-1)==0 )
	{
		int sum=0;
		char *p1 = pMisc;
		int ndx;
		int dig;
		for (ndx=1; ; )
		{
			dig = 15 - getLsb(ndx,4);
			sprintf( p1, "%X ", dig );
			p1 += 2;
			ndx += 4;
			if ( ndx >= nBit-1 )
				break;
			sum = (sum>>4) + (sum&15) + dig;
		}
		if ( (sum&=15) != dig )
		{
			sprintf(p1-1, "-%X", sum);
		}
		else
		{
			sprintf( pProtocol, "Solidtek%d", nBit-2 );
			if ( nBit == 22 )
			{
				*pDevice = 15-getLsb(1,4);
				*pSubDevice = 63-getLsb(5,6);
				*pOBC = 63-getLsb(11,6);
				return;
			}
			if ( nBit == 18 )
			{
				*pDevice = 15-getLsb(1,4);
				*pSubDevice = 1-getLsb(12,1);
				*pOBC = 127-getLsb(5,7);
				if (	*pDevice == 0
					&&	*pSubDevice == 0
					&&	*pOBC == 0 )
				{	
					newPreemptValue = prBySolidtek; 	// Avoid RC6-8-13 decode of same frame
					newPreemptLength = nFrameL;
				}
			}
			return;
		}
	}
	char* p1 = pProtocol;
	sprintf( p1, "S:%d", nBit );
	unsigned char* pb = cBits;
	pb[nBit>>3] += 0xFF << (nBit&7);
	do
	{
		sprintf( p1+=strlen(p1), ".%02X", msb(255-*pb) );
		++pb;
	} while ( (nBit-=8) > 0 );


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x40(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x124e0(%rip), %xmm0    # 0x1a2d8
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1240e(%rip), %xmm0    # 0x1a228
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x124a4(%rip), %xmm1    # 0x1a2e0
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x12489(%rip), %xmm0    # 0x1a2e8
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x12472(%rip), %xmm1    # 0x1a2f0
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movss 0x1e0(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1245c(%rip), %xmm1    # 0x1a2f8
ucomisd %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movss 0x1e0(%rax), %xmm0
movq 0x38(%rax), %rcx
movss (%rcx), %xmm1
movq 0x38(%rax), %rax
addss 0x4(%rax), %xmm1
ucomiss %xmm1, %xmm0
ja 0x7ee2
movq -0x38(%rbp), %rax
movss 0x1d0(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x12424(%rip), %xmm0    # 0x1a300
ucomisd %xmm1, %xmm0
jbe 0x7ee7
jmp 0x834b
movq -0x38(%rbp), %rax
cmpl $0x3, 0x54(%rax)
jl 0x7ef6
jmp 0x834b
movq -0x38(%rbp), %rdi
movss 0x12176(%rip), %xmm0    # 0x1a078
movss %xmm0, 0xfc(%rdi)
movss 0x12162(%rip), %xmm0    # 0x1a074
movss %xmm0, 0x100(%rdi)
movss 0x1214e(%rip), %xmm0    # 0x1a070
movss %xmm0, 0x104(%rdi)
movss 0x1213a(%rip), %xmm0    # 0x1a06c
movss %xmm0, 0x108(%rdi)
movss 0x12126(%rip), %xmm0    # 0x1a068
movss %xmm0, 0x10c(%rdi)
movss 0x12112(%rip), %xmm0    # 0x1a064
movss %xmm0, 0x110(%rdi)
movss 0x120fe(%rip), %xmm0    # 0x1a060
movss %xmm0, 0x120(%rdi)
movss 0x120ea(%rip), %xmm0    # 0x1a05c
movss %xmm0, 0x114(%rdi)
movss 0x120d6(%rip), %xmm0    # 0x1a058
movss %xmm0, 0x118(%rdi)
movss 0x120c2(%rip), %xmm0    # 0x1a054
movss %xmm0, 0x124(%rdi)
movss 0x120ae(%rip), %xmm0    # 0x1a050
movss %xmm0, 0x11c(%rdi)
xorps %xmm0, %xmm0
movss %xmm0, 0x130(%rdi)
callq 0x16180
movq -0x38(%rbp), %rax
movq 0xc8(%rax), %rcx
addq $0x4, %rcx
movq %rcx, 0xc8(%rax)
movl $0x0, 0xc4(%rax)
movq -0x38(%rbp), %rdi
callq 0x16aa0
cmpl $0x0, %eax
jg 0x7fed
jmp 0x834b
jmp 0x7fef
movq -0x38(%rbp), %rcx
movq 0xc8(%rcx), %rax
cmpq 0x40(%rcx), %rax
jb 0x7fda
movq -0x38(%rbp), %rax
cmpl $0xa, 0xc0(%rax)
jge 0x8012
jmp 0x834b
movq -0x38(%rbp), %rax
movl 0xc0(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x827c
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x18b30
cmpl $0x1, %eax
jne 0x827c
movq -0x38(%rbp), %rdi
movl 0xc0(%rdi), %esi
subl $0x1, %esi
callq 0x18b30
cmpl $0x0, %eax
jne 0x827c
movq -0x38(%rbp), %rax
movl $0x0, -0xc(%rbp)
movq 0x150(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl $0x4, %edx
callq 0x16030
movl %eax, %ecx
movl $0xf, %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
leaq 0x13092(%rip), %rsi     # 0x1b131
movb $0x0, %al
callq 0x2060
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl 0xc0(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jl 0x80d1
jmp 0x80e7
movl -0xc(%rbp), %eax
sarl $0x4, %eax
movl -0xc(%rbp), %ecx
andl $0xf, %ecx
addl %ecx, %eax
addl -0x20(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x8074
movl -0xc(%rbp), %eax
andl $0xf, %eax
movl %eax, -0xc(%rbp)
cmpl -0x20(%rbp), %eax
je 0x8113
movq -0x18(%rbp), %rdi
addq $-0x1, %rdi
movl -0xc(%rbp), %edx
leaq 0x1302e(%rip), %rsi     # 0x1b135
movb $0x0, %al
callq 0x2060
jmp 0x827a
movq -0x38(%rbp), %rax
movq 0x148(%rax), %rdi
movl 0xc0(%rax), %edx
subl $0x2, %edx
leaq 0x1300b(%rip), %rsi     # 0x1b139
movb $0x0, %al
callq 0x2060
movq -0x38(%rbp), %rax
cmpl $0x16, 0xc0(%rax)
jne 0x81b6
movq -0x38(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x16030
movq -0x38(%rbp), %rdi
movl $0xf, %ecx
subl %eax, %ecx
movq 0x160(%rdi), %rax
movl %ecx, (%rax)
movl $0x5, %esi
movl $0x6, %edx
callq 0x16030
movq -0x38(%rbp), %rdi
movl $0x3f, %ecx
subl %eax, %ecx
movq 0x168(%rdi), %rax
movl %ecx, (%rax)
movl $0xb, %esi
movl $0x6, %edx
callq 0x16030
movl %eax, %edx
movq -0x38(%rbp), %rax
movl $0x3f, %ecx
subl %edx, %ecx
movq 0x170(%rax), %rax
movl %ecx, (%rax)
jmp 0x834b
movq -0x38(%rbp), %rax
cmpl $0x12, 0xc0(%rax)
jne 0x8275
movq -0x38(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x16030
movq -0x38(%rbp), %rdi
movl $0xf, %ecx
subl %eax, %ecx
movq 0x160(%rdi), %rax
movl %ecx, (%rax)
movl $0xc, %esi
movl $0x1, %edx
callq 0x16030
movq -0x38(%rbp), %rdi
movl $0x1, %ecx
subl %eax, %ecx
movq 0x168(%rdi), %rax
movl %ecx, (%rax)
movl $0x5, %esi
movl $0x7, %edx
callq 0x16030
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl $0x7f, %edx
subl %ecx, %edx
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x160(%rax), %rax
cmpl $0x0, (%rax)
jne 0x8273
movq -0x38(%rbp), %rax
movq 0x168(%rax), %rax
cmpl $0x0, (%rax)
jne 0x8273
movq -0x38(%rbp), %rax
movq 0x170(%rax), %rax
cmpl $0x0, (%rax)
jne 0x8273
movq -0x38(%rbp), %rax
movl $0x3, 0x5c(%rax)
movl 0x48(%rax), %ecx
movl %ecx, 0x58(%rax)
jmp 0x8275
jmp 0x834b
jmp 0x827c
movq -0x38(%rbp), %rax
movq 0x148(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl 0xc0(%rax), %edx
leaq 0x12ea8(%rip), %rsi     # 0x1b144
movb $0x0, %al
callq 0x2060
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0xa0, %rcx
movq %rcx, -0x30(%rbp)
movl 0xc0(%rax), %ecx
andl $0x7, %ecx
movl $0xff, %esi
shll %cl, %esi
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movl 0xc0(%rcx), %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rdi
callq 0x20a0
movq -0x38(%rbp), %rdi
addq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
movl $0xff, %esi
subl %eax, %esi
movl $0x8, %edx
callq 0x15e70
movq -0x40(%rbp), %rdi
movl %eax, %edx
leaq 0x12dda(%rip), %rsi     # 0x1b0fa
movb $0x0, %al
callq 0x2060
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rcx
movl 0xc0(%rcx), %eax
subl $0x8, %eax
movl %eax, 0xc0(%rcx)
cmpl $0x0, %eax
jg 0x82e2
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)