// File: /workspace/github_cpp_makefile_star2_O2/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 0xaf83
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movss 0x9c(%rdi), %xmm0
ucomiss 0x669f(%rip), %xmm0     # 0x11634
ja 0xaf74
movss 0x6699(%rip), %xmm1     # 0x11638
ucomiss %xmm0, %xmm1
ja 0xaf74
movq 0x38(%rbx), %rax
ucomiss (%rax), %xmm0
jne 0xaf74
jp 0xaf74
movq 0x40(%rbx), %rcx
movss 0x6681(%rip), %xmm0     # 0x1163c
ucomiss (%rcx), %xmm0
ja 0xaf74
leaq 0xa0(%rbx), %rcx
movq %rcx, -0x30(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
andq $0x0, 0xc0(%rbx)
addq $0x4, %rax
movq %rax, 0xc8(%rbx)
movl $0x42de0000, 0xe0(%rbx) # imm = 0x42DE0000
leaq 0x678f(%rip), %r13      # 0x11788
movabsq $0x448ac00043de0000, %r14 # imm = 0x448AC00043DE0000
movabsq $0x435e000044c24000, %r15 # imm = 0x435E000044C24000
movabsq $0x43de000044c24000, %r12 # imm = 0x43DE000044C24000
movl 0xc0(%rbx), %eax
cmpq $0x9, %rax
ja 0xb04f
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
pushq $0x1
popq %rax
subl 0xc4(%rbx), %eax
movl %eax, 0xc4(%rbx)
movaps 0x601d(%rip), %xmm0     # 0x11060
movups %xmm0, 0xe4(%rbx)
jmp 0xb0e2
cmpl $0x11, %eax
je 0xb0c0
cmpl $0x80, %eax
jne 0xb0e2
jmp 0xaf74
movl $0x10, 0xc0(%rbx)
movq %r14, 0xe4(%rbx)
movl $0x448ac000, 0xec(%rbx) # imm = 0x448AC000
movq %r15, 0xf0(%rbx)
movl $0x44268000, 0xf8(%rbx) # imm = 0x44268000
jmp 0xb0e2
movl $0x8, 0xc0(%rbx)
movabsq $0x445e0000445e0000, %rax # imm = 0x445E0000445E0000
movq %rax, 0xe8(%rbx)
movq %r12, 0xf0(%rbx)
movl $0x448ac000, 0xf8(%rbx) # imm = 0x448AC000
jmp 0xb0e2
movabsq $0x44268000435e0000, %rax # imm = 0x44268000435E0000
movq %rax, 0xe4(%rbx)
movabsq $0x448ac00044268000, %rax # imm = 0x448AC00044268000
movq %rax, 0xec(%rbx)
movq %rbx, %rdi
callq 0xf4f4
testl %eax, %eax
je 0xaf74
movq 0xc8(%rbx), %rax
cmpq 0x40(%rbx), %rax
jb 0xb017
cmpl $0x18, 0xc0(%rbx)
jl 0xaf74
movq %rbx, %rdi
callq 0xec52
shrb $0x4, 0xa0(%rbx)
movl 0xc0(%rbx), %esi
addl $-0x8, %esi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0xeb6a
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 0xb1db
movzbl 0xa4(%rbx), %edx
shrl $0x7, %edx
leaq 0x6d04(%rip), %rsi      # 0x11e91
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 0xaf74
movzbl %al, %edx
shrl $0x7, %edx
leaq 0x6ca9(%rip), %rsi      # 0x11e91
xorl %eax, %eax
callq 0x2060
movl 0xc0(%rbx), %ecx
cmpl $0x19, %ecx
jl 0xb22f
movzbl 0xa2(%rbx), %eax
movq 0x160(%rbx), %r14
movl %eax, (%r14)
movl 0xc0(%rbx), %ecx
cmpl $0x1f, %ecx
jg 0xb22f
addl $-0x10, %ecx
pushq $0x10
popq %rsi
movq %rbx, %rdi
movl %ecx, %edx
callq 0xeb6a
movl %eax, (%r14)
movl 0xc0(%rbx), %ecx
cmpl $0x20, %ecx
sete %dl
movq -0x30(%rbp), %rax
movb (%rax), %al
testb %al, %al
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xb26e
movq 0x170(%rbx), %rax
movq 0x178(%rbx), %rcx
movl (%rax), %eax
movl %eax, (%rcx)
movq 0x148(%rbx), %rax
movl $0x364352, (%rax)       # imm = 0x364352
jmp 0xaf74
cmpl $0x21, %ecx
jl 0xb2d8
addl $-0x20, %ecx
pushq $0x18
popq %rsi
movq %rbx, %rdi
movl %ecx, %edx
callq 0xeb6a
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
movl 0xc0(%rbx), %ecx
movb 0xa0(%rbx), %al
cmpl $0x28, %ecx
sete %dl
cmpb $0x6, %al
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xb2d8
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 0xaf74
cmpl $0x2, 0x54(%rbx)
jg 0xaf74
movq 0x148(%rbx), %rdi
movzbl %al, %edx
addl $-0x10, %ecx
leaq 0x6a1e(%rip), %rsi      # 0x11d14
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2060
nop