// File: /workspace/github_cpp_makefile_star2_O1/probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryRC6()
void Signal::tryRC6()
//
// {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,M:3,<-2,2|2,-2>(T:1),D:8,F:8,^107m)+		RC6 when M=0
// {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,M:3,<-2,2|2,-2>(T:1),D:8,S:8,F:8,^??)+		Replay when M=6
// {36k,444,msb}<-1,1|1,-1>(6,-2,1:1,M:3,-2,2,OEM1:8,OEM2:8,T:1,D:7,F:8,-69m)+   MCE when M=6, OEM1=128
// {36k,444,msb}<-1,1|1,-1>(6,-2,~M:1:3,M:3,<-2,2|2,-2>(T:1),?:?,^??)+          Unknown versions of RC6
//
{
	if ( nFrameL < 10 )
		return;
	const float HB = 444;
	if (   nMaxDur != *pFrame || nMaxDur < 2*HB || nMaxDur > 12*HB	// First ON nominally 6 half bits
		|| *pFrameEnd < 20*HB )
	{
		return;
	}
	cleanup();
	++pBit;	// Skip over nominal 6
    minGlitch = HB*.25;
	do
	{
		switch (nBit)	// Various boundaries within the sequence
		{
		case 0:  // Lead in Bit inverted treated as extra mode bit
			nMinShort = HB;					// Nominally 2
			nMaxShort = nMinLong = HB*2.5;	// 2 vs. 3
			nMaxLong = HB*3.5;				// Nominally 3
			nMinShort2 = HB*.5;				// Nominally 1
			nMaxShort2 = HB*1.5;			// Nominally 1
			break;
		case 1:  // First true mode bit
			nState = 1 - nState;			// Lead bit was processed with reversed polarity
			nMinShort = HB*.5;				// Nominally 1
			nMaxShort = nMinLong = HB*1.5;	// 1 vs. 2
			nMaxLong = HB*2.5;				// Nominally 2
			break;
		case 4:  // Toggle bit
			nBit = 8;						// Put toggle bit in second byte
			nMaxShort = nMinLong = HB*2.;	// 1 vs. 3
			nMaxLong = HB*3.5;				// Nominally 3
			nMinShort2 = HB;				// Nominally 2
			nMaxShort2 = HB*2.5;			// Nominally 2
			break;
		case 9:  // Bit after Toggle bit
			nBit = 16;						// Put in third byte
			nMinShort = HB;					// Nominally 2
			nMaxShort = nMinLong = HB*2.5;	// 2 vs. 3
			nMaxLong = HB*3.5;				// Nominally 3
			nMinShort2 = HB*.5;				// Nominally 1
			nMaxShort2 = HB*1.5;			// Nominally 1
			break;
		case 17:  // Start of normal section
			nMinShort = HB*.5;				// Nominally 1
			nMaxShort = nMinLong = HB*1.5;	// 1 vs. 2
			nMaxLong = HB*2.5;				// Nominally 2
			break;
		case sizeof(cBits)*8:
			return;
		}
		if ( ! phaseBit() )
			return;
	} while (pBit < pFrameEnd);
	if (nBit < 24)
		return;	// Got too little to be right

	makeMsb();
	cBits[0] >>= 4;

	*pOBC = getMsb(nBit-8, 8);

	if (   nBit == 48
		&& cBits[0] == 6
		&& cBits[2] == 128
		&& ! ( cBits[1] & 128 ) )
	{
		sprintf(pMisc, "T=%d", cBits[4]>>7);
		*pDevice = getMsb(33, 7);
		*pSubDevice = getMsb(24, 8);    // OEM2 reported as subdevice
		pHex[0] = *pOBC;
		strcpy(pProtocol, "MCE");
		return;
	}

	sprintf(pMisc, "T=%d", cBits[1]>>7);

	if (nBit > 24)
	{
		*pDevice = cBits[2];
		if (nBit < 32)
			*pDevice = getMsb(16, nBit-16);
	}
	if (nBit == 32 && cBits[0] == 0)
	{
		pHex[0] = *pOBC;
		strcpy(pProtocol, "RC6");
		return;
	}
	if (nBit > 32)
	{
		*pSubDevice = getMsb(24, nBit-32);
	}
	if (nBit == 40 && cBits[0]==6 ) 
	{
		pHex[0] = *pOBC;
		strcpy(pProtocol, "Replay");
		return;
	}
	if ( preemptValue >= prRCx )		// GD 2009  Avoids spurious decode of OrtekMCE
	{
		return;
	}
	sprintf(pProtocol, "RC6-%d-%d",cBits[0], nBit-16);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0xa, 0x48(%rdi)
jge 0xbb07
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movss 0x9c(%rdi), %xmm0
ucomiss 0x6b1f(%rip), %xmm0     # 0x12638
ja 0xbaf8
movss 0x6b19(%rip), %xmm1     # 0x1263c
ucomiss %xmm0, %xmm1
ja 0xbaf8
movq 0x38(%rbx), %rax
ucomiss (%rax), %xmm0
jne 0xbaf8
jp 0xbaf8
movq 0x40(%rbx), %rcx
movss 0x6b01(%rip), %xmm0     # 0x12640
ucomiss (%rcx), %xmm0
ja 0xbaf8
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
movq $0x0, 0xc0(%rbx)
addq $0x4, %rax
movq %rax, 0xc8(%rbx)
movl $0x42de0000, 0xe0(%rbx) # imm = 0x42DE0000
leaq 0x6c13(%rip), %r12      # 0x12788
movabsq $0x448ac00043de0000, %r13 # imm = 0x448AC00043DE0000
movabsq $0x435e000044c24000, %r14 # imm = 0x435E000044C24000
movabsq $0x43de000044c24000, %r15 # imm = 0x43DE000044C24000
movl 0xc0(%rbx), %eax
cmpq $0x9, %rax
ja 0xbbcc
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl $0x1, %eax
subl 0xc4(%rbx), %eax
movl %eax, 0xc4(%rbx)
movaps 0x64a0(%rip), %xmm0     # 0x12060
movups %xmm0, 0xe4(%rbx)
jmp 0xbc5f
cmpl $0x11, %eax
je 0xbc3d
cmpl $0x80, %eax
jne 0xbc5f
jmp 0xbaf8
movl $0x10, 0xc0(%rbx)
movq %r13, 0xe4(%rbx)
movl $0x448ac000, 0xec(%rbx) # imm = 0x448AC000
movq %r14, 0xf0(%rbx)
movl $0x44268000, 0xf8(%rbx) # imm = 0x44268000
jmp 0xbc5f
movl $0x8, 0xc0(%rbx)
movabsq $0x445e0000445e0000, %rax # imm = 0x445E0000445E0000
movq %rax, 0xe8(%rbx)
movq %r15, 0xf0(%rbx)
movl $0x448ac000, 0xf8(%rbx) # imm = 0x448AC000
jmp 0xbc5f
movabsq $0x44268000435e0000, %rax # imm = 0x44268000435E0000
movq %rax, 0xe4(%rbx)
movabsq $0x448ac00044268000, %rax # imm = 0x448AC00044268000
movq %rax, 0xec(%rbx)
movq %rbx, %rdi
callq 0x10840
testl %eax, %eax
je 0xbaf8
movq 0xc8(%rbx), %rax
cmpq 0x40(%rbx), %rax
jb 0xbb93
movl 0xc0(%rbx), %eax
cmpl $0x18, %eax
jl 0xbaf8
addq $0x7, %rax
shrq $0x3, %rax
addq $0x9f, %rax
movl $0x33000000, %ecx       # imm = 0x33000000
movl $0x55000000, %edx       # imm = 0x55000000
movzbl (%rbx,%rax), %esi
bswapl %esi
movl %esi, %edi
shll $0x4, %edi
shrl $0x4, %esi
andl $0xf000000, %esi        # imm = 0xF000000
orl %edi, %esi
movl %esi, %edi
andl %ecx, %edi
shrl $0x2, %esi
andl %ecx, %esi
leal (%rsi,%rdi,4), %esi
movl %esi, %edi
andl %edx, %edi
shrl %esi
andl %edx, %esi
leal (%rsi,%rdi,2), %esi
shrl $0x18, %esi
movb %sil, (%rbx,%rax)
leaq -0x1(%rax), %rsi
addq $-0x9f, %rax
cmpq $0x1, %rax
movq %rsi, %rax
jg 0xbca7
shrb $0x4, 0xa0(%rbx)
movl 0xc0(%rbx), %esi
addl $-0x8, %esi
movq %rbx, %rdi
movl $0x8, %edx
callq 0xfdf2
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
cmpl $0x30, 0xc0(%rbx)
sete %cl
cmpb $0x6, 0xa0(%rbx)
movb 0xa1(%rbx), %al
sete %dl
andb %cl, %dl
movb 0xa2(%rbx), %cl
negb %cl
seto %cl
testb %al, %al
setns %sil
andb %cl, %sil
andb %dl, %sil
movq 0x150(%rbx), %rdi
cmpb $0x1, %sil
jne 0xbdb3
movzbl 0xa4(%rbx), %edx
shrl $0x7, %edx
leaq 0x7135(%rip), %rsi      # 0x12e9a
xorl %eax, %eax
callq 0x2060
movzbl 0xa4(%rbx), %eax
andl $0x7f, %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movzbl 0xa3(%rbx), %eax
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
movq 0x170(%rbx), %rax
movq 0x178(%rbx), %rcx
movl (%rax), %eax
movl %eax, (%rcx)
movq 0x148(%rbx), %rax
movl $0x45434d, (%rax)       # imm = 0x45434D
jmp 0xbaf8
movzbl %al, %edx
shrl $0x7, %edx
leaq 0x70da(%rip), %rsi      # 0x12e9a
xorl %eax, %eax
callq 0x2060
cmpl $0x19, 0xc0(%rbx)
jl 0xbdff
movzbl 0xa2(%rbx), %eax
movq 0x160(%rbx), %r14
movl %eax, (%r14)
movl 0xc0(%rbx), %edx
cmpl $0x1f, %edx
jg 0xbdff
addl $-0x10, %edx
movq %rbx, %rdi
movl $0x10, %esi
callq 0xfdf2
movl %eax, (%r14)
movl 0xc0(%rbx), %edx
cmpl $0x20, %edx
jne 0xbe37
cmpb $0x0, 0xa0(%rbx)
jne 0xbe37
movq 0x170(%rbx), %rax
movq 0x178(%rbx), %rcx
movl (%rax), %eax
movl %eax, (%rcx)
movq 0x148(%rbx), %rax
movl $0x364352, (%rax)       # imm = 0x364352
jmp 0xbaf8
cmpl $0x21, %edx
jl 0xbe55
addl $-0x20, %edx
movq %rbx, %rdi
movl $0x18, %esi
callq 0xfdf2
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
movl 0xc0(%rbx), %ecx
cmpl $0x28, %ecx
sete %dl
movb 0xa0(%rbx), %al
cmpb $0x6, %al
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xbea1
movq 0x170(%rbx), %rax
movq 0x178(%rbx), %rcx
movl (%rax), %eax
movl %eax, (%rcx)
movq 0x148(%rbx), %rax
movl $0x79616c, 0x3(%rax)    # imm = 0x79616C
movl $0x6c706552, (%rax)     # imm = 0x6C706552
jmp 0xbaf8
cmpl $0x2, 0x54(%rbx)
jg 0xbaf8
movzbl %al, %edx
movq 0x148(%rbx), %rdi
addl $-0x10, %ecx
leaq 0x6e5e(%rip), %rsi      # 0x12d1d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2060