// File: probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryNokia()
void Signal::tryNokia()
// Nokia12 {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:4,F:8,164,-???)+
// Nokia   {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:8,S:8,F:8,164,-???)+
// Nokia32 {36k,msb}<164,-276|164,-445|164,-614|164,-783>(412,-276,D:8,S:8,X:8,F:8,164,^100m)+
{
	enum { ON=164, BASE=276, UNIT=169 };
	const double SCALE = 1./UNIT;

	if (   (nFrameL != 8 && nFrameL != 14 && nFrameL != 18)
		|| *pFrameEnd <= BASE+UNIT*4.5 )  // Require some end framing
	{
		return;
	}
	int (*_abs)( int ) = & std::abs;
    if (   pFrame[0] <= sortOn.max2           // Require that the first On be largest
		|| sortOn.max2 > ON*1.5               // Require that the largest On other than the first not be excessive
		|| sortBurst.max1 > BASE+UNIT*4.5     // Require that the largest Burst not be excessive
		|| pFrame[0]+pFrame[1] > BASE+UNIT*3. // Require first pair not too large
		||_abs(sortOff.min1/sortOn.min1 - 276./164.) > 0.2  ) //require about the correct ratio of durations DAR 2012
	{
		return;
	}
//	if (   nFrameL == 8
//		&& pOff[0] + UNIT*.5 > pOff[5] )
//	{
//		return;
//	}
	cleanup();

	for (int ndx=0; ndx<nFrameL-2; ndx++)
	{
		int nVal = (int)floor((pFrame[ndx*2+3] - (BASE-UNIT*.5) ) * SCALE);
		if (nVal<0 || nVal>3)
			return;

		cBits[ndx>>2] |= nVal << (6-(ndx&3)*2);
	}
	if ( nFrameL == 8 )
	{
		strcpy(pProtocol, "Nokia12");
		*pDevice = getMsb(0,4);		// Was getLsb in both places, bug found by Barf
		*pOBC = getMsb(4,8);
	}
	else
	{
		*pDevice = cBits[0];
		*pSubDevice = cBits[1];
		if ( nFrameL == 14 )
		{
			strcpy(pProtocol, "Nokia");
			*pOBC = cBits[2];
		}
		else
		{
			strcpy(pProtocol, "Nokia32");
			*pOBC = cBits[3];
			sprintf(pMisc,"X=%d T=%d", cBits[2]&0x7F, (cBits[2]&0x80) >> 7 );
		}
	}
	pHex[0] = *pOBC;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movsd 0x8cdc(%rip), %xmm0     # 0x1a678
movsd %xmm0, -0x10(%rbp)
cmpl $0x8, 0x48(%rax)
je 0x119bb
movq -0x28(%rbp), %rax
cmpl $0xe, 0x48(%rax)
je 0x119bb
movq -0x28(%rbp), %rax
cmpl $0x12, 0x48(%rax)
jne 0x119d9
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x8cad(%rip), %xmm0     # 0x1a680
ucomisd %xmm1, %xmm0
jb 0x119de
jmp 0x11c94
movq -0x28(%rbp), %rax
movq 0xd5c7(%rip), %rcx      # 0x1efb0
movq %rcx, -0x18(%rbp)
movq 0x38(%rax), %rcx
movss (%rcx), %xmm1
movss 0x188(%rax), %xmm0
ucomiss %xmm1, %xmm0
jae 0x11aad
movq -0x28(%rbp), %rax
movss 0x188(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8c6a(%rip), %xmm1     # 0x1a688
ucomisd %xmm1, %xmm0
ja 0x11aad
movq -0x28(%rbp), %rax
movss 0x1dc(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8c40(%rip), %xmm1     # 0x1a680
ucomisd %xmm1, %xmm0
ja 0x11aad
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rcx
movss (%rcx), %xmm0
movq 0x38(%rax), %rax
addss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8c29(%rip), %xmm1     # 0x1a690
ucomisd %xmm1, %xmm0
ja 0x11aad
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movss 0x18c(%rcx), %xmm0
divss 0x180(%rcx), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8c07(%rip), %xmm1     # 0x1a698
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %edi
callq *%rax
cvtsi2sd %eax, %xmm0
movsd 0x8999(%rip), %xmm1     # 0x1a440
ucomisd %xmm1, %xmm0
jbe 0x11ab2
jmp 0x11c94
movq -0x28(%rbp), %rdi
callq 0x16180
movl $0x0, -0x1c(%rbp)
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %eax
movl 0x48(%rcx), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0x11b68
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x1c(%rbp), %ecx
shll %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8ba5(%rip), %xmm1     # 0x1a6a0
subsd %xmm1, %xmm0
movsd 0x8b71(%rip), %xmm1     # 0x1a678
mulsd %xmm1, %xmm0
callq 0x2200
cvttsd2si %xmm0, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x11b23
cmpl $0x3, -0x20(%rbp)
jle 0x11b28
jmp 0x11c94
movq -0x28(%rbp), %rax
movl -0x20(%rbp), %esi
movl -0x1c(%rbp), %edx
andl $0x3, %edx
shll %edx
movl $0x6, %ecx
subl %edx, %ecx
shll %cl, %esi
movl -0x1c(%rbp), %ecx
sarl $0x2, %ecx
movslq %ecx, %rcx
movzbl 0xa0(%rax,%rcx), %edx
orl %esi, %edx
movb %dl, 0xa0(%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x11ac2
movq -0x28(%rbp), %rax
cmpl $0x8, 0x48(%rax)
jne 0x11bcb
movq -0x28(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x940d(%rip), %rsi      # 0x1af91
callq 0x2120
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x15f50
movq -0x28(%rbp), %rdi
movl %eax, %ecx
movq 0x160(%rdi), %rax
movl %ecx, (%rax)
movl $0x4, %esi
movl $0x8, %edx
callq 0x15f50
movl %eax, %ecx
movq -0x28(%rbp), %rax
movq 0x170(%rax), %rax
movl %ecx, (%rax)
jmp 0x11c7e
movq -0x28(%rbp), %rax
movzbl 0xa0(%rax), %edx
movq 0x160(%rax), %rcx
movl %edx, (%rcx)
movzbl 0xa1(%rax), %edx
movq 0x168(%rax), %rcx
movl %edx, (%rcx)
cmpl $0xe, 0x48(%rax)
jne 0x11c22
movq -0x28(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x9392(%rip), %rsi      # 0x1af99
callq 0x2120
movq -0x28(%rbp), %rax
movzbl 0xa2(%rax), %ecx
movq 0x170(%rax), %rax
movl %ecx, (%rax)
jmp 0x11c7c
movq -0x28(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x936b(%rip), %rsi      # 0x1af9f
callq 0x2120
movq -0x28(%rbp), %rax
movzbl 0xa3(%rax), %edx
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x150(%rax), %rdi
movzbl 0xa2(%rax), %edx
andl $0x7f, %edx
movzbl 0xa2(%rax), %ecx
andl $0x80, %ecx
sarl $0x7, %ecx
leaq 0x9332(%rip), %rsi      # 0x1afa7
movb $0x0, %al
callq 0x2060
jmp 0x11c7e
movq -0x28(%rbp), %rax
movq 0x170(%rax), %rcx
movl (%rcx), %ecx
movq 0x178(%rax), %rax
movl %ecx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)