// File: probonopd[P]decodeir/DecodeIR.cpp
// Function: Signal::tryCanalSat()
void Signal::tryCanalSat()	// GD 2009  Added tryCanalSat

// CanalSat		{55.5k,250,msb}<-1,1|1,-1>(T=0,(1,-1,D:7,S:6,T:1,0:1,F:7,-89m,T=1)+) 
// where T=0 for the first frame and T=1 for all repeats
// (PID = 018C)
// CanalSatLD     {56k,320,msb}<-1,1|1,-1>(T=0,(1,-1,D:7,S:6,T:1,0:1,F:6,~F:1,-85m,T=1)+)  DAR Aug 2012
// Amino		{56.0k,268,msb}<-1,1|1,-1>(T=1,(7,-6,3,D:4,1:1,T:1,1:2,0:8,F:8,15:4,C:4,-79m,T=0)+)
// also 36k is used
// where T=1 for first frame and T=0 for all repeat frames
// with C = sum of the first 7 nibbles mod 15

// Zaptor		{36k,330,msb}<-1,1|1,-1>(8,-6,2,D:8,T:1,S:7,F:8,E:4,C:4,-74m)+
// where T=0 for all frames except the last, T=1 for last frame, E is a checksum seed
// with C = (D:4+D:4:4+S:4+S:3:4+8*T+F:4+F:4:4+E)&15

