// File: /workspace/github_cpp_makefile_star2_O2/probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::trySony()
void Signal::trySony()
// Sony8  {40k,600}<1,-1|2,-1>(4,-1,F:8,^22200)
// Sony12 {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,^45m)+
// Sony15 {40k,600}<1,-1|2,-1>(4,-1,F:7,D:8,^45m)+
// Sony20 {40k,600}<1,-1|2,-1>(4,-1,F:7,D:5,S:8,^45m)+
{

	switch (nFrameL)
	{
		case 9:
            require( sortBurst.max2 < 3.3*600 )
            require( sortBurst.max1 < 5.5*600 )
			// max content = .6*(5+8*3) = 17.4m
			// min leadout = (22.2 - 17.4)/.6 = 8 units
			require( framed( max( nMaxDur*1.5, pFrame[1]*6.) ) )
			break;
		case 13:
			// Max content = .6*(5+12*3) = 24.6ms
			// Min leadout = (45-24.6)/.6 = 34 units
			require( framed(nMaxDur*7) )
			break;
		case 16:
			// Max content = .6*(5+15*3) = 30ms
			// Min leadout = (45-30)/.6 = 25 units
			require( framed( max( nMaxDur*1.5, pFrame[1]*6.) ) )
			break;
		case 21:
			// Max content = .6*(5+20*3) = 39ms
			// Min leadout = (45-39)/.6 = 10 units
			require( framed(nMaxDur*2) )
			break;
		default:
			require( false );
	}
	require( sortOff.min1 > 0.8*600)  // DAR 2012 avoid misdecode from Humax 4Phase
    float bigBurst = sortBurst.max2;
    float smallBurst = sortBurst.min1;
    float firstBurst = pFrame[0]+pFrame[1];
    if ( firstBurst > bigBurst )
    {
        require( sortBurst.max1 * (2. / 6) < smallBurst )  // Lead in too big
    }
    else
    {
        if ( firstBurst < sortBurst.min2 )
            smallBurst = sortBurst.min2;
        bigBurst = sortBurst.max1;
        require( bigBurst < 2350. )  // Avoid misdecode from RC5
    }

    require( bigBurst * (2. / 3.6) < smallBurst )  // Larger burst too big

    require( sortOff.min1*1.6 > sortOff.max1 )  // All but terminal gap should be the same size

                                    // bigBurst is nominal 3
	nMaxShort = bigBurst*(5./6);    // nMaxShort is nominal 2.5

	// If all the pulses are the same size, fall back on expected timing
	if ( nMaxShort < smallBurst )
	{
		require( pFrame[0]+pFrame[1] > 3.3*600 )
		require( bigBurst < 3.3*600 )
        require( smallBurst > 1.5*600 )
		nMaxShort = 1500;
	}

	cleanup();
	pBit+=2;
	decodeX2( nFrameL-2 );  // Can't use off half of last bit
	if ( pBit[0]*(2.5/1.33) > nMaxShort )   // Last On is nominal 1 or 2, but bias for battery problems
	{
		cBits[nBit>>3] |= 1 << (nBit & 7);
	}
	
	sprintf(pProtocol, "Sony%d", nFrameL-1);
	if (nFrameL == 9)
	{
		*pOBC = cBits[0];
		return;
	}
	newPreemptValue = prBySony; 	// Avoid Async decode of same frame
	newPreemptLength = nFrameL;
	*pOBC = getLsb(0,7);
	pHex[0] = msb(*pOBC);
	if (nFrameL <= 16 )
	{
		*pDevice = getLsb(7, nFrameL-8);
		pHex[1] = pHex[0]+1;
	}
	else
	{
		*pDevice = getLsb(7, 5);
		*pSubDevice = getLsb(12, 8);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x48(%rdi), %esi
cmpl $0x15, %esi
je 0xc464
cmpl $0xd, %esi
je 0xc44a
cmpl $0x10, %esi
je 0xc417
cmpl $0x9, %esi
jne 0xc6ed
movss 0x526b(%rip), %xmm0     # 0x11660
ucomiss 0x1e0(%rbx), %xmm0
jbe 0xc6ed
movss 0x525a(%rip), %xmm0     # 0x11664
ucomiss 0x1dc(%rbx), %xmm0
jbe 0xc6ed
cvtss2sd 0x9c(%rbx), %xmm0
mulsd 0x4d51(%rip), %xmm0     # 0x11178
movq 0x38(%rbx), %rax
cvtss2sd 0x4(%rax), %xmm1
mulsd 0x4e68(%rip), %xmm1     # 0x112a0
maxsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss 0x140(%rbx), %xmm1
jmp 0xc478
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
mulss 0x50b2(%rip), %xmm0     # 0x11514
jmp 0xc478
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
addss %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jb 0xc6ed
movss 0x18c(%rbx), %xmm0
ucomiss 0x51d8(%rip), %xmm0     # 0x11668
jbe 0xc6ed
movss 0x1e0(%rbx), %xmm2
movq 0x38(%rbx), %rax
movss (%rax), %xmm3
addss 0x4(%rax), %xmm3
movss 0x1d0(%rbx), %xmm1
ucomiss %xmm2, %xmm3
movss 0x1dc(%rbx), %xmm4
jbe 0xc4db
cvtss2sd %xmm4, %xmm3
mulsd 0x4fac(%rip), %xmm3     # 0x11478
cvtss2sd %xmm1, %xmm5
ucomisd %xmm3, %xmm5
ja 0xc50c
jmp 0xc6ed
movss 0x5189(%rip), %xmm2     # 0x1166c
ucomiss %xmm4, %xmm2
jbe 0xc6ed
movss 0x1cc(%rbx), %xmm2
cmpltss %xmm2, %xmm3
andps %xmm3, %xmm2
andnps %xmm1, %xmm3
orps %xmm2, %xmm3
cvtss2sd %xmm3, %xmm5
movaps %xmm3, %xmm1
movaps %xmm4, %xmm2
cvtss2sd %xmm2, %xmm3
movsd 0x4d90(%rip), %xmm4     # 0x112a8
mulsd %xmm3, %xmm4
ucomisd %xmm4, %xmm5
jbe 0xc6ed
cvtss2sd %xmm0, %xmm0
mulsd 0x4c8e(%rip), %xmm0     # 0x111c0
cvtss2sd 0x190(%rbx), %xmm4
ucomisd %xmm4, %xmm0
jbe 0xc6ed
mulsd 0x4f34(%rip), %xmm3     # 0x11480
cvtsd2ss %xmm3, %xmm0
movss %xmm0, 0xe8(%rbx)
ucomiss %xmm0, %xmm1
jbe 0xc59b
ucomiss 0x4ff8(%rip), %xmm1     # 0x1155c
jbe 0xc6ed
movss 0x50ee(%rip), %xmm0     # 0x11660
ucomiss %xmm2, %xmm0
jbe 0xc6ed
movss (%rax), %xmm0
addss 0x4(%rax), %xmm0
ucomiss 0x50d5(%rip), %xmm0     # 0x11660
jbe 0xc6ed
movl $0x44bb8000, 0xe8(%rbx) # imm = 0x44BB8000
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
andq $0x0, 0xc0(%rbx)
addq $0x8, %rax
movq %rax, 0xc8(%rbx)
addl $-0x2, %esi
movq %rbx, %rdi
callq 0xed6e
movq 0xc8(%rbx), %rax
cvtss2sd (%rax), %xmm0
mulsd 0x4eb2(%rip), %xmm0     # 0x11488
cvtss2sd 0xe8(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc600
movl 0xc0(%rbx), %eax
movl %eax, %ecx
andb $0x7, %cl
pushq $0x1
popq %rdx
shll %cl, %edx
sarl $0x3, %eax
cltq
orb %dl, 0xa0(%rbx,%rax)
movq 0x148(%rbx), %rdi
movl 0x48(%rbx), %edx
decl %edx
leaq 0x599d(%rip), %rsi      # 0x11fb0
xorl %eax, %eax
callq 0x2060
movl 0x48(%rbx), %eax
cmpl $0x9, %eax
jne 0xc635
movzbl 0xa0(%rbx), %eax
movq 0x170(%rbx), %rcx
jmp 0xc6eb
movl $0x2, 0x5c(%rbx)
movl %eax, 0x58(%rbx)
movzbl 0xa0(%rbx), %eax
andl $0x7f, %eax
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
bswapl %eax
movl %eax, %ecx
shll $0x4, %ecx
shrl $0x4, %eax
andl $0x7000000, %eax        # imm = 0x7000000
orl %ecx, %eax
movl %eax, %ecx
andl $0x33000000, %ecx       # imm = 0x33000000
shrl $0x2, %eax
andl $0x31000000, %eax       # imm = 0x31000000
leal (%rax,%rcx,4), %eax
movl %eax, %ecx
andl $0x55000000, %ecx       # imm = 0x55000000
shrl %eax
andl $0x54000000, %eax       # imm = 0x54000000
leal (%rax,%rcx,2), %eax
shrl $0x18, %eax
movq 0x178(%rbx), %r14
movl %eax, (%r14)
movl 0x48(%rbx), %edx
cmpl $0x10, %edx
jg 0xc6bf
addl $-0x8, %edx
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0xebd6
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movl (%r14), %eax
incl %eax
movl %eax, 0x4(%r14)
jmp 0xc6ed
pushq $0x7
popq %rsi
pushq $0x5
popq %rdx
movq %rbx, %rdi
callq 0xebd6
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
pushq $0xc
popq %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0xebd6
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
popq %rbx
popq %r14
popq %rbp
retq