// File: /workspace/github_cpp_makefile_star2_O2/probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryAirboard()
void Signal::tryAirboard()
{
	if ( nFrameL < 5 )
		return;
	// Left framing always checked
	if (!framedLeft(22*8*105))
		return;
	// Right framing only checked if outside repeat section
	if (   *pFrameEnd < 22*8*105
		&& pFrameEnd < pDuration+2*nSingle )
	{
		return;
	}
	if (pFrame[2] < 5*105 || pFrame[2] > 8*105)
		return;
	if (nMaxDur > 22*8*105 || nMaxDur < 2*8*105)
		return;
    require( sortOn.max1 < 8*105 )
    require( sortOn.min1 > 5*105 || sortOn.min1 == pFrame[0] )

    double rClock = 1.0 / 105;
	int repByte = -1;
	int bytes = 0;
	int phase = 0;
	cBits[0] = 0;
    float* pX;
	for (pX = pFrame+1; ; pX+=2)
	{
		if ( pX == pDuration+2*nSingle+1 && repByte < 0 )
		{
			repByte = 2*bytes;
			if ( phase )
				--repByte;
		}
		int nb = (int)( floor( *pX * rClock) ) + 2;  // Number of sequential one bits
		int np = (nb >> 3) + phase;                  // New phase after those one bits
		if (np >= 10)                                // End of valid byte
		{
			cBits[bytes] |= (0xFF)<<phase;
			phase = 0;
			cBits[++bytes] = 0;
			if ( pX > pFrameEnd )                // Found a valid byte past requested frame
				return;                          // so requested frame is wrong.
			if ( *pX >= 22*8*105 )
				break;
			if ( pX >= pDuration+2*(nSingle+nRepeat)-1 )
				break;
		}
		else
		{
			if ( pX == pFrameEnd )					 // Frame ends on non byte boundary
				return;                              // so requested frame is wrong.
			if ( np > 7 )                            // Stop bits are wrong
				break;                               //   stop and check if past valid frame
			if ( (nb & 7) >= 5 )                     // Not whole number of bits
				break;                               //   stop and check if past valid frame
			cBits[bytes] |= (1<<np) - (1<<phase);
			phase = np+1;
		}
	}
	if ( pX < pFrameEnd )
		return;
	sprintf(pProtocol, "AirB%d-", bytes);
	for (int nn=0; nn<bytes; ++nn)
	{
		sprintf(pProtocol+strlen(pProtocol),
			(nn==(repByte>>1))
			   ? ( (repByte & 1 ) ? ":%02X" : ";%02X" )
			   : ( nn ? ".%02X" : "%02X" )
			, cBits[nn] );
		*pOBC = cBits[0] & 7;
		*pDevice = cBits[0] >> 3;
	}
}

