// File: NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::OpenInputLMF(char*)
bool LMF_IO::OpenInputLMF(__int8 * LMF_Filename)
/////////////////////////////////////////////////////////////////
{
	unsigned __int32	unsigned_int_Dummy;
	__int32				data_format_in_header;
	__int8				byte_Dummy;
	__int32				byte_counter;

	if (InputFileIsOpen) {
		errorflag = 3; // file is already open
		return false;
	}
	input_lmf = new MyFILE(true);

	TDC8HP.UserHeaderVersion = 0; // yes, 0 is ok here and 2 in LMF_IO::initialization is also ok

	input_lmf->open(LMF_Filename);

	if (input_lmf->error) {
		errorflag = 4; // could not open file
		input_lmf = 0;
		return false;
	}

//L10:

//  READ LMF-HEADER
	ArchiveFlag = 0;

	*input_lmf >> ArchiveFlag;

	DAQ_SOURCE_CODE_bitmasked  =  ArchiveFlag & DAQ_SOURCE_CODE;
	DAN_SOURCE_CODE_bitmasked  =  ArchiveFlag & DAN_SOURCE_CODE;
	CCF_HISTORY_CODE_bitmasked =  ArchiveFlag & CCF_HISTORY_CODE;

	ArchiveFlag = ArchiveFlag & 0x1fffffff;
	
	if (ArchiveFlag != 476758 && ArchiveFlag != 476759) { // is this not a Cobold list mode file?
		not_Cobold_LMF = true;
		if (!OpenNonCoboldFile()) return false;
		errorflag = 0; // no error
		InputFileIsOpen = true;
		return true;
	}

	if (ArchiveFlag == 476758) Cobold_Header_version = 2002;
	if (ArchiveFlag == 476759) Cobold_Header_version = 2008;

	*input_lmf >> data_format_in_header;

	data_format_in_userheader = data_format_in_header;
	if (data_format_in_header != LM_USERDEF && data_format_in_header != LM_SHORT && data_format_in_header != LM_SLONG && data_format_in_header != LM_DOUBLE && data_format_in_header != LM_CAMAC) {
		errorflag = 8;
		CloseInputLMF();
		return false;
	}

	if (Cobold_Header_version <= 2002)	*input_lmf >> Numberofcoordinates;
	if (Cobold_Header_version >= 2008)	{
		unsigned __int64 temp;
		*input_lmf >> temp;
		Numberofcoordinates =__int32(temp);
	}
	
	if (Numberofcoordinates >= 0) CAMAC_Data = new unsigned __int32[Numberofcoordinates];

	if (Cobold_Header_version <= 2002)	*input_lmf >> Headersize;
	if (Cobold_Header_version >= 2008)	{
		unsigned __int64 temp;
		*input_lmf >> temp;
		Headersize =__int32(temp);
	}


	if (Cobold_Header_version <= 2002)	*input_lmf >> User_header_size;
	if (Cobold_Header_version >= 2008)	{
		unsigned __int64 temp;
		*input_lmf >> temp;
		User_header_size =__int32(temp);
	}

	if (skip_header) {
		__int32 backstep;
		if (Cobold_Header_version <= 2002) backstep = sizeof(__int32)*5;
		if (Cobold_Header_version >= 2008) backstep = sizeof(__int32)*2 + sizeof(__int64)*3;
		for (unsigned __int32 i=0;i<Headersize-backstep;++i) *input_lmf >> byte_Dummy;
		for (unsigned __int32 i=0;i<User_header_size;++i) *input_lmf >> byte_Dummy;
		errorflag = 0; // no error
		InputFileIsOpen = true;
		goto L666;
	}

	if (Cobold_Header_version >= 2008) *input_lmf >> uint64_Numberofevents;
	if (Cobold_Header_version <= 2002) {
		__int32 temp;
		*input_lmf >> temp;
		uint64_Numberofevents = temp;
	}

	// get CTime version:
	if (!CTime_version) {
		unsigned __int32 dummy_uint32;
		unsigned __int64 pos = input_lmf->tell(); 
		*input_lmf >> dummy_uint32;
		if (dummy_uint32 == (unsigned) INT_MIN_ + 10) CTime_version = 2005; else CTime_version = 2003;
		input_lmf->seek(pos);
	}
	
	CTime_version_output = CTime_version;

	unsigned __int32 dummy_uint32;
	if(CTime_version >= 2005) {
		*input_lmf >> dummy_uint32;
		*input_lmf >> dummy_uint32; Starttime = dummy_uint32;
		*input_lmf >> dummy_uint32;
	} else {*input_lmf >> dummy_uint32; Starttime = dummy_uint32;}

	if(CTime_version >= 2005) {
		*input_lmf >> dummy_uint32;
		*input_lmf >> dummy_uint32; Stoptime = dummy_uint32;
		*input_lmf >> dummy_uint32;
	} else {
		*input_lmf >> dummy_uint32; Stoptime = dummy_uint32;
	}

	Read_CString_as_StdString(*input_lmf,Versionstring);
	Read_CString_as_StdString(*input_lmf,FilePathName);
	Read_CString_as_StdString(*input_lmf,Comment);
	Comment_output = Comment;

	byte_counter = 0;

	if (CCF_HISTORY_CODE_bitmasked) {
		*input_lmf >> number_of_CCFHistory_strings;
		CCFHistory_strings = new std::string*[number_of_CCFHistory_strings];
		memset(CCFHistory_strings,0,sizeof(std::string*)*number_of_CCFHistory_strings);
		for (__int32 i=0;i<number_of_CCFHistory_strings;++i) {
			__int32 string_len;
			*input_lmf >> string_len;
			CCFHistory_strings[i] = new std::string();
			CCFHistory_strings[i]->reserve(string_len);
			while (string_len > 0) {
				__int8 c;
				*input_lmf >> c;	
				*CCFHistory_strings[i] += c;
				--string_len;
			}
		}
	}

	if (DAN_SOURCE_CODE_bitmasked) {
		*input_lmf >> number_of_DAN_source_strings;
		DAN_source_strings = new std::string*[number_of_DAN_source_strings];
		memset(DAN_source_strings,0,sizeof(std::string*)*number_of_DAN_source_strings);
		for (__int32 i=0;i<number_of_DAN_source_strings;++i) {
			__int32 string_len;
			*input_lmf >> string_len;
			DAN_source_strings[i] = new std::string();
			DAN_source_strings[i]->reserve(string_len);
			while (string_len > 0) {
				__int8 c;
				*input_lmf >> c; 
				*DAN_source_strings[i] += c;
				--string_len;
			}
		}
	}	



	if (User_header_size == 0) {
		errorflag = 6;
		InputFileIsOpen = false;
		goto L666;
	}

	if ((unsigned) __int32(input_lmf->tell()) != Headersize) {
		errorflag = 6;
		InputFileIsOpen = false;
		goto L666;
	}



//  READ USER-HEADER
	if (Cobold_Header_version >= 2008) {
		*input_lmf >> LMF_Header_version;   byte_counter += sizeof(__int32);
	}

	if (Cobold_Header_version <= 2002) {*input_lmf >> unsigned_int_Dummy;	byte_counter += sizeof(__int32);}

	if (Cobold_Header_version >= 2008) {
		unsigned __int64 temp;
		*input_lmf >> temp;	unsigned_int_Dummy = (unsigned __int32)(temp);
		byte_counter += sizeof(unsigned __int64);
	}


	if (unsigned_int_Dummy != User_header_size) {
		errorflag = 6; // error reading header
		CloseInputLMF();
		return false;
	}

	*input_lmf >> DAQVersion;	byte_counter += sizeof(__int32);	// Version is always 2nd value

	*input_lmf >> DAQ_ID;		byte_counter += sizeof(__int32);	// DAQ_ID is always 3ed value

	if (DAQ_ID == DAQ_ID_TDC8)		goto L100;
	if (DAQ_ID == DAQ_ID_2TDC8)		goto L100;
	if (DAQ_ID == DAQ_ID_TDC8HP)	goto L100;
	if (DAQ_ID == DAQ_ID_TDC8HPRAW)	goto L100;
	if (DAQ_ID == DAQ_ID_HM1)		goto L100;
	if (DAQ_ID == DAQ_ID_CAMAC)		goto L100;
	if (DAQ_ID == DAQ_ID_HM1_ABM)	goto L100;
	if (DAQ_ID == DAQ_ID_TCPIP)		goto L100;
	if (DAQ_ID == DAQ_ID_FADC8)		goto L100;
	if (DAQ_ID == DAQ_ID_FADC4)		goto L100;

	errorflag = 7; // LMF not data of TDC8PCI2 or 2TDC8PCI2 or TDC8HP or CAMAC or HM1 or TCPIP
	CloseInputLMF();
	return false;

L100:
	if (DAQ_ID == DAQ_ID_TDC8)	 byte_counter += ReadTDC8PCI2Header();
	if (DAQ_ID == DAQ_ID_2TDC8)	 byte_counter += Read2TDC8PCI2Header();
	if (DAQ_ID == DAQ_ID_TDC8HP || DAQ_ID == DAQ_ID_TDC8HPRAW) byte_counter += ReadTDC8HPHeader_LMFV_1_to_7(byte_counter);
	if (DAQ_ID == DAQ_ID_HM1 || DAQ_ID == DAQ_ID_HM1_ABM)     byte_counter += ReadHM1Header();
	if (DAQ_ID == DAQ_ID_CAMAC)  byte_counter += ReadCAMACHeader();
	if (DAQ_ID == DAQ_ID_TCPIP)  byte_counter += ReadTCPIPHeader();
	if (DAQ_ID == DAQ_ID_FADC8)  byte_counter += ReadfADC8Header();
	if (DAQ_ID == DAQ_ID_FADC4)  byte_counter += ReadfADC4Header_up_to_v11();

	if ((User_header_size != (unsigned) byte_counter) || (data_format_in_userheader != data_format_in_header)) {
		if (!(DAQ_ID == DAQ_ID_TDC8 && this->LMF_Version == 0x8)
			&& !(this->LMF_Version == 7 && (DAQ_ID == DAQ_ID_HM1 || DAQ_ID == DAQ_ID_HM1_ABM) && DAQVersion == 20080507 && User_header_size > 100000)) {
			errorflag = 6; // error reading header
			CloseInputLMF();
			return false;
		}
	}

	if (data_format_in_header != LM_USERDEF && data_format_in_userheader != LM_SHORT && data_format_in_userheader != LM_SLONG && data_format_in_userheader != LM_DOUBLE && data_format_in_userheader != LM_CAMAC) {
		errorflag = 6; // error reading header
		CloseInputLMF();
		return false;
	}

	errorflag = 0; // no error
	InputFileIsOpen = true;

L666:

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
testb $0x1, 0x2b28(%rax)
je 0x4271
movq -0xa0(%rbp), %rax
movl $0x3, 0x12e0(%rax)
movb $0x0, -0x1(%rbp)
jmp 0x5150
movl $0x28, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movl $0x1, %esi
callq 0x1cf90
jmp 0x4294
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x2b18(%rax)
movl $0x0, 0x14dc(%rax)
movq 0x2b18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1cfe0
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rax
cmpl $0x0, 0x8(%rax)
je 0x431e
movq -0xa0(%rbp), %rax
movl $0x4, 0x12e0(%rax)
movq $0x0, 0x2b18(%rax)
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x28, %esi
callq 0x21a0
jmp 0x515e
movq -0xa0(%rbp), %rsi
movl $0x0, 0x248(%rsi)
movq 0x2b18(%rsi), %rdi
addq $0x248, %rsi            # imm = 0x248
callq 0x1cb80
movq -0xa0(%rbp), %rax
movl 0x248(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x12e8(%rax)
movl 0x248(%rax), %ecx
andl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x12ec(%rax)
movl 0x248(%rax), %ecx
andl $0x20000000, %ecx       # imm = 0x20000000
movl %ecx, 0x12f0(%rax)
movl 0x248(%rax), %ecx
andl $0x1fffffff, %ecx       # imm = 0x1FFFFFFF
movl %ecx, 0x248(%rax)
cmpl $0x74656, 0x248(%rax)   # imm = 0x74656
je 0x43f1
movq -0xa0(%rbp), %rax
cmpl $0x74657, 0x248(%rax)   # imm = 0x74657
je 0x43f1
movq -0xa0(%rbp), %rdi
movb $0x1, 0x2b3c(%rdi)
callq 0x4100
testb $0x1, %al
jne 0x43d0
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rax
movl $0x0, 0x12e0(%rax)
movb $0x1, 0x2b28(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rax
cmpl $0x74656, 0x248(%rax)   # imm = 0x74656
jne 0x4415
movq -0xa0(%rbp), %rax
movl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
movq -0xa0(%rbp), %rax
cmpl $0x74657, 0x248(%rax)   # imm = 0x74657
jne 0x4439
movq -0xa0(%rbp), %rax
movl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1cf60
movq -0xa0(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, 0x290(%rax)
cmpl $-0x1, -0x20(%rbp)
je 0x449d
cmpl $0x2, -0x20(%rbp)
je 0x449d
cmpl $0xa, -0x20(%rbp)
je 0x449d
cmpl $0x5, -0x20(%rbp)
je 0x449d
cmpl $0x6, -0x20(%rbp)
je 0x449d
movq -0xa0(%rbp), %rdi
movl $0x8, 0x12e0(%rdi)
callq 0x3cf0
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x44ca
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x270, %rsi            # imm = 0x270
callq 0x1cf60
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x4505
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1cbb0
movq -0xa0(%rbp), %rax
movq -0x40(%rbp), %rcx
movl %ecx, 0x270(%rax)
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x270(%rax)
jl 0x4555
movq -0xa0(%rbp), %rax
movslq 0x270(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x2b78(%rax)
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x4582
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x298, %rsi            # imm = 0x298
callq 0x1cb80
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x45bd
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1cbb0
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %ecx, 0x298(%rax)
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x45ea
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x29c, %rsi            # imm = 0x29C
callq 0x1cb80
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x4625
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1cbb0
movq -0xa0(%rbp), %rax
movq -0x50(%rbp), %rcx
movl %ecx, 0x29c(%rax)
movq -0xa0(%rbp), %rax
testb $0x1, 0x12e4(%rax)
je 0x4705
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x4653
movl $0x14, -0x54(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x466d
movl $0x20, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x58(%rbp), %eax
movl 0x298(%rcx), %ecx
subl -0x54(%rbp), %ecx
cmpl %ecx, %eax
jae 0x46ad
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x21(%rbp), %rsi
callq 0x1d0e0
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x4674
movl $0x0, -0x5c(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x5c(%rbp), %eax
cmpl 0x29c(%rcx), %eax
jae 0x46e8
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x21(%rbp), %rsi
callq 0x1d0e0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x46b4
movq -0xa0(%rbp), %rax
movl $0x0, 0x12e0(%rax)
movb $0x1, 0x2b28(%rax)
jmp 0x514c
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x4732
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x268, %rsi            # imm = 0x268
callq 0x1cbb0
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x476e
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1cf60
movq -0xa0(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq %rcx, 0x268(%rax)
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x274(%rax)
jne 0x47f3
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
callq 0x1d110
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq 0x2b18(%rax), %rdi
leaq -0x64(%rbp), %rsi
callq 0x1cb80
cmpl $0x8000000a, -0x64(%rbp) # imm = 0x8000000A
jne 0x47cb
movq -0xa0(%rbp), %rax
movl $0x7d5, 0x274(%rax)     # imm = 0x7D5
jmp 0x47dc
movq -0xa0(%rbp), %rax
movl $0x7d3, 0x274(%rax)     # imm = 0x7D3
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x2440
movq -0xa0(%rbp), %rax
movl 0x274(%rax), %ecx
movl %ecx, 0x278(%rax)
cmpl $0x7d5, 0x274(%rax)     # imm = 0x7D5
jl 0x4863
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movl -0x74(%rbp), %ecx
movq %rcx, 0x220(%rax)
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
jmp 0x488b
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movl -0x74(%rbp), %ecx
movq %rcx, 0x220(%rax)
movq -0xa0(%rbp), %rax
cmpl $0x7d5, 0x274(%rax)     # imm = 0x7D5
jl 0x48ef
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movl -0x74(%rbp), %ecx
movq %rcx, 0x228(%rax)
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
jmp 0x4917
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x74(%rbp), %rsi
callq 0x1cb80
movq -0xa0(%rbp), %rax
movl -0x74(%rbp), %ecx
movq %rcx, 0x228(%rax)
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
callq 0x2630
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x20, %rsi
callq 0x2630
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x60, %rsi
callq 0x2630
movq -0xa0(%rbp), %rdi
movq %rdi, %rsi
addq $0x60, %rsi
addq $0x80, %rdi
callq 0x2040
movq -0xa0(%rbp), %rax
movl $0x0, -0x28(%rbp)
cmpl $0x0, 0x12f0(%rax)
je 0x4add
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x12f4, %rsi           # imm = 0x12F4
callq 0x1cf60
movq -0xa0(%rbp), %rax
movslq 0x12f4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x1300(%rax)
movq 0x1300(%rax), %rdi
movslq 0x12f4(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20d0
movl $0x0, -0x78(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x78(%rbp), %eax
cmpl 0x12f4(%rcx), %eax
jge 0x4adb
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x1cf60
movl $0x20, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, -0xb0(%rbp)
callq 0x2260
movq -0xb0(%rbp), %rsi
movq -0xa0(%rbp), %rax
movq 0x1300(%rax), %rcx
movslq -0x78(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x1300(%rax), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x22d0
cmpl $0x0, -0x7c(%rbp)
jle 0x4acb
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x7d(%rbp), %rsi
callq 0x1d0e0
movq -0xa0(%rbp), %rcx
movb -0x7d(%rbp), %al
movq 0x1300(%rcx), %rcx
movslq -0x78(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movsbl %al, %esi
callq 0x2100
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x4a82
jmp 0x4acd
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x4a07
jmp 0x4add
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x12ec(%rax)
je 0x4c6b
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x1310, %rsi           # imm = 0x1310
callq 0x1cf60
movq -0xa0(%rbp), %rax
movslq 0x1310(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x1318(%rax)
movq 0x1318(%rax), %rdi
movslq 0x1310(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20d0
movl $0x0, -0x84(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x84(%rbp), %eax
cmpl 0x1310(%rcx), %eax
jge 0x4c69
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1cf60
movl $0x20, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, -0xb8(%rbp)
callq 0x2260
movq -0xb8(%rbp), %rsi
movq -0xa0(%rbp), %rax
movq 0x1318(%rax), %rcx
movslq -0x84(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x1318(%rax), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x88(%rbp), %rsi
callq 0x22d0
cmpl $0x0, -0x88(%rbp)
jle 0x4c53
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x89(%rbp), %rsi
callq 0x1d0e0
movq -0xa0(%rbp), %rcx
movb -0x89(%rbp), %al
movq 0x1318(%rcx), %rcx
movslq -0x84(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movsbl %al, %esi
callq 0x2100
movl -0x88(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x4bf8
jmp 0x4c55
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x4b6e
jmp 0x4c6b
movq -0xa0(%rbp), %rax
cmpl $0x0, 0x29c(%rax)
jne 0x4c98
movq -0xa0(%rbp), %rax
movl $0x6, 0x12e0(%rax)
movb $0x0, 0x2b28(%rax)
jmp 0x514c
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
callq 0x1d110
movq -0xa0(%rbp), %rcx
cmpl 0x298(%rcx), %eax
je 0x4cd7
movq -0xa0(%rbp), %rax
movl $0x6, 0x12e0(%rax)
movb $0x0, 0x2b28(%rax)
jmp 0x514c
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x4d0f
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x12b0, %rsi           # imm = 0x12B0
callq 0x1cb80
movslq -0x28(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x7d2, 0x24c(%rax)     # imm = 0x7D2
jg 0x4d44
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x1cb80
movslq -0x28(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0x4d86
movq -0xa0(%rbp), %rax
movq 0x2b18(%rax), %rdi
leaq -0x98(%rbp), %rsi
callq 0x1cbb0
movq -0x98(%rbp), %rax
movl %eax, -0x1c(%rbp)
movslq -0x28(%rbp), %rax
addq $0x8, %rax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x29c(%rcx), %eax
je 0x4db7
movq -0xa0(%rbp), %rdi
movl $0x6, 0x12e0(%rdi)
callq 0x3cf0
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rsi
movq 0x2b18(%rsi), %rdi
addq $0x280, %rsi            # imm = 0x280
callq 0x1cb80
movq -0xa0(%rbp), %rsi
movslq -0x28(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x28(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x288, %rsi            # imm = 0x288
callq 0x1cb80
movq -0xa0(%rbp), %rax
movslq -0x28(%rbp), %rcx
addq $0x4, %rcx
movl %ecx, -0x28(%rbp)
cmpl $0x2, 0x288(%rax)
jne 0x4e16
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x5, 0x288(%rax)
jne 0x4e2b
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x8, 0x288(%rax)
jne 0x4e40
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x10, 0x288(%rax)
jne 0x4e55
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x1, 0x288(%rax)
jne 0x4e67
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x3, 0x288(%rax)
jne 0x4e79
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x6, 0x288(%rax)
jne 0x4e8b
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x9, 0x288(%rax)
jne 0x4e9d
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x11, 0x288(%rax)
jne 0x4eaf
jmp 0x4ee0
movq -0xa0(%rbp), %rax
cmpl $0x12, 0x288(%rax)
jne 0x4ec1
jmp 0x4ee0
movq -0xa0(%rbp), %rdi
movl $0x7, 0x12e0(%rdi)
callq 0x3cf0
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rax
cmpl $0x2, 0x288(%rax)
jne 0x4f02
movq -0xa0(%rbp), %rdi
callq 0x5170
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x5, 0x288(%rax)
jne 0x4f24
movq -0xa0(%rbp), %rdi
callq 0x58d0
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x8, 0x288(%rax)
je 0x4f44
movq -0xa0(%rbp), %rax
cmpl $0x10, 0x288(%rax)
jne 0x4f59
movq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x6760
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x1, 0x288(%rax)
je 0x4f79
movq -0xa0(%rbp), %rax
cmpl $0x6, 0x288(%rax)
jne 0x4f8b
movq -0xa0(%rbp), %rdi
callq 0x7c90
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x3, 0x288(%rax)
jne 0x4fad
movq -0xa0(%rbp), %rdi
callq 0x87c0
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x9, 0x288(%rax)
jne 0x4fcf
movq -0xa0(%rbp), %rdi
callq 0x8a00
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x11, 0x288(%rax)
jne 0x4ff1
movq -0xa0(%rbp), %rdi
callq 0x8c50
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0x12, 0x288(%rax)
jne 0x5013
movq -0xa0(%rbp), %rdi
callq 0x8de0
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0xa0(%rbp), %rax
movl 0x29c(%rax), %eax
cmpl -0x28(%rbp), %eax
jne 0x503b
movq -0xa0(%rbp), %rax
movl 0x290(%rax), %eax
cmpl -0x20(%rbp), %eax
je 0x50d2
movq -0xa0(%rbp), %rax
cmpl $0x2, 0x288(%rax)
jne 0x505b
movq -0xa0(%rbp), %rax
cmpl $0x8, 0x12a4(%rax)
je 0x50d0
movq -0xa0(%rbp), %rax
cmpl $0x7, 0x12a4(%rax)
jne 0x50b1
movq -0xa0(%rbp), %rax
cmpl $0x1, 0x288(%rax)
je 0x508b
movq -0xa0(%rbp), %rax
cmpl $0x6, 0x288(%rax)
jne 0x50b1
movq -0xa0(%rbp), %rax
cmpl $0x132677b, 0x280(%rax) # imm = 0x132677B
jne 0x50b1
movq -0xa0(%rbp), %rax
cmpl $0x186a0, 0x29c(%rax)   # imm = 0x186A0
ja 0x50d0
movq -0xa0(%rbp), %rdi
movl $0x6, 0x12e0(%rdi)
callq 0x3cf0
movb $0x0, -0x1(%rbp)
jmp 0x5150
jmp 0x50d2
cmpl $-0x1, -0x20(%rbp)
je 0x5134
movq -0xa0(%rbp), %rax
cmpl $0x2, 0x290(%rax)
je 0x5134
movq -0xa0(%rbp), %rax
cmpl $0xa, 0x290(%rax)
je 0x5134
movq -0xa0(%rbp), %rax
cmpl $0x5, 0x290(%rax)
je 0x5134
movq -0xa0(%rbp), %rax
cmpl $0x6, 0x290(%rax)
je 0x5134
movq -0xa0(%rbp), %rdi
movl $0x6, 0x12e0(%rdi)
callq 0x3cf0
movb $0x0, -0x1(%rbp)
jmp 0x5150
movq -0xa0(%rbp), %rax
movl $0x0, 0x12e0(%rax)
movb $0x1, 0x2b28(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x22f0
nopw (%rax,%rax)