// File: /workspace/github_cpp_makefile_star2_O3/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 0xdb28
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 0x4dd8(%rip), %xmm0     # 0x12670
jb 0xdb1a
movq 0x40(%rbx), %rax
movss 0x4dc6(%rip), %xmm0     # 0x12670
ucomiss (%rax), %xmm0
jbe 0xd8c4
movslq 0x20(%rbx), %rcx
shlq $0x3, %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jb 0xdb1a
movq 0x38(%rbx), %r12
movss 0x8(%r12), %xmm0
movss 0x4d9d(%rip), %xmm1     # 0x12674
ucomiss %xmm0, %xmm1
ja 0xdb1a
ucomiss 0x4d91(%rip), %xmm0     # 0x12678
ja 0xdb1a
movss 0x9c(%rbx), %xmm0
ucomiss 0x4d74(%rip), %xmm0     # 0x12670
ja 0xdb1a
movss 0x4d72(%rip), %xmm1     # 0x1267c
ucomiss %xmm0, %xmm1
ja 0xdb1a
movss 0x4d5d(%rip), %xmm0     # 0x12678
ucomiss 0x184(%rbx), %xmm0
jbe 0xdb1a
movss 0x180(%rbx), %xmm0
ucomiss 0x4d3d(%rip), %xmm0     # 0x12674
ja 0xd94a
ucomiss (%r12), %xmm0
jne 0xdb1a
jp 0xdb1a
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 0x4af2(%rip), %xmm0     # 0x12490
callq 0x21f0
cvttsd2si %xmm0, %edx
addl $0x2, %edx
movl %edx, %eax
sarl $0x3, %eax
addl %r15d, %eax
cmpl $0xa, %eax
jl 0xda13
movl $0xff, %eax
movl %r15d, %ecx
shll %cl, %eax
movslq %r14d, %rcx
orb %al, 0xa0(%rbx,%rcx)
movb $0x0, 0xa1(%rbx,%rcx)
movq 0x40(%rbx), %rcx
cmpq %rcx, %r12
ja 0xdb1a
incl %r14d
movss (%r12), %xmm0
ucomiss 0x4c80(%rip), %xmm0     # 0x12670
jae 0xda5b
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 0xda52
jmp 0xda5b
movq 0x40(%rbx), %rcx
cmpq %rcx, %r12
je 0xdb1a
andl $0x7, %edx
cmpl $0x4, %edx
ja 0xda5b
cmpl $0x7, %eax
jg 0xda5b
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
movl %eax, %r15d
addq $0x8, %r12
jmp 0xd961
cmpq %rcx, %r12
jb 0xdb1a
movq 0x148(%rbx), %rdi
leaq 0x5545(%rip), %rsi      # 0x12fb7
movl %r14d, %edx
xorl %eax, %eax
callq 0x2060
testl %r14d, %r14d
jle 0xdb1a
movl %r13d, %eax
sarl %eax
movq %rax, -0x30(%rbp)
testb $0x1, %r13b
leaq 0x552c(%rip), %rax      # 0x12fc5
leaq 0x551f(%rip), %r12      # 0x12fbf
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 0x5505(%rip), %rsi      # 0x12fcb
leaq 0x543f(%rip), %rax      # 0x12f0c
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 0xdaaa
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop