// File: /workspace/github_cpp_makefile_star2_O1/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 $0xf, %esi
jg 0xd171
cmpl $0x9, %esi
je 0xd195
cmpl $0xd, %esi
jne 0xd497
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
mulss 0x53a8(%rip), %xmm0     # 0x12514
jmp 0xd1f6
cmpl $0x10, %esi
je 0xd1bf
cmpl $0x15, %esi
jne 0xd497
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
addss %xmm0, %xmm0
jmp 0xd1f6
movss 0x54c7(%rip), %xmm0     # 0x12664
ucomiss 0x1e0(%rbx), %xmm0
jbe 0xd497
movss 0x54b6(%rip), %xmm0     # 0x12668
ucomiss 0x1dc(%rbx), %xmm0
jbe 0xd497
xorps %xmm0, %xmm0
cvtss2sd 0x9c(%rbx), %xmm0
mulsd 0x4fa6(%rip), %xmm0     # 0x12178
movq 0x38(%rbx), %rax
cvtss2sd 0x4(%rax), %xmm1
mulsd 0x50bd(%rip), %xmm1     # 0x122a0
maxsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0x140(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jb 0xd497
movss 0x18c(%rbx), %xmm2
ucomiss 0x545e(%rip), %xmm2     # 0x1266c
jbe 0xd497
movss 0x1e0(%rbx), %xmm0
movss 0x1d0(%rbx), %xmm1
movq 0x38(%rbx), %rax
movss (%rax), %xmm3
addss 0x4(%rax), %xmm3
ucomiss %xmm0, %xmm3
jbe 0xd258
xorps %xmm3, %xmm3
cvtss2sd 0x1dc(%rbx), %xmm3
mulsd 0x522f(%rip), %xmm3     # 0x12478
cvtss2sd %xmm1, %xmm4
ucomisd %xmm3, %xmm4
ja 0xd28a
jmp 0xd497
movss 0x1dc(%rbx), %xmm0
movss 0x5408(%rip), %xmm4     # 0x12670
ucomiss %xmm0, %xmm4
jbe 0xd497
movss 0x1cc(%rbx), %xmm4
cmpltss %xmm4, %xmm3
andps %xmm3, %xmm4
andnps %xmm1, %xmm3
orps %xmm4, %xmm3
movaps %xmm3, %xmm1
xorps %xmm3, %xmm3
cvtss2sd %xmm0, %xmm3
movsd 0x500f(%rip), %xmm4     # 0x122a8
mulsd %xmm3, %xmm4
cvtss2sd %xmm1, %xmm5
ucomisd %xmm4, %xmm5
jbe 0xd497
cvtss2sd %xmm2, %xmm2
mulsd 0x4f09(%rip), %xmm2     # 0x121c0
xorps %xmm4, %xmm4
cvtss2sd 0x190(%rbx), %xmm4
ucomisd %xmm4, %xmm2
jbe 0xd497
mulsd 0x51ac(%rip), %xmm3     # 0x12480
xorps %xmm2, %xmm2
cvtsd2ss %xmm3, %xmm2
movss %xmm2, 0xe8(%rbx)
ucomiss %xmm2, %xmm1
jbe 0xd326
ucomiss 0x526d(%rip), %xmm1     # 0x1255c
jbe 0xd497
movss 0x5367(%rip), %xmm1     # 0x12664
ucomiss %xmm0, %xmm1
jbe 0xd497
movss (%rax), %xmm0
addss 0x4(%rax), %xmm0
ucomiss 0x534e(%rip), %xmm0     # 0x12664
jbe 0xd497
movl $0x44bb8000, 0xe8(%rbx) # imm = 0x44BB8000
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
movq $0x0, 0xc0(%rbx)
addq $0x8, %rax
movq %rax, 0xc8(%rbx)
addl $-0x2, %esi
movq %rbx, %rdi
callq 0x10028
movq 0xc8(%rbx), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax), %xmm0
mulsd 0x5121(%rip), %xmm0     # 0x12488
xorps %xmm1, %xmm1
cvtss2sd 0xe8(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd396
movl 0xc0(%rbx), %eax
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
sarl $0x3, %eax
cltq
orb %dl, 0xa0(%rbx,%rax)
movq 0x148(%rbx), %rdi
movl 0x48(%rbx), %edx
decl %edx
leaq 0x5c10(%rip), %rsi      # 0x12fb9
xorl %eax, %eax
callq 0x2060
movl 0x48(%rbx), %eax
cmpl $0x9, %eax
jne 0xd3cb
movzbl 0xa0(%rbx), %eax
movq 0x170(%rbx), %rcx
jmp 0xd495
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 0xd457
addl $-0x8, %edx
movq %rbx, %rdi
movl $0x7, %esi
callq 0xfe7e
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movl (%r14), %eax
incl %eax
movl %eax, 0x4(%r14)
jmp 0xd497
movzbl 0xa0(%rbx), %eax
shrl $0x7, %eax
movzbl 0xa1(%rbx), %ecx
andl $0xf, %ecx
leal (%rax,%rcx,2), %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movb 0xa1(%rbx), %al
movb 0xa2(%rbx), %cl
shrb $0x4, %al
shlb $0x4, %cl
orb %al, %cl
movzbl %cl, %eax
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
popq %rbx
popq %r14
popq %rbp
retq