// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x48(%rdi), %r14d
cmpl $0x12, %r14d
ja 0xbf91
movl $0x44100, %eax          # imm = 0x44100
btl %r14d, %eax
jae 0xbf91
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movss 0x5891(%rip), %xmm0     # 0x11644
ucomiss (%rax), %xmm0
jae 0xbf91
movq 0x38(%rbx), %r15
movss (%r15), %xmm0
movss 0x188(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jae 0xbf91
ucomiss 0x586b(%rip), %xmm1     # 0x11648
ja 0xbf91
movss 0x1dc(%rbx), %xmm1
ucomiss 0x5852(%rip), %xmm1     # 0x11644
ja 0xbf91
addss 0x4(%r15), %xmm0
ucomiss 0x5847(%rip), %xmm0     # 0x1164c
ja 0xbf91
movss 0x18c(%rbx), %xmm0
divss 0x180(%rbx), %xmm0
cvtss2sd %xmm0, %xmm0
addsd 0x5629(%rip), %xmm0     # 0x11450
cvttsd2si %xmm0, %eax
testl %eax, %eax
jne 0xbf91
leaq 0xa0(%rbx), %rax
movq %rax, -0x30(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xa0(%rbx)
movq %r15, 0xc8(%rbx)
andq $0x0, 0xc0(%rbx)
leal -0x2(%r14), %eax
movq %rax, -0x38(%rbp)
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %r13, -0x38(%rbp)
je 0xbeb6
cvtss2sd 0xc(%r15,%r13,8), %xmm0
addsd 0x55dc(%rip), %xmm0     # 0x11458
mulsd 0x55dc(%rip), %xmm0     # 0x11460
callq 0x2210
cvttsd2si %xmm0, %eax
cmpl $0x3, %eax
ja 0xbf91
movl %r12d, %ecx
notb %cl
andb $0x6, %cl
shll %cl, %eax
movl %r13d, %ecx
shrl $0x2, %ecx
movq -0x30(%rbp), %rdx
orb %al, (%rdx,%rcx)
incq %r13
addl $0x2, %r12d
jmp 0xbe67
cmpl $0x8, %r14d
jne 0xbef3
movq 0x148(%rbx), %rax
movabsq $0x323161696b6f4e, %rcx # imm = 0x323161696B6F4E
movq %rcx, (%rax)
movzbl 0xa0(%rbx), %eax
shrl $0x4, %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
pushq $0x4
popq %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0xeb6a
jmp 0xbf33
movzbl 0xa0(%rbx), %eax
movq 0x160(%rbx), %rcx
movl %eax, (%rcx)
movzbl 0xa1(%rbx), %eax
movq 0x168(%rbx), %rcx
movl %eax, (%rcx)
cmpl $0xe, 0x48(%rbx)
movq 0x148(%rbx), %rax
jne 0xbf3e
movw $0x61, 0x4(%rax)
movl $0x696b6f4e, (%rax)     # imm = 0x696B6F4E
movzbl 0xa2(%rbx), %eax
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
jmp 0xbf88
movabsq $0x323361696b6f4e, %rcx # imm = 0x323361696B6F4E
movq %rcx, (%rax)
movzbl 0xa3(%rbx), %eax
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
movq 0x150(%rbx), %rdi
movzbl 0xa2(%rbx), %ecx
movl %ecx, %edx
andl $0x7f, %edx
shrl $0x7, %ecx
leaq 0x5f14(%rip), %rsi      # 0x11e8c
xorl %eax, %eax
callq 0x2060
movq 0x170(%rbx), %rax
movl (%rax), %eax
movq 0x178(%rbx), %rcx
movl %eax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq