// File: /workspace/github_cpp_makefile_star2_O1/probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::trySomfy()
void Signal::trySomfy()
{
    if (   nFrameL < 10
        || nFrameL > 19 )
    {
        return;
    }
    float firstBurst = pFrame[0] + pFrame[1];
    if (   firstBurst < 1.6 * sortBurst.max2
        || sortBurst.max1 > pFrameEnd[0] )
    {
        return;
    }
    float bitTotal = nTotDur - firstBurst;
    if ( bitTotal > 8.7 * sortBurst.max2 )
        return;
    if ( bitTotal < 7. * sortBurst.max2 )
        return;
    cBits[0] = cBits[1] = 0;
	pBit = pFrame+2;
	nBit = 0;
    for (;;)
    {
        float burst = pBit[0] + pBit[1];
        if ( burst * 1.6 > sortBurst.max2 )
        {
            if ( pBit+1 >= pFrameEnd )
            {
                if ( nBit != 8 )
                    return;
                if ( pBit[0] * 2.1 > sortBurst.max2 )
    			    cBits[nBit>>3] |= 1 << (nBit & 7);
                break;
            }
            if ( pBit[0] > pBit[1] )
    			cBits[nBit>>3] |= 1 << (nBit & 7);
            pBit += 2;
        }
        else
        {
            pBit += 2;
            burst += pBit[0];
            if ( pBit+1 >= pFrameEnd )
            {
                if ( nBit != 8 )
                    return;
                if ( burst *2.1 < sortBurst.max2 )
                    return;
                if ( burst > sortBurst.max2 )
                    return;
  			    cBits[nBit>>3] |= 1 << (nBit & 7);
                break;
            }
            burst += pBit[1];
            if (   burst *1.3 < sortBurst.max2
                || burst *.8 > sortBurst.max2
                || burst *.5 < pBit[1] )
            {
                return;
            }
    		cBits[nBit>>3] |= 1 << (nBit & 7);
            pBit += 2;
        }
        if ( ++nBit == 9 )
        {
            return;
        }
    }
    int cmd = getLsb(0,2);
    int dev = getLsb(2,3);
    if ( ( (cmd*4+dev+3) & 15 ) == getLsb(5,4) )
    {
	    strcpy(pProtocol, "Somfy");
	    *pOBC = cmd;
        *pDevice = dev;
    }

}

// Assembly:
movl 0x48(%rdi), %eax
addl $-0x14, %eax
cmpl $-0xa, %eax
jb 0x65a8
pushq %rbp
movq %rsp, %rbp
movq 0x38(%rdi), %rax
movss (%rax), %xmm1
addss 0x4(%rax), %xmm1
cvtss2sd %xmm1, %xmm2
cvtss2sd 0x1e0(%rdi), %xmm0
movsd 0xbc34(%rip), %xmm3     # 0x121c0
mulsd %xmm0, %xmm3
ucomisd %xmm2, %xmm3
ja 0x65a7
movss 0x1dc(%rdi), %xmm2
movq 0x40(%rdi), %rcx
ucomiss (%rcx), %xmm2
jbe 0x65a9
popq %rbp
retq
movss 0x98(%rdi), %xmm2
subss %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movsd 0xbc04(%rip), %xmm2     # 0x121c8
mulsd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
ja 0x65a7
mulsd 0xbbfa(%rip), %xmm0     # 0x121d0
ucomisd %xmm1, %xmm0
ja 0x65a7
movw $0x0, 0xa0(%rdi)
addq $0x8, %rax
movq %rax, 0xc8(%rdi)
movl $0x0, 0xc0(%rdi)
movsd 0xbbbe(%rip), %xmm0     # 0x121c0
movsd 0xbbce(%rip), %xmm1     # 0x121d8
movsd 0xbbce(%rip), %xmm2     # 0x121e0
movsd 0xbbce(%rip), %xmm3     # 0x121e8
movsd 0xbaae(%rip), %xmm4     # 0x120d0
movq 0xc8(%rdi), %rax
movss (%rax), %xmm7
movss 0x4(%rax), %xmm9
movaps %xmm7, %xmm6
addss %xmm9, %xmm6
xorps %xmm10, %xmm10
cvtss2sd %xmm6, %xmm10
mulsd %xmm0, %xmm10
movss 0x1e0(%rdi), %xmm8
xorps %xmm5, %xmm5
cvtss2sd %xmm8, %xmm5
ucomisd %xmm5, %xmm10
jbe 0x667a
addq $0x4, %rax
cmpq 0x40(%rdi), %rax
jae 0x6724
ucomiss %xmm9, %xmm7
ja 0x66e6
jmp 0x6704
leaq 0x8(%rax), %rcx
movq %rcx, 0xc8(%rdi)
addss 0x8(%rax), %xmm6
addq $0xc, %rax
cmpq 0x40(%rdi), %rax
jae 0x6751
movss (%rax), %xmm7
addss %xmm7, %xmm6
cvtss2sd %xmm6, %xmm6
movaps %xmm6, %xmm8
mulsd %xmm2, %xmm8
ucomisd %xmm8, %xmm5
movaps %xmm6, %xmm8
mulsd %xmm3, %xmm8
movl $0x1, %eax
ja 0x6782
ucomisd %xmm5, %xmm8
ja 0x6782
mulsd %xmm4, %xmm6
xorps %xmm5, %xmm5
cvtss2sd %xmm7, %xmm5
ucomisd %xmm6, %xmm5
ja 0x6782
movl 0xc0(%rdi), %eax
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
sarl $0x3, %eax
cltq
orb %dl, 0xa0(%rdi,%rax)
addq $0x8, 0xc8(%rdi)
movl 0xc0(%rdi), %ecx
incl %ecx
movl %ecx, 0xc0(%rdi)
xorl %eax, %eax
cmpl $0x9, %ecx
sete %al
jmp 0x6782
movl $0x1, %eax
cmpl $0x8, 0xc0(%rdi)
jne 0x6782
xorps %xmm6, %xmm6
cvtss2sd %xmm7, %xmm6
mulsd %xmm1, %xmm6
movl $0x2, %eax
ucomisd %xmm5, %xmm6
jbe 0x6782
orb $0x1, 0xa1(%rdi)
jmp 0x6782
movl $0x1, %eax
cmpl $0x8, 0xc0(%rdi)
jne 0x6782
xorps %xmm7, %xmm7
cvtss2sd %xmm6, %xmm7
mulsd %xmm1, %xmm7
ucomisd %xmm7, %xmm5
ja 0x6782
ucomiss %xmm8, %xmm6
ja 0x6782
orb $0x1, 0xa1(%rdi)
movl $0x2, %eax
testl %eax, %eax
je 0x6622
cmpl $0x2, %eax
jne 0x65a7
movzbl 0xa0(%rdi), %ecx
movl %ecx, %eax
shrl $0x2, %eax
andl $0x7, %eax
leal (%rax,%rcx,4), %edx
addl $0x3, %edx
andl $0xf, %edx
movl %ecx, %esi
shrl $0x5, %esi
movzbl 0xa1(%rdi), %r8d
andl $0x1, %r8d
leal (%rsi,%r8,8), %esi
cmpl %esi, %edx
jne 0x65a7
andl $0x3, %ecx
movq 0x148(%rdi), %rdx
movw $0x79, 0x4(%rdx)
movl $0x666d6f53, (%rdx)     # imm = 0x666D6F53
movq 0x170(%rdi), %rdx
movl %ecx, (%rdx)
movq 0x160(%rdi), %rcx
movl %eax, (%rcx)
jmp 0x65a7
nop