// Assembly:
cmpl $0x5, 0x48(%rdi)
jl 0xcbd8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movss 0x13c(%rdi), %xmm0
ucomiss 0x4c5a(%rip), %xmm0     # 0x11670
jb 0xcbca
movq 0x40(%rbx), %rax
movss 0x4c48(%rip), %xmm0     # 0x11670
ucomiss (%rax), %xmm0
jbe 0xca42
movslq 0x20(%rbx), %rcx
shlq $0x3, %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jb 0xcbca
movq 0x38(%rbx), %r12
movss 0x8(%r12), %xmm0
movss 0x4c1f(%rip), %xmm1     # 0x11674
ucomiss %xmm0, %xmm1
ja 0xcbca
ucomiss 0x4c13(%rip), %xmm0     # 0x11678
ja 0xcbca
movss 0x9c(%rbx), %xmm0
ucomiss 0x4bf6(%rip), %xmm0     # 0x11670
ja 0xcbca
movss 0x4bf4(%rip), %xmm1     # 0x1167c
ucomiss %xmm0, %xmm1
ja 0xcbca
movss 0x4bdf(%rip), %xmm0     # 0x11678
ucomiss 0x184(%rbx), %xmm0
jbe 0xcbca
movss 0x180(%rbx), %xmm0
ucomiss 0x4bbf(%rip), %xmm0     # 0x11674
ja 0xcac8
ucomiss (%r12), %xmm0
jne 0xcbca
jp 0xcbca
movb $0x0, 0xa0(%rbx)
addq $0x4, %r12
pushq $-0x1
popq %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movl %r13d, %eax
movq 0x8(%rbx), %rcx
leal (%r14,%r14), %r13d
cmpl $0x1, %r15d
adcl $-0x1, %r13d
movslq 0x20(%rbx), %rdx
testl %eax, %eax
cmovnsl %eax, %r13d
leaq (%rcx,%rdx,8), %rcx
addq $0x4, %rcx
cmpq %rcx, %r12
cmovnel %eax, %r13d
cvtss2sd (%r12), %xmm0
mulsd 0x4979(%rip), %xmm0     # 0x11490
callq 0x2210
cvttsd2si %xmm0, %esi
addl $0x2, %esi
movl %esi, %eax
sarl $0x3, %eax
addl %r15d, %eax
movslq %r14d, %rdx
cmpl $0xa, %eax
jl 0xcb88
movl $0xff, %eax
movl %r15d, %ecx
shll %cl, %eax
orb %al, 0xa0(%rbx,%rdx)
movb $0x0, 0xa1(%rbx,%rdx)
movq 0x40(%rbx), %rcx
cmpq %rcx, %r12
ja 0xcbca
incl %r14d
movss (%r12), %xmm0
ucomiss 0x4b0b(%rip), %xmm0     # 0x11670
jae 0xcbc5
movq 0x8(%rbx), %rax
movslq 0x20(%rbx), %rdx
movslq 0x24(%rbx), %rsi
addq %rdx, %rsi
leaq (%rax,%rsi,8), %rax
addq $-0x4, %rax
xorl %r15d, %r15d
cmpq %rax, %r12
jb 0xcbbc
jmp 0xcbc5
movq 0x40(%rbx), %rcx
cmpq %rcx, %r12
je 0xcbca
andl $0x7, %esi
cmpl $0x4, %esi
ja 0xcbc5
cmpl $0x7, %eax
jg 0xcbc5
pushq $0x1
popq %rsi
movl %eax, %ecx
shll %cl, %esi
pushq $-0x1
popq %rdi
movl %r15d, %ecx
shll %cl, %edi
addl %esi, %edi
orb %dil, 0xa0(%rbx,%rdx)
incl %eax
movl %eax, %r15d
addq $0x8, %r12
jmp 0xcadd
cmpq %rcx, %r12
jae 0xcbd9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x148(%rbx), %rdi
leaq 0x53d0(%rip), %rsi      # 0x11fb7
xorl %r15d, %r15d
movl %r14d, %edx
xorl %eax, %eax
callq 0x2060
movl %r13d, %eax
sarl %eax
movq %rax, -0x30(%rbp)
testb $0x1, %r13b
leaq 0x53bd(%rip), %rax      # 0x11fc5
leaq 0x53b0(%rip), %r13      # 0x11fbf
cmoveq %rax, %r13
testl %r14d, %r14d
cmovlel %r15d, %r14d
xorl %r12d, %r12d
cmpq %r12, %r14
je 0xcbca
movq 0x148(%rbx), %r15
movq %r15, %rdi
callq 0x20a0
addq %rax, %r15
testq %r12, %r12
leaq 0x538d(%rip), %rsi      # 0x11fcb
leaq 0x52c7(%rip), %rax      # 0x11f0c
cmoveq %rax, %rsi
cmpq %r12, -0x30(%rbp)
cmoveq %r13, %rsi
movzbl 0xa0(%rbx,%r12), %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2060
movzbl 0xa0(%rbx), %eax
andl $0x7, %eax
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
movzbl 0xa0(%rbx), %eax
shrl $0x3, %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
incq %r12
jmp 0xcc1d
nop