// File: /workspace/github_cpp_makefile_star2_O3/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 0xcd3a
movl $0x44100, %eax          # imm = 0x44100
btl %r14d, %eax
jae 0xcd3a
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movss 0x5af5(%rip), %xmm0     # 0x12644
ucomiss (%rax), %xmm0
jae 0xcd3a
movq 0x38(%rbx), %r15
movss (%r15), %xmm0
movss 0x188(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jae 0xcd3a
ucomiss 0x5acf(%rip), %xmm1     # 0x12648
ja 0xcd3a
movss 0x1dc(%rbx), %xmm1
ucomiss 0x5ab6(%rip), %xmm1     # 0x12644
ja 0xcd3a
addss 0x4(%r15), %xmm0
ucomiss 0x5aab(%rip), %xmm0     # 0x1264c
ja 0xcd3a
movss 0x18c(%rbx), %xmm0
divss 0x180(%rbx), %xmm0
cvtss2sd %xmm0, %xmm0
addsd 0x588d(%rip), %xmm0     # 0x12450
cvttsd2si %xmm0, %eax
testl %eax, %eax
jne 0xcd3a
leaq 0xa0(%rbx), %rax
movq %rax, -0x38(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xa0(%rbx)
movq %r15, 0xc8(%rbx)
movq $0x0, 0xc0(%rbx)
leal -0x2(%r14), %eax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
xorl %r13d, %r13d
xorps %xmm0, %xmm0
cvtss2sd 0xc(%r15,%r13,8), %xmm0
addsd 0x5840(%rip), %xmm0     # 0x12458
mulsd 0x5840(%rip), %xmm0     # 0x12460
callq 0x21f0
cvttsd2si %xmm0, %eax
cmpl $0x3, %eax
ja 0xcd3a
movl %r12d, %ecx
notb %cl
andb $0x6, %cl
shll %cl, %eax
movl %r13d, %ecx
shrl $0x2, %ecx
movq -0x38(%rbp), %rdx
orb %al, (%rdx,%rcx)
incq %r13
addl $0x2, %r12d
cmpq %r13, -0x30(%rbp)
jne 0xcc06
cmpl $0x8, %r14d
jne 0xcc9c
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)
movb 0xa0(%rbx), %al
movb 0xa1(%rbx), %cl
shrb $0x4, %cl
shlb $0x4, %al
orb %cl, %al
movzbl %al, %eax
jmp 0xccdc
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 0xcce7
movw $0x61, 0x4(%rax)
movl $0x696b6f4e, (%rax)     # imm = 0x696B6F4E
movzbl 0xa2(%rbx), %eax
movq 0x170(%rbx), %rcx
movl %eax, (%rcx)
jmp 0xcd31
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 0x616b(%rip), %rsi      # 0x12e8c
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
nop