{
	int HB;
	static int M = 0;	// toggle mask or previous T	
	int T = 0;				// toggle
	static int FC = 0;	// count of bypassed frames
	static int confBits1to32 = 0;	// DAR July 2011
	static int confBits34to65 = 0;	//filled in when a toggle changes state  DAR July 2011

	if ( nFrameL < 11 || nTotDur < 5000) return;
	if (*pFrame < 1000)
	{	
		if (sortBurst.min3 < 570) 
		{                         
			HB = 250;
		}
		else 
		{
			HB = 320;            //DAR AUG 2012 add CanalSatLD                                       
		}
		if (	*pFrame < HB*.5 
			||	nMaxDur < .5*HB 
			||	nMaxDur > 2.5*HB ) 
		{
			return;
		}
	}
	else
	{
		//if (nFreq > 46000)  //DAR March 2011 Some Amino is 36KHz  
		if (sortBurst.min3 < 600) //so use burst times instead
		{                         
			HB = 270;
		}
		else 
		{
			HB = 330;                                                   
		}
		if (	nMaxDur != *pFrame 
			||	nMaxDur < 3.5*HB 
			||	nMaxDur > 14*HB ) // First ON nominally 7 or 8 half bits
		{
			return;
		}
	}

	if (   !framed(40*HB)
		|| sortOn.min1 < HB * .3
		|| sortOn.max2 > HB * 4.5		// nominal 4
        || sortBurst.max2 > HB * 7  )	// nominal 4,-2
	{
		return;
	}

    minGlitch = HB*.25;
	nMinShort2 = HB * .5;
	nMaxShort2 = HB * 1.5;

	cleanup();
	nBit = 1;
	nState = (HB == 270 || HB == 330) ? 0 : 1;
	pBit += 2 - nState;

	while (pBit < pFrameEnd)
	{
		if ( nBit == 1 || ((HB == 270 || HB == 330) && nBit == 2))
		{
			int pulseL = (HB == 270 || HB == 330) && nBit == 1;						// Is initial long MARK?
			nMinShort = HB * (pulseL ? HB == 330 ? 1.5 : 2.4 : .5);	// nominally 2 : 3 : 1
			nMaxShort = nMinLong = HB * (pulseL ? HB == 330 ? 2.5 : 3.5 : 1.5);	// nominally 2 v 3 : 3 v 4 : 1 v 2
			nMaxLong = HB * (pulseL ? HB == 330 ? 3.6 : 4.8 : 2.5);	// nominally 3 : 4 : 2
		}
		if ( ! phaseBit() ) return;
	}
	if ( nBit != ( (HB == 270 || HB == 330) ? 33 : 23 ) ) return;		// wrong number of bits
	if ( (HB == 250 || HB == 320) && getLsb(15,1) ) return;            // bit 15 must be zero for CanalSat

	// look to see if there is a following frame
	float* pFrameEnd1 = pFrameEnd;					// save for later restoration
	float* pFrameEnd2 = pFrameEnd + 1;
	for ( ; pFrameEnd2 < pMainLimit; pFrameEnd2++ )
	{
		if ( *pFrameEnd2 > 40 * HB ) break;
	};
	nState = (HB == 270 || HB == 330) ? 0 : 1;
	pBit = pFrameEnd + 3 - nState;
	pFrameEnd = pFrameEnd2;							// temp change for use by phaseBit{}
	nBit++;

	while ( pBit < pFrameEnd )
	{
		if ( (HB == 270 || HB == 330) && nBit <= 35 )
		{
			int pulseL = nBit == 34;
			nMinShort = HB * (pulseL ? HB == 330 ? 1.5 : 2.4 : .5);
			nMaxShort = nMinLong = HB * (pulseL ? HB == 330 ? 2.5 : 3.5 : 1.5);
			nMaxLong = HB * (pulseL ? HB == 330 ? 3.6 : 4.8 : 2.5);
		}
		if ( ! phaseBit() ) break;
	}
	pFrameEnd = pFrameEnd1;							// restore original value
	makeMsb();
	if ( (HB == 270 || HB == 330) )  //much of the below Amino/Zaptor stuff revised by DAR July 2011
	{
		int s = 0;	// For Amino andZaptor protocols, check checksum
		int tmp1 = getMsb(1,32);  
		int tmp2 = getMsb(34,32); 
		for (int n=1; n<29; n+=4) s += getMsb(n,4);
		if ( getMsb(29,4) != (s&15) ) return; 
		if ( nBit == 66 )
		{
			s = 0;   // check checksum of second frame
			for (int n=34; n<62; n+=4) s += getMsb(n,4);	
			if ( getMsb(62,4) != (s&15) ) return;
			T = ((tmp1 ^ tmp2) & 0xFFFFFFF0);	//mask off checksum nibble
			if ((T == 0x04000000) 			//Amino confirmed; also means subdevice and function codes match
					&& (tmp1 & 0x04000000))		// repeat bit changed from 1 to 0, so tmp1 is a start frame 
			{
				AminoToggleDetected = true;
				confBits1to32 = tmp1;
				confBits34to65 = tmp2;
				if ( FC == 0 ) setzContext();			// save the context value
				FC++;	
				return;			// wait for repeat to come round
			}
			if	((T == 0x00800000)			//Zaptor confirmed; also shows subdevice and function codes match
					&& (tmp2 & 0x00800000)) //repeat bit changed from 0 to 1, so tmp2 is an end frame 
			{  
				ZaptorToggleDetected = true;
				confBits1to32 = tmp1;
				confBits34to65 = tmp2;
			}
		}
	}
	if ( (HB == 250 || HB == 320)&&	nBit == 46 )
	{
		T = getMsb(14,1) ^ getMsb(37,1);				// difference between the toggle values
		if	(	( (M == 0) ^ (T == 0) )					// exactly one of M and T must be zero
			&&	getMsb(1,13) == getMsb(24,13)			// all bits other than toggle must be equal
			&&	getMsb(15,8) == getMsb(38,8) )
		{
			M = 1;										// next frame is valid repeat
			if ( FC == 0 ) setzContext();				// save the context value
			FC++;										// increment count of bypassed frames
			return;										// wait for repeat to come round
		}
	}					
	if ( HB == 250 )
	{
		*pDevice = getMsb(1,7);
		*pSubDevice = getMsb(8,6);
		*pOBC = getMsb(16,7);
		pHex[0] = *pOBC << 1;
		strcpy( pProtocol, "CanalSat" );
		nNote_out = 4;
		strcpy( pMisc, M == 0 ? (nNote_out = 1, nAuxNote_out = 1, "no start frame") : "");
	}
	else if ( HB == 320 )
	{
		*pDevice = getMsb(1,7);
		*pSubDevice = getMsb(8,6);
		*pOBC = getMsb(16,6);
		strcpy( pProtocol, "CanalSatLD" );
		nNote_out = 4;
		strcpy( pMisc, M == 0 ? (nNote_out = 1, nAuxNote_out = 1, "no start frame") : "");
	}
	else 
	{
		if (AminoToggleDetected) HB = 270;		
		else if (ZaptorToggleDetected) HB = 330;	
		else 
		{
			confBits1to32 = getMsb(1,32);
			int tmp3 = confBits1to32 & 0x000000F0; 
			if (tmp3 == 0xF0) HB = 270;			//Amino decided by seed nibble
			else if (tmp3 == 0x50) HB = 330;	//Zaptor 
		}	//  else decide protocol by already determined HB duration 	
		if ( HB == 270 )					//Amino
		{
			*pDevice = (confBits1to32 >> 28) & 0xF;	
			*pSubDevice = (confBits1to32 >> 16) & 0xFF;  //always zero according to the Amino spec
			*pOBC = (confBits1to32 >> 8) & 0xFF;   
			pHex[0] = *pOBC;
			int seed = (confBits1to32 >> 4) & 0xF;
			if (seed != 0x0F) sprintf(pMisc, "E = %d", seed);
			if (nFreq > 46000) strcpy( pProtocol, "Amino-56");
			else strcpy( pProtocol, "Amino-36");
			if (AminoToggleDetected)  nNote_out = 4;
			else
			{
				nNote_out = 1;
				if ((confBits1to32 & 0x04000000) == 0) 
				{
					nAuxNote_out = 1;
					if (*pMisc){strcat(pMisc, ", ");}
					strcat(pMisc, "no start frame");
				}
				else 
				{
					nAuxNote_out = 0;
					if (*pMisc){strcat(pMisc, ", ");}
					strcat(pMisc, "no end frame");
				}
			}
		}
		else if ( HB == 330 )  //Zaptor
		{
			if (!ZaptorToggleDetected && (nBit == 66))  
			{
					if ( FC == 0 ) setzContext();	// save the context value
					FC++;	
					return;			// wait for repeat to come round
			}
			*pDevice = (confBits1to32 >> 24) & 0xFF;
			*pSubDevice = (confBits1to32 >> 16) & 0x7F;  
			*pOBC = (confBits1to32 >> 8) & 0xFF;   
			pHex[0] = *pOBC;
			int seed = (confBits1to32 >> 4) & 0xF;
			if (nFreq > 46000) strcpy( pProtocol, "Zaptor-56");
			else strcpy( pProtocol, "Zaptor-36");
			if (seed != 5) sprintf(pMisc, "E = %d", seed);
			if (ZaptorToggleDetected) nNote_out = 5;  
			else if ((confBits1to32 & 0x00800000) == 0)
			{
				nNote_out = 1;
				nAuxNote_out = 0;
				if (*pMisc){strcat(pMisc, ", ");}
				strcat(pMisc, "no end frame");
			}
			else
			{
				nNote_out = 0;
				nAuxNote_out = 6;
				if (*pMisc){strcat(pMisc, ", ");}
				strcat(pMisc, "no start frame");
			}
		}
	}
	nFrameCount = FC;
	M = 0;		// reset static variables
	FC = 0;		
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0xb, 0x48(%rax)
jl 0x10819
movq -0x58(%rbp), %rax
movss 0x9928(%rip), %xmm0     # 0x1a138
ucomiss 0x98(%rax), %xmm0
jbe 0x1081e
jmp 0x11971
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rax
movss 0x989a(%rip), %xmm0     # 0x1a0c8
ucomiss (%rax), %xmm0
jbe 0x108db
movq -0x58(%rbp), %rax
movss 0x98f9(%rip), %xmm0     # 0x1a13c
ucomiss 0x1c8(%rax), %xmm0
jbe 0x10855
movl $0xfa, -0xc(%rbp)
jmp 0x1085c
movl $0x140, -0xc(%rbp)      # imm = 0x140
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x9947(%rip), %xmm2     # 0x1a1c0
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x108d1
movq -0x58(%rbp), %rax
movss 0x9c(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0xc(%rbp), %xmm2
movsd 0x9920(%rip), %xmm0     # 0x1a1c0
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x108d1
movq -0x58(%rbp), %rax
movss 0x9c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
cvtsi2sdl -0xc(%rbp), %xmm2
movsd 0x99c1(%rip), %xmm1     # 0x1a288
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x108d6
jmp 0x11971
jmp 0x1095e
movq -0x58(%rbp), %rax
movss 0x97c9(%rip), %xmm0     # 0x1a0b0
ucomiss 0x1c8(%rax), %xmm0
jbe 0x108f9
movl $0x10e, -0xc(%rbp)      # imm = 0x10E
jmp 0x10900
movl $0x14a, -0xc(%rbp)      # imm = 0x14A
movq -0x58(%rbp), %rax
movss 0x9c(%rax), %xmm0
movq 0x38(%rax), %rax
ucomiss (%rax), %xmm0
jne 0x10957
jp 0x10957
movq -0x58(%rbp), %rax
movss 0x9c(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0xc(%rbp), %xmm2
movsd 0x9c64(%rip), %xmm0     # 0x1a598
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x10957
movq -0x58(%rbp), %rax
movss 0x9c(%rax), %xmm0
imull $0xe, -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1095c
jmp 0x11971
jmp 0x1095e
movq -0x58(%rbp), %rdi
imull $0x28, -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm0
callq 0x18840
cmpl $0x0, %eax
je 0x109db
movq -0x58(%rbp), %rax
movss 0x180(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x98df(%rip), %xmm2     # 0x1a270
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x109db
movq -0x58(%rbp), %rax
movss 0x188(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
movsd 0x98c8(%rip), %xmm2     # 0x1a280
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x109db
movq -0x58(%rbp), %rax
movss 0x1e0(%rax), %xmm0
imull $0x7, -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x109e0
jmp 0x11971
movq -0x58(%rbp), %rdi
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x98a7(%rip), %xmm1     # 0x1a298
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xe0(%rdi)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x97b2(%rip), %xmm1     # 0x1a1c0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xf4(%rdi)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd 0x9865(%rip), %xmm1     # 0x1a290
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xf8(%rdi)
callq 0x16180
movq -0x58(%rbp), %rax
movl $0x1, 0xc0(%rax)
movb $0x1, %al
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
movb %al, -0x59(%rbp)
je 0x10a69
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
sete %al
movb %al, -0x59(%rbp)
movq -0x58(%rbp), %rax
movb -0x59(%rbp), %sil
movl $0x1, %ecx
xorl %edx, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
movl %ecx, 0xc4(%rax)
movl $0x2, %edx
subl 0xc4(%rax), %edx
movq 0xc8(%rax), %rcx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, 0xc8(%rax)
movq -0x58(%rbp), %rcx
movq 0xc8(%rcx), %rax
cmpq 0x40(%rcx), %rax
jae 0x10ce5
movq -0x58(%rbp), %rax
cmpl $0x1, 0xc0(%rax)
je 0x10af1
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
je 0x10ae0
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
jne 0x10ccd
movq -0x58(%rbp), %rax
cmpl $0x2, 0xc0(%rax)
jne 0x10ccd
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
je 0x10b08
xorl %eax, %eax
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
movb %al, -0x5a(%rbp)
jne 0x10b19
movq -0x58(%rbp), %rax
cmpl $0x1, 0xc0(%rax)
sete %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x10b6e
movl -0xc(%rbp), %eax
movsd 0x9751(%rip), %xmm0     # 0x1a290
movsd 0x9731(%rip), %xmm1     # 0x1a278
movsd %xmm1, -0x78(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0x70(%rbp)
je 0x10b62
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x10b7d
movsd 0x964a(%rip), %xmm0     # 0x1a1c0
movsd %xmm0, -0x80(%rbp)
jmp 0x10b7d
movq -0x58(%rbp), %rax
movsd -0x68(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xe4(%rax)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x10bfa
movl -0xc(%rbp), %eax
movsd 0x96cf(%rip), %xmm0     # 0x1a288
movsd 0x99d7(%rip), %xmm1     # 0x1a598
movsd %xmm1, -0x98(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0x90(%rbp)
je 0x10be8
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0x10c0c
movsd 0x968e(%rip), %xmm0     # 0x1a290
movsd %xmm0, -0xa0(%rbp)
jmp 0x10c0c
movq -0x58(%rbp), %rax
movsd -0x88(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xec(%rax)
movss %xmm0, 0xe8(%rax)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x10c97
movl -0xc(%rbp), %eax
movsd 0x9a1a(%rip), %xmm0     # 0x1a670
movsd 0x981a(%rip), %xmm1     # 0x1a478
movsd %xmm1, -0xb8(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0xb0(%rbp)
je 0x10c85
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
jmp 0x10ca9
movsd 0x95e9(%rip), %xmm0     # 0x1a288
movsd %xmm0, -0xc0(%rbp)
jmp 0x10ca9
movq -0x58(%rbp), %rax
movsd -0xa8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xf0(%rax)
movq -0x58(%rbp), %rdi
callq 0x17050
cmpl $0x0, %eax
jne 0x10ce0
jmp 0x11971
jmp 0x10aa8
movq -0x58(%rbp), %rax
movl 0xc0(%rax), %eax
movl %eax, -0xc8(%rbp)
movb $0x1, %al
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
movb %al, -0xc1(%rbp)
je 0x10d16
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
sete %al
movb %al, -0xc1(%rbp)
movl -0xc8(%rbp), %eax
movb -0xc1(%rbp), %sil
movl $0x17, %ecx
movl $0x21, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
cmpl %ecx, %eax
je 0x10d3d
jmp 0x11971
cmpl $0xfa, -0xc(%rbp)
je 0x10d4f
cmpl $0x140, -0xc(%rbp)      # imm = 0x140
jne 0x10d6c
movq -0x58(%rbp), %rdi
movl $0xf, %esi
movl $0x1, %edx
callq 0x16030
cmpl $0x0, %eax
je 0x10d6c
jmp 0x11971
movq -0x58(%rbp), %rax
movq 0x40(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq 0x40(%rax), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
cmpq 0x10(%rcx), %rax
jae 0x10db9
movq -0x28(%rbp), %rax
movss (%rax), %xmm0
imull $0x28, -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x10da9
jmp 0x10db9
jmp 0x10dab
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x10d84
movb $0x1, %al
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
movb %al, -0xc9(%rbp)
je 0x10dda
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
sete %al
movb %al, -0xc9(%rbp)
movq -0x58(%rbp), %rax
movb -0xc9(%rbp), %sil
movl $0x1, %ecx
xorl %edx, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
movl %ecx, 0xc4(%rax)
movq 0x40(%rax), %rcx
addq $0xc, %rcx
movslq 0xc4(%rax), %rsi
xorl %edx, %edx
subq %rsi, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, 0xc8(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl 0xc0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc0(%rax)
movq -0x58(%rbp), %rcx
movq 0xc8(%rcx), %rax
cmpq 0x40(%rcx), %rax
jae 0x11060
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
je 0x10e5d
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
jne 0x1104b
movq -0x58(%rbp), %rax
cmpl $0x23, 0xc0(%rax)
jg 0x1104b
movq -0x58(%rbp), %rax
cmpl $0x22, 0xc0(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x10ee3
movl -0xc(%rbp), %eax
movsd 0x93ee(%rip), %xmm0     # 0x1a290
movsd 0x93ce(%rip), %xmm1     # 0x1a278
movsd %xmm1, -0xe8(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0xe0(%rbp)
je 0x10ed1
movsd -0xe8(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
jmp 0x10ef5
movsd 0x92d5(%rip), %xmm0     # 0x1a1c0
movsd %xmm0, -0xf0(%rbp)
jmp 0x10ef5
movq -0x58(%rbp), %rax
movsd -0xd8(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xe4(%rax)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x10f78
movl -0xc(%rbp), %eax
movsd 0x9351(%rip), %xmm0     # 0x1a288
movsd 0x9659(%rip), %xmm1     # 0x1a598
movsd %xmm1, -0x108(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0x100(%rbp)
je 0x10f66
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x100(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
jmp 0x10f8a
movsd 0x9310(%rip), %xmm0     # 0x1a290
movsd %xmm0, -0x110(%rbp)
jmp 0x10f8a
movq -0x58(%rbp), %rax
movsd -0xf8(%rbp), %xmm0
movsd -0x110(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xec(%rax)
movss %xmm0, 0xe8(%rax)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x11015
movl -0xc(%rbp), %eax
movsd 0x969c(%rip), %xmm0     # 0x1a670
movsd 0x949c(%rip), %xmm1     # 0x1a478
movsd %xmm1, -0x128(%rbp)
cmpl $0x14a, %eax            # imm = 0x14A
movsd %xmm0, -0x120(%rbp)
je 0x11003
movsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
movsd -0x120(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
jmp 0x11027
movsd 0x926b(%rip), %xmm0     # 0x1a288
movsd %xmm0, -0x130(%rbp)
jmp 0x11027
movq -0x58(%rbp), %rax
movsd -0x118(%rbp), %xmm0
movsd -0x130(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xf0(%rax)
movq -0x58(%rbp), %rdi
callq 0x17050
cmpl $0x0, %eax
jne 0x1105b
jmp 0x11060
jmp 0x10e32
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, 0x40(%rdi)
callq 0x16110
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
je 0x11087
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
jne 0x11216
movq -0x58(%rbp), %rdi
movl $0x0, -0x30(%rbp)
movl $0x1, %esi
movl $0x20, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, -0x34(%rbp)
movl $0x22, %esi
movl $0x20, %edx
callq 0x15f50
movl %eax, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
cmpl $0x1d, -0x3c(%rbp)
jge 0x110e9
movq -0x58(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0x4, %edx
callq 0x15f50
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x3c(%rbp)
jmp 0x110c1
movq -0x58(%rbp), %rdi
movl $0x1d, %esi
movl $0x4, %edx
callq 0x15f50
movl -0x30(%rbp), %ecx
andl $0xf, %ecx
cmpl %ecx, %eax
je 0x1110b
jmp 0x11971
movq -0x58(%rbp), %rax
cmpl $0x42, 0xc0(%rax)
jne 0x11214
movl $0x0, -0x30(%rbp)
movl $0x22, -0x40(%rbp)
cmpl $0x3e, -0x40(%rbp)
jge 0x11152
movq -0x58(%rbp), %rdi
movl -0x40(%rbp), %esi
movl $0x4, %edx
callq 0x15f50
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x40(%rbp)
jmp 0x1112a
movq -0x58(%rbp), %rdi
movl $0x3e, %esi
movl $0x4, %edx
callq 0x15f50
movl -0x30(%rbp), %ecx
andl $0xf, %ecx
cmpl %ecx, %eax
je 0x11174
jmp 0x11971
movl -0x34(%rbp), %eax
xorl -0x38(%rbp), %eax
andl $-0x10, %eax
movl %eax, -0x10(%rbp)
cmpl $0x4000000, -0x10(%rbp) # imm = 0x4000000
jne 0x111dc
movl -0x34(%rbp), %eax
andl $0x4000000, %eax        # imm = 0x4000000
cmpl $0x0, %eax
je 0x111dc
movq -0x58(%rbp), %rax
movl $0x1, 0xb8(%rax)
movl -0x34(%rbp), %eax
movl %eax, 0xe157(%rip)      # 0x1f304
movl -0x38(%rbp), %eax
movl %eax, 0xe152(%rip)      # 0x1f308
cmpl $0x0, 0xe143(%rip)      # 0x1f300
jne 0x111c8
movq -0x58(%rbp), %rdi
callq 0x2860
movl 0xe132(%rip), %eax      # 0x1f300
addl $0x1, %eax
movl %eax, 0xe129(%rip)      # 0x1f300
jmp 0x11971
cmpl $0x800000, -0x10(%rbp)  # imm = 0x800000
jne 0x11212
movl -0x38(%rbp), %eax
andl $0x800000, %eax         # imm = 0x800000
cmpl $0x0, %eax
je 0x11212
movq -0x58(%rbp), %rax
movl $0x1, 0xbc(%rax)
movl -0x34(%rbp), %eax
movl %eax, 0xe0fb(%rip)      # 0x1f304
movl -0x38(%rbp), %eax
movl %eax, 0xe0f6(%rip)      # 0x1f308
jmp 0x11214
jmp 0x11216
cmpl $0xfa, -0xc(%rbp)
je 0x1122c
cmpl $0x140, -0xc(%rbp)      # imm = 0x140
jne 0x1133f
movq -0x58(%rbp), %rax
cmpl $0x2e, 0xc0(%rax)
jne 0x1133f
movq -0x58(%rbp), %rdi
movl $0xe, %esi
movl $0x1, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, -0x134(%rbp)
movl $0x25, %esi
movl $0x1, %edx
callq 0x15f50
movl %eax, %ecx
movl -0x134(%rbp), %eax
xorl %ecx, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, 0xe07f(%rip)      # 0x1f2fc
sete %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, -0x10(%rbp)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
xorl %ecx, %eax
cmpl $0x0, %eax
je 0x1133d
movq -0x58(%rbp), %rdi
movl $0x1, %esi
movl $0xd, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, -0x138(%rbp)
movl $0x18, %esi
movl $0xd, %edx
callq 0x15f50
movl %eax, %ecx
movl -0x138(%rbp), %eax
cmpl %ecx, %eax
jne 0x1133d
movq -0x58(%rbp), %rdi
movl $0xf, %esi
movl $0x8, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, -0x13c(%rbp)
movl $0x26, %esi
movl $0x8, %edx
callq 0x15f50
movl %eax, %ecx
movl -0x13c(%rbp), %eax
cmpl %ecx, %eax
jne 0x1133d
movl $0x1, 0xdfe5(%rip)      # 0x1f2fc
cmpl $0x0, 0xdfe2(%rip)      # 0x1f300
jne 0x11329
movq -0x58(%rbp), %rdi
callq 0x2860
movl 0xdfd1(%rip), %eax      # 0x1f300
addl $0x1, %eax
movl %eax, 0xdfc8(%rip)      # 0x1f300
jmp 0x11971
jmp 0x1133f
cmpl $0xfa, -0xc(%rbp)
jne 0x11446
movq -0x58(%rbp), %rdi
movl $0x1, %esi
movl $0x7, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, %ecx
movq 0x160(%rdi), %rax
movl %ecx, (%rax)
movl $0x8, %esi
movl $0x6, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, %ecx
movq 0x168(%rdi), %rax
movl %ecx, (%rax)
movl $0x10, %esi
movl $0x7, %edx
callq 0x15f50
movl %eax, %edx
movq -0x58(%rbp), %rax
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x170(%rax), %rcx
movl (%rcx), %edx
shll %edx
movq 0x178(%rax), %rcx
movl %edx, (%rcx)
movq 0x148(%rax), %rdi
leaq 0x9abb(%rip), %rsi      # 0x1ae87
callq 0x2120
movq -0x58(%rbp), %rax
movl $0x4, 0x88(%rax)
movq 0x150(%rax), %rax
movq %rax, -0x148(%rbp)
cmpl $0x0, 0xdf08(%rip)      # 0x1f2fc
jne 0x1141e
movq -0x58(%rbp), %rax
movl $0x1, 0x88(%rax)
movl $0x1, 0x8c(%rax)
leaq 0x9a1d(%rip), %rax      # 0x1ae32
movq %rax, -0x150(%rbp)
jmp 0x1142e
leaq 0x9e0e(%rip), %rax      # 0x1b233
movq %rax, -0x150(%rbp)
jmp 0x1142e
movq -0x148(%rbp), %rdi
movq -0x150(%rbp), %rsi
callq 0x2120
jmp 0x11950
cmpl $0x140, -0xc(%rbp)      # imm = 0x140
jne 0x11539
movq -0x58(%rbp), %rdi
movl $0x1, %esi
movl $0x7, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, %ecx
movq 0x160(%rdi), %rax
movl %ecx, (%rax)
movl $0x8, %esi
movl $0x6, %edx
callq 0x15f50
movq -0x58(%rbp), %rdi
movl %eax, %ecx
movq 0x168(%rdi), %rax
movl %ecx, (%rax)
movl $0x10, %esi
movl $0x6, %edx
callq 0x15f50
movl %eax, %edx
movq -0x58(%rbp), %rax
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x148(%rax), %rdi
leaq 0x99d1(%rip), %rsi      # 0x1ae90
callq 0x2120
movq -0x58(%rbp), %rax
movl $0x4, 0x88(%rax)
movq 0x150(%rax), %rax
movq %rax, -0x158(%rbp)
cmpl $0x0, 0xde15(%rip)      # 0x1f2fc
jne 0x11511
movq -0x58(%rbp), %rax
movl $0x1, 0x88(%rax)
movl $0x1, 0x8c(%rax)
leaq 0x992a(%rip), %rax      # 0x1ae32
movq %rax, -0x160(%rbp)
jmp 0x11521
leaq 0x9d1b(%rip), %rax      # 0x1b233
movq %rax, -0x160(%rbp)
jmp 0x11521
movq -0x158(%rbp), %rdi
movq -0x160(%rbp), %rsi
callq 0x2120
jmp 0x1194e
movq -0x58(%rbp), %rax
cmpl $0x0, 0xb8(%rax)
je 0x1154f
movl $0x10e, -0xc(%rbp)      # imm = 0x10E
jmp 0x115b1
movq -0x58(%rbp), %rax
cmpl $0x0, 0xbc(%rax)
je 0x11565
movl $0x14a, -0xc(%rbp)      # imm = 0x14A
jmp 0x115af
movq -0x58(%rbp), %rdi
movl $0x1, %esi
movl $0x20, %edx
callq 0x15f50
movl %eax, 0xdd86(%rip)      # 0x1f304
movl 0xdd80(%rip), %eax      # 0x1f304
andl $0xf0, %eax
movl %eax, -0x44(%rbp)
cmpl $0xf0, -0x44(%rbp)
jne 0x1159e
movl $0x10e, -0xc(%rbp)      # imm = 0x10E
jmp 0x115ad
cmpl $0x50, -0x44(%rbp)
jne 0x115ab
movl $0x14a, -0xc(%rbp)      # imm = 0x14A
jmp 0x115ad
jmp 0x115af
jmp 0x115b1
cmpl $0x10e, -0xc(%rbp)      # imm = 0x10E
jne 0x1175e
movq -0x58(%rbp), %rax
movl 0xdd3c(%rip), %edx      # 0x1f304
sarl $0x1c, %edx
andl $0xf, %edx
movq 0x160(%rax), %rcx
movl %edx, (%rcx)
movl 0xdd27(%rip), %edx      # 0x1f304
sarl $0x10, %edx
andl $0xff, %edx
movq 0x168(%rax), %rcx
movl %edx, (%rcx)
movl 0xdd0f(%rip), %edx      # 0x1f304
sarl $0x8, %edx
andl $0xff, %edx
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x170(%rax), %rcx
movl (%rcx), %ecx
movq 0x178(%rax), %rax
movl %ecx, (%rax)
movl 0xdce5(%rip), %eax      # 0x1f304
sarl $0x4, %eax
andl $0xf, %eax
movl %eax, -0x48(%rbp)
cmpl $0xf, -0x48(%rbp)
je 0x1164a
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
movl -0x48(%rbp), %edx
leaq 0x9858(%rip), %rsi      # 0x1ae9b
movb $0x0, %al
callq 0x2060
movq -0x58(%rbp), %rax
cmpl $0xb3b0, 0x2c(%rax)     # imm = 0xB3B0
jle 0x11670
movq -0x58(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x9839(%rip), %rsi      # 0x1aea2
callq 0x2120
jmp 0x11687
movq -0x58(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x9829(%rip), %rsi      # 0x1aeab
callq 0x2120
movq -0x58(%rbp), %rax
cmpl $0x0, 0xb8(%rax)
je 0x116a7
movq -0x58(%rbp), %rax
movl $0x4, 0x88(%rax)
jmp 0x11759
movq -0x58(%rbp), %rax
movl $0x1, 0x88(%rax)
movl 0xdc49(%rip), %eax      # 0x1f304
andl $0x4000000, %eax        # imm = 0x4000000
cmpl $0x0, %eax
jne 0x1170f
movq -0x58(%rbp), %rax
movl $0x1, 0x8c(%rax)
movq 0x150(%rax), %rax
cmpb $0x0, (%rax)
je 0x116f6
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x97c3(%rip), %rsi      # 0x1aeb4
callq 0x2230
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x972a(%rip), %rsi      # 0x1ae32
callq 0x2230
jmp 0x11757
movq -0x58(%rbp), %rax
movl $0x0, 0x8c(%rax)
movq 0x150(%rax), %rax
cmpb $0x0, (%rax)
je 0x11740
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x9779(%rip), %rsi      # 0x1aeb4
callq 0x2230
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x9795(%rip), %rsi      # 0x1aee7
callq 0x2230
jmp 0x11759
jmp 0x1194c
cmpl $0x14a, -0xc(%rbp)      # imm = 0x14A
jne 0x1194a
movq -0x58(%rbp), %rax
cmpl $0x0, 0xbc(%rax)
jne 0x117ab
movq -0x58(%rbp), %rax
cmpl $0x42, 0xc0(%rax)
jne 0x117ab
cmpl $0x0, 0xdb74(%rip)      # 0x1f300
jne 0x11797
movq -0x58(%rbp), %rdi
callq 0x2860
movl 0xdb63(%rip), %eax      # 0x1f300
addl $0x1, %eax
movl %eax, 0xdb5a(%rip)      # 0x1f300
jmp 0x11971
movq -0x58(%rbp), %rax
movl 0xdb4f(%rip), %edx      # 0x1f304
sarl $0x18, %edx
andl $0xff, %edx
movq 0x160(%rax), %rcx
movl %edx, (%rcx)
movl 0xdb37(%rip), %edx      # 0x1f304
sarl $0x10, %edx
andl $0x7f, %edx
movq 0x168(%rax), %rcx
movl %edx, (%rcx)
movl 0xdb22(%rip), %edx      # 0x1f304
sarl $0x8, %edx
andl $0xff, %edx
movq 0x170(%rax), %rcx
movl %edx, (%rcx)
movq 0x170(%rax), %rcx
movl (%rcx), %edx
movq 0x178(%rax), %rcx
movl %edx, (%rcx)
movl 0xdaf8(%rip), %ecx      # 0x1f304
sarl $0x4, %ecx
andl $0xf, %ecx
movl %ecx, -0x4c(%rbp)
cmpl $0xb3b0, 0x2c(%rax)     # imm = 0xB3B0
jle 0x11837
movq -0x58(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x9687(%rip), %rsi      # 0x1aeb7
callq 0x2120
jmp 0x1184e
movq -0x58(%rbp), %rax
movq 0x148(%rax), %rdi
leaq 0x9678(%rip), %rsi      # 0x1aec1
callq 0x2120
cmpl $0x5, -0x4c(%rbp)
je 0x11870
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
movl -0x4c(%rbp), %edx
leaq 0x9632(%rip), %rsi      # 0x1ae9b
movb $0x0, %al
callq 0x2060
movq -0x58(%rbp), %rax
cmpl $0x0, 0xbc(%rax)
je 0x11890
movq -0x58(%rbp), %rax
movl $0x5, 0x88(%rax)
jmp 0x11948
movl 0xda6e(%rip), %eax      # 0x1f304
andl $0x800000, %eax         # imm = 0x800000
cmpl $0x0, %eax
jne 0x118f4
movq -0x58(%rbp), %rax
movl $0x1, 0x88(%rax)
movl $0x0, 0x8c(%rax)
movq 0x150(%rax), %rax
cmpb $0x0, (%rax)
je 0x118db
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x95de(%rip), %rsi      # 0x1aeb4
callq 0x2230
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x95fa(%rip), %rsi      # 0x1aee7
callq 0x2230
jmp 0x11946
movq -0x58(%rbp), %rax
movl $0x0, 0x88(%rax)
movl $0x6, 0x8c(%rax)
movq 0x150(%rax), %rax
cmpb $0x0, (%rax)
je 0x1192f
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x958a(%rip), %rsi      # 0x1aeb4
callq 0x2230
movq -0x58(%rbp), %rax
movq 0x150(%rax), %rdi
leaq 0x94f1(%rip), %rsi      # 0x1ae32
callq 0x2230
jmp 0x11948
jmp 0x1194a
jmp 0x1194c
jmp 0x1194e
jmp 0x11950
movq -0x58(%rbp), %rax
movl 0xd9a6(%rip), %ecx      # 0x1f300
movl %ecx, 0x60(%rax)
movl $0x0, 0xd995(%rip)      # 0x1f2fc
movl $0x0, 0xd98f(%rip)      # 0x1f300
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw (%rax,%rax)