// File: /workspace/github_cpp_makefile_star2_O3/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 0xd1c7
cmpl $0x9, %esi
je 0xd1eb
cmpl $0xd, %esi
jne 0xd4ec
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
mulss 0x5352(%rip), %xmm0     # 0x12514
jmp 0xd24c
cmpl $0x10, %esi
je 0xd215
cmpl $0x15, %esi
jne 0xd4ec
movss 0x9c(%rbx), %xmm0
movss 0x140(%rbx), %xmm1
addss %xmm0, %xmm0
jmp 0xd24c
movss 0x546d(%rip), %xmm0     # 0x12660
ucomiss 0x1e0(%rbx), %xmm0
jbe 0xd4ec
movss 0x545c(%rip), %xmm0     # 0x12664
ucomiss 0x1dc(%rbx), %xmm0
jbe 0xd4ec
xorps %xmm0, %xmm0
cvtss2sd 0x9c(%rbx), %xmm0
mulsd 0x4f50(%rip), %xmm0     # 0x12178
movq 0x38(%rbx), %rax
cvtss2sd 0x4(%rax), %xmm1
mulsd 0x5067(%rip), %xmm1     # 0x122a0
maxsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0x140(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jb 0xd4ec
movss 0x18c(%rbx), %xmm0
ucomiss 0x5404(%rip), %xmm0     # 0x12668
jbe 0xd4ec
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 0xd2b2
xorps %xmm3, %xmm3
cvtss2sd %xmm4, %xmm3
mulsd 0x51d5(%rip), %xmm3     # 0x12478
cvtss2sd %xmm1, %xmm5
ucomisd %xmm3, %xmm5
ja 0xd2e3
jmp 0xd4ec
movss 0x53b2(%rip), %xmm2     # 0x1266c
ucomiss %xmm4, %xmm2
jbe 0xd4ec
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
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
movsd 0x4fb6(%rip), %xmm4     # 0x122a8
mulsd %xmm3, %xmm4
ucomisd %xmm4, %xmm5
jbe 0xd4ec
cvtss2sd %xmm0, %xmm0
mulsd 0x4eb4(%rip), %xmm0     # 0x121c0
xorps %xmm4, %xmm4
cvtss2sd 0x190(%rbx), %xmm4
ucomisd %xmm4, %xmm0
jbe 0xd4ec
mulsd 0x5157(%rip), %xmm3     # 0x12480
xorps %xmm0, %xmm0
cvtsd2ss %xmm3, %xmm0
movss %xmm0, 0xe8(%rbx)
ucomiss %xmm0, %xmm1
jbe 0xd37b
ucomiss 0x5218(%rip), %xmm1     # 0x1255c
jbe 0xd4ec
movss 0x530e(%rip), %xmm0     # 0x12660
ucomiss %xmm2, %xmm0
jbe 0xd4ec
movss (%rax), %xmm0
addss 0x4(%rax), %xmm0
ucomiss 0x52f5(%rip), %xmm0     # 0x12660
jbe 0xd4ec
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 0xfee2
movq 0xc8(%rbx), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax), %xmm0
mulsd 0x50cc(%rip), %xmm0     # 0x12488
xorps %xmm1, %xmm1
cvtss2sd 0xe8(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd3eb
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 0x5bb2(%rip), %rsi      # 0x12fb0
xorl %eax, %eax
callq 0x2060
movl 0x48(%rbx), %eax
cmpl $0x9, %eax
jne 0xd420
movzbl 0xa0(%rbx), %eax
movq 0x170(%rbx), %rcx
jmp 0xd4ea
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 0xd4ac
addl $-0x8, %edx
movq %rbx, %rdi
movl $0x7, %esi
callq 0xfd2a
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movl (%r14), %eax
incl %eax
movl %eax, 0x4(%r14)
jmp 0xd4ec
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
nop