// File: /workspace/github_cpp_makefile_star2_O3/probonopd[P]decodeir/DecodeIR.cpp
// Function: DecodeIR
void DecodeIR_API DecodeIR
(	unsigned int* Context,		//In/Out - Array of unsigned 4 byte integers.  For input it tells dll in what context it should 
								//decode the signal, and on output the context it would need to decode the next part of the signal.
								//It has a minimum length of 2, and on first call, both integers are 0.  Further information can
								//be passed in either direction by increasing its length.  See TiSubDevice below.
	int* TpaiBursts, 			//In - Array of integers containing the burst lengths in microseconds, 
								//the length of the array is 2*(TiSingleBurstCount + TiRepeatBurstCount +
								//ExtraBurstCount), where ExtraBurstCount is carried in TiDevice, see below.
	int TiFreq,					//In - Frequency in Hz of the signal.  Use -1 for unknown.  Any positive
								//   value less than 500000/longest_on will be treated as unmodulated, but
								//   normally unmodulated should be represented as 0.
	int TiSingleBurstCount,		//In - Number of bursts sent once
	int TiRepeatBurstCount,		//In - Number of bursts sent repeatedly

	// For all int* outputs, the caller must preset the value to -1 and the decoder will not change the value
	//   unless it finds a decode and that decode includes that value.
	// Similarly char* outputs should have their first byte set to 0 by the caller and the decoder will
	//   overwrite with a null terminated string only when that string is not empty.
	char* TsProtocol,			//Out - 255 character string name of the decoded protocol
	int* TiDevice,				//Out - Integer device number.
								//In  - If < -1 and RepeatBurstCount > 0, it is -ExtraBurstCount.  If < -1
								//and RepeatBurstCount = 0 it flags that the frame count should not be returned
								//to the caller.  The caller should include any extra bursts in with the single
								//bursts in this case.  All versions of IR.exe have done this.
	int* TiSubDevice,			//Out - Integer sub device number.
								//In  - If < -1 it is negative of the length of the Context array.  A handshake
								//protocol is used to return to the caller the actual length that has been
								//interpreted and acted upon by the version of DecodeIR in use.  This version
								//supports a maximum length of 9.  See decode2() for more details.
	int* TiOBC,					//Out - Integer OBC of the decoded signal
	int* TaiHex,				//Out - Array of 4 integers containing up to 4 different one-byte Hex commands
								//if returning less that 4 hex values, the remaining integers should be -1
	char* TsMisc,				//Out - 255 character string of Misc text, used whenever more explanation of 
								//the results should be returned
	char* TsError)				//Out - 255 character string containing an error message if the dll encountered an error
{
	if (TiSingleBurstCount + TiRepeatBurstCount >= MinFrame)
	{
		char szMessage[500];
		sprintf(szMessage,"N=%d SCount=%d RCount=%d Burst1=%d Freq=%d hex[0]=%d Error=\"%s\""
			,*Context, TiSingleBurstCount, TiRepeatBurstCount, TpaiBursts[1],TiFreq,TaiHex[-1],TsError);
		//	MessageBox(0,szMessage,"DecodeIR",0);
		Signal _Signal(
			Context,
			TpaiBursts, 	
			TiFreq, 
			TiSingleBurstCount, 
			TiRepeatBurstCount, 
			TsProtocol, 
			TiDevice, 
			TiSubDevice, 
			TiOBC, 
			TaiHex, 
			TsMisc, 
			TsError );

		_Signal.decode2();	// GD 2009 changed from decode()
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movl %r8d, %r14d
movl %ecx, %r15d
leal (%r14,%r15), %eax
cmpl $0x2, %eax
jl 0x10c3b
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %rbx
movq 0x28(%rbp), %rax
movl (%rdi), %edx
movq %r9, -0x30(%rbp)
movl 0x4(%rsi), %r9d
movl -0x4(%rax), %r10d
subq $0x8, %rsp
leaq 0x24c7(%rip), %rsi      # 0x13097
leaq -0x410(%rbp), %rdi
movl %r15d, %ecx
movl %r14d, %r8d
xorl %eax, %eax
pushq 0x38(%rbp)
pushq %r10
pushq %r12
callq 0x2060
addq $0x18, %rsp
leaq -0x218(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl %r12d, %ecx
movl %r15d, %r8d
movl %r14d, %r9d
pushq 0x38(%rbp)
pushq 0x30(%rbp)
pushq 0x28(%rbp)
pushq 0x20(%rbp)
pushq 0x18(%rbp)
pushq 0x10(%rbp)
pushq -0x30(%rbp)
callq 0x23cc
addq $0x40, %rsp
leaq -0x218(%rbp), %rdi
callq 0xeea4
leaq -0x218(%rbp), %rdi
callq 0x268a
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0x268a
movq %rbx, %rdi
callq 0x2210