// File: /workspace/github_cpp_makefile_star2_O1/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 0xdaff
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 0x4e2c(%rip), %xmm0     # 0x12674
jb 0xdaf1
movq 0x40(%rbx), %rax
movss 0x4e1a(%rip), %xmm0     # 0x12674
ucomiss (%rax), %xmm0
jbe 0xd874
movslq 0x20(%rbx), %rcx
shlq $0x3, %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jb 0xdaf1
movq 0x38(%rbx), %r12
movss 0x8(%r12), %xmm0
movss 0x4df1(%rip), %xmm1     # 0x12678
ucomiss %xmm0, %xmm1
ja 0xdaf1
ucomiss 0x4de5(%rip), %xmm0     # 0x1267c
ja 0xdaf1
movss 0x9c(%rbx), %xmm0
ucomiss 0x4dc8(%rip), %xmm0     # 0x12674
ja 0xdaf1
movss 0x4dc6(%rip), %xmm1     # 0x12680
ucomiss %xmm0, %xmm1
ja 0xdaf1
movss 0x4db1(%rip), %xmm0     # 0x1267c
ucomiss 0x184(%rbx), %xmm0
jbe 0xdaf1
movss 0x180(%rbx), %xmm0
ucomiss 0x4d91(%rip), %xmm0     # 0x12678
ja 0xd8fa
ucomiss (%r12), %xmm0
jne 0xdaf1
jp 0xdaf1
movb $0x0, 0xa0(%rbx)
addq $0x4, %r12
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
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
xorps %xmm0, %xmm0
cvtss2sd (%r12), %xmm0
mulsd 0x4b42(%rip), %xmm0     # 0x12490
callq 0x21f0
cvttsd2si %xmm0, %ecx
addl $0x2, %ecx
movl %ecx, %eax
sarl $0x3, %eax
addl %r15d, %eax
cmpl $0xa, %eax
jl 0xd9cf
movl $0xff, %eax
movl %r15d, %ecx
shll %cl, %eax
movslq %r14d, %rcx
orb %al, 0xa0(%rbx,%rcx)
incl %r14d
movb $0x0, 0xa1(%rbx,%rcx)
movl $0x1, %ecx
xorl %r15d, %r15d
cmpq 0x40(%rbx), %r12
ja 0xda1b
movss (%r12), %xmm0
movl $0x2, %ecx
ucomiss 0x4cca(%rip), %xmm0     # 0x12674
jae 0xda1b
movq 0x8(%rbx), %rax
movslq 0x20(%rbx), %rcx
movslq 0x24(%rbx), %rdx
addq %rcx, %rdx
leaq (%rax,%rdx,8), %rax
addq $-0x4, %rax
xorl %ecx, %ecx
cmpq %rax, %r12
setae %cl
addl %ecx, %ecx
jmp 0xda1b
cmpq 0x40(%rbx), %r12
je 0xda16
cmpl $0x8, %eax
setge %dl
andl $0x7, %ecx
cmpl $0x5, %ecx
setae %cl
orb %dl, %cl
movl $0x2, %ecx
jne 0xda1b
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %esi
addl %edx, %esi
movslq %r14d, %rcx
orb %sil, 0xa0(%rbx,%rcx)
incl %eax
xorl %ecx, %ecx
movl %eax, %r15d
jmp 0xda1b
movl $0x1, %ecx
testl %ecx, %ecx
jne 0xda28
addq $0x8, %r12
jmp 0xd911
cmpl $0x2, %ecx
jne 0xdaf1
cmpq 0x40(%rbx), %r12
jb 0xdaf1
movq 0x148(%rbx), %rdi
leaq 0x5577(%rip), %rsi      # 0x12fc0
movl %r14d, %edx
xorl %eax, %eax
callq 0x2060
testl %r14d, %r14d
jle 0xdaf1
movl %r13d, %eax
sarl %eax
movq %rax, -0x30(%rbp)
testb $0x1, %r13b
leaq 0x555e(%rip), %rax      # 0x12fce
leaq 0x5551(%rip), %r12      # 0x12fc8
cmoveq %rax, %r12
movl %r14d, %r13d
xorl %r15d, %r15d
movq 0x148(%rbx), %r14
movq %r14, %rdi
callq 0x2090
addq %rax, %r14
testq %r15, %r15
leaq 0x5537(%rip), %rsi      # 0x12fd4
leaq 0x5471(%rip), %rax      # 0x12f15
cmoveq %rax, %rsi
cmpq %r15, -0x30(%rbp)
cmoveq %r12, %rsi
movzbl 0xa0(%rbx,%r15), %edx
movq %r14, %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 %r15
cmpq %r15, %r13
jne 0xda81
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq