// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x40(%rdi), %rax
movss 0xb9f0(%rip), %xmm0     # 0x11544
ucomiss (%rax), %xmm0
jbe 0x5b68
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movss (%rax), %xmm0
movss 0xb9cd(%rip), %xmm1     # 0x11548
ucomiss %xmm0, %xmm1
ja 0x5b59
ucomiss 0xb9c5(%rip), %xmm0     # 0x1154c
ja 0x5b59
movss 0x4(%rax), %xmm1
movss 0xb9ba(%rip), %xmm2     # 0x11550
ucomiss %xmm1, %xmm2
ja 0x5b59
ucomiss 0xb9b2(%rip), %xmm1     # 0x11554
ja 0x5b59
movss 0x1e0(%rbx), %xmm2
ucomiss 0xb9a5(%rip), %xmm2     # 0x11558
ja 0x5b59
addss %xmm1, %xmm0
ucomiss %xmm0, %xmm2
ja 0x5b59
movss 0xb996(%rip), %xmm0     # 0x1155c
ucomiss 0x1d0(%rbx), %xmm0
ja 0x5b59
cmpl $0x2, 0x54(%rbx)
jg 0x5b59
movaps 0xb444(%rip), %xmm0     # 0x11020
movups %xmm0, 0xfc(%rbx)
movabsq $0x43fa000044834000, %rcx # imm = 0x43FA000044834000
movq %rcx, 0x10c(%rbx)
movabsq $0x446d800044548000, %rcx # imm = 0x446D800044548000
movq %rcx, 0x114(%rbx)
movl $0x449c0000, 0x124(%rbx) # imm = 0x449C0000
movabsq $0x441c000044d48000, %rcx # imm = 0x441C000044D48000
movq %rcx, 0x11c(%rbx)
andl $0x0, 0x130(%rbx)
addq $0x4, %rax
leaq 0xa0(%rbx), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
andq $0x0, 0xc0(%rbx)
movq %rax, 0xc8(%rbx)
movq %rbx, %rdi
callq 0xf26a
testl %eax, %eax
jle 0x5b59
movq 0xc8(%rbx), %rax
cmpq 0x40(%rbx), %rax
jb 0x5c4b
movl 0xc0(%rbx), %edx
cmpl $0xa, %edx
jl 0x5b59
movl %edx, %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x5dc5
testb $0x1, (%r13)
je 0x5dc5
leal -0x1(%rdx), %eax
movl %eax, %ecx
shrl $0x3, %ecx
movzbl (%r13,%rcx), %ecx
andl $0x5, %eax
btl %eax, %ecx
jb 0x5dc5
movq 0x150(%rbx), %rax
movq %rax, -0x30(%rbp)
pushq $0x5
popq %r14
xorl %r15d, %r15d
leal -0x4(%r14), %esi
movq %rbx, %rdi
pushq $0x4
popq %rdx
callq 0xebd6
pushq $0xf
popq %r12
subl %eax, %r12d
movq -0x30(%rbp), %rdi
leaq 0xc321(%rip), %rsi      # 0x11ffe
movl %r12d, %edx
xorl %eax, %eax
callq 0x2060
movl 0xc0(%rbx), %edx
leal -0x1(%rdx), %eax
cmpl %eax, %r14d
jge 0x5d10
addq $0x2, -0x30(%rbp)
movl %r15d, %eax
sarl $0x4, %eax
andl $0xf, %r15d
addl %eax, %r15d
addl %r12d, %r15d
addl $0x4, %r14d
jmp 0x5cbc
movq -0x30(%rbp), %rdi
andl $0xf, %r15d
cmpl %r12d, %r15d
jne 0x5dab
movq 0x148(%rbx), %rdi
addl $-0x2, %edx
leaq 0xc2d4(%rip), %rsi      # 0x12006
xorl %eax, %eax
callq 0x2060
movl 0xc0(%rbx), %eax
cmpl $0x12, %eax
je 0x5e78
cmpl $0x16, %eax
jne 0x5b59
movl 0xa0(%rbx), %eax
notl %eax
shrl %eax
andl $0xf, %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
pushq $0x5
popq %rsi
pushq $0x6
popq %r14
movq %rbx, %rdi
movl %r14d, %edx
callq 0xebd6
pushq $0x3f
popq %r15
movl %r15d, %ecx
subl %eax, %ecx
movq 0x168(%rbx), %rax
movl %ecx, (%rax)
pushq $0xb
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0xebd6
subl %eax, %r15d
movq 0x170(%rbx), %rax
movl %r15d, (%rax)
jmp 0x5b59
incq %rdi
leaq 0xc24d(%rip), %rsi      # 0x12002
movl %r15d, %edx
xorl %eax, %eax
callq 0x2060
movl 0xc0(%rbx), %edx
movq 0x148(%rbx), %r14
leaq 0xc23e(%rip), %rsi      # 0x12011
movq %r14, %rdi
xorl %eax, %eax
callq 0x2060
movl 0xc0(%rbx), %eax
movl %eax, %ecx
andb $0x7, %cl
movl $0xff, %edx
shll %cl, %edx
sarl $0x3, %eax
cltq
addb %dl, 0xa0(%rbx,%rax)
movl $0x33000000, %r12d      # imm = 0x33000000
movl $0x55000000, %r15d      # imm = 0x55000000
movq %r14, %rdi
callq 0x20a0
addq %rax, %r14
movzbl (%r13), %eax
xorl $0xff, %eax
bswapl %eax
movl %eax, %ecx
shll $0x4, %ecx
shrl $0x4, %eax
andl $0xf000000, %eax        # imm = 0xF000000
orl %ecx, %eax
movl %eax, %ecx
andl %r12d, %ecx
shrl $0x2, %eax
andl %r12d, %eax
leal (%rax,%rcx,4), %eax
movl %eax, %ecx
andl %r15d, %ecx
shrl %eax
andl %r15d, %eax
leal (%rax,%rcx,2), %edx
shrl $0x18, %edx
movq %r14, %rdi
leaq 0xc176(%rip), %rsi      # 0x11fcb
xorl %eax, %eax
callq 0x2060
incq %r13
movl 0xc0(%rbx), %eax
leal -0x8(%rax), %ecx
movl %ecx, 0xc0(%rbx)
cmpl $0x8, %eax
jg 0x5e07
jmp 0x5b59
movl 0xa0(%rbx), %eax
notl %eax
shrl %eax
andl $0xf, %eax
movq 0x160(%rbx), %r15
movl %eax, (%r15)
movzbl 0xa1(%rbx), %eax
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movq 0x168(%rbx), %r14
movl %ecx, (%r14)
pushq $0x5
popq %rsi
pushq $0x7
popq %rdx
movq %rbx, %rdi
callq 0xebd6
pushq $0x7f
popq %rcx
subl %eax, %ecx
movq 0x170(%rbx), %rdx
movl %ecx, (%rdx)
cmpl $0x0, (%r15)
jne 0x5b59
cmpl $0x7f, %eax
jne 0x5b59
cmpl $0x0, (%r14)
jne 0x5b59
movl $0x3, 0x5c(%rbx)
movl 0x48(%rbx), %eax
movl %eax, 0x58(%rbx)
jmp 0x5b59