// File: /workspace/github_cpp_makefile_star2_O3/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::OpenOutputLMF(char*)
bool LMF_IO::OpenOutputLMF(__int8 * LMF_Filename)
/////////////////////////////////////////////////////////////////
{
//	double				double_Dummy = 0.;
//	unsigned __int32	unsigned_int_Dummy = 0;
//	__int32				int_Dummy = 0;

	if (OutputFileIsOpen) {
		errorflag = 12; // file is already open
		return false;
	}
	output_lmf = new MyFILE(false);

	fADC8.at_least_1_signal_was_written = false;

	output_lmf->open(LMF_Filename);

	if (output_lmf->error) {
		errorflag = 11; // could not open output file
		return false;
	}

//	out_ar = new CArchive(output_lmf,CArchive::store);
//	if (!out_ar) {
//		errorflag = 13; // could not connect CAchrive to output file
//		output_lmf->Close(); output_lmf = 0;
//		return false;
//	}

	if (number_of_DAQ_source_strings_output == -1 && number_of_DAQ_source_strings > 0) {
		number_of_DAQ_source_strings_output = number_of_DAQ_source_strings;
		DAQ_source_strings_output = new std::string*[number_of_DAQ_source_strings];
		memset(DAQ_source_strings_output,0,sizeof(std::string*)*number_of_DAQ_source_strings_output);
		for (__int32 i=0;i<number_of_DAQ_source_strings;++i) {DAQ_source_strings_output[i] = new std::string(); *DAQ_source_strings_output[i] = *DAQ_source_strings[i];}
	} else number_of_DAQ_source_strings_output = 0;

	if (number_of_CCFHistory_strings_output == -1 && number_of_CCFHistory_strings > 0) {
		number_of_CCFHistory_strings_output = number_of_CCFHistory_strings;
		CCFHistory_strings_output = new std::string*[number_of_CCFHistory_strings];
		memset(CCFHistory_strings_output,0,sizeof(std::string*)*number_of_CCFHistory_strings_output);
		for (__int32 i=0;i<number_of_CCFHistory_strings;++i)  {CCFHistory_strings_output[i] = new std::string(); *CCFHistory_strings_output[i] = *CCFHistory_strings[i];}
	} else number_of_CCFHistory_strings_output = 0;

	if (number_of_DAN_source_strings_output == -1 && number_of_DAN_source_strings > 0) {
		number_of_DAN_source_strings_output = number_of_DAN_source_strings;
		DAN_source_strings_output = new std::string*[number_of_DAN_source_strings];
		memset(DAN_source_strings_output,0,sizeof(std::string*)*number_of_DAN_source_strings_output);
		for (__int32 i=0;i<number_of_DAN_source_strings;++i) {DAN_source_strings_output[i] = new std::string(); *DAN_source_strings_output[i] = *DAN_source_strings[i];}
	} else number_of_DAN_source_strings_output = 0;

	if (DAQ_ID_output == DAQ_ID_RAW32BIT) {
		if (number_of_channels_output  == 0) number_of_channels_output  = number_of_channels;
		if (max_number_of_hits_output  == 0) max_number_of_hits_output  = max_number_of_hits;
		if (number_of_channels_output == 0 || max_number_of_hits_output == 0) {errorflag =14; return false;}
		Numberofcoordinates_output = number_of_channels_output*(1+max_number_of_hits_output);
		data_format_in_userheader_output = 10;

		errorflag = 0; // no error
		OutputFileIsOpen = true;
		return true;
	}

	if (DAQ_ID_output == DAQ_ID_SIMPLE) {
		if (number_of_channels_output  == 0) number_of_channels_output  = number_of_channels;
		if (max_number_of_hits_output  == 0) max_number_of_hits_output  = max_number_of_hits;
		if (number_of_channels_output == 0 || max_number_of_hits_output == 0) {errorflag =14; return false;}
		Numberofcoordinates_output = number_of_channels_output*(1+max_number_of_hits_output);
		if (SIMPLE_DAQ_ID_Orignial == 0) SIMPLE_DAQ_ID_Orignial = DAQ_ID;
		*output_lmf << SIMPLE_DAQ_ID_Orignial;
		unsigned __int32 dummy = (unsigned __int32)(uint64_number_of_written_events);
		*output_lmf << dummy;
		*output_lmf << data_format_in_userheader_output;

		errorflag = 0; // no error
		OutputFileIsOpen = true;
		return true;
	}


	
// Preparing to write LMF-header:
// -----------------------------------
	OutputFilePathName = LMF_Filename;

	Headersize_output = 0;

	if (DAQVersion_output == (unsigned) -1) DAQVersion_output = DAQVersion;

	if (DAQVersion_output >= 20080000 && Cobold_Header_version_output == 0) Cobold_Header_version_output = 2008;
	if (Cobold_Header_version_output == 0) Cobold_Header_version_output = Cobold_Header_version;

	if (tdcresolution_output < 0.) tdcresolution_output = tdcresolution;
	if (Starttime_output == 0)	{
		Starttime_output = Starttime;
	}
	if (Stoptime_output == 0)	{
		Stoptime_output = Stoptime;
	}
	if (system_timeout_output == -1) system_timeout_output = system_timeout;
	if (time_reference_output ==  0) time_reference_output = time_reference;
	if (common_mode_output    == -1) common_mode_output    = common_mode;

	if (number_of_channels_output  == 0) number_of_channels_output  = number_of_channels;
	if (max_number_of_hits_output  == 0) max_number_of_hits_output  = max_number_of_hits;
	
	if (data_format_in_userheader_output == -2) data_format_in_userheader_output = data_format_in_userheader;
	if (DAQ_ID_output == 0) DAQ_ID_output = DAQ_ID;
	if (DAQ_ID_output == DAQ_ID_TDC8HPRAW) DAQ_ID_output = DAQ_ID_TDC8HP;

	if (DAQ_ID_output == DAQ_ID_2TDC8) {
		if (number_of_channels2_output == -1) number_of_channels2_output = number_of_channels2;
		if (max_number_of_hits2_output == -1) max_number_of_hits2_output = max_number_of_hits2;
	}

	if (max_number_of_hits2_output < 0 || max_number_of_hits2_output > 100000) max_number_of_hits2_output = max_number_of_hits_output;

	if (timestamp_format_output == (unsigned) -1) timestamp_format_output = timestamp_format;

	if (Numberofcoordinates_output == -2) {
		if (data_format_in_userheader_output == LM_SHORT)  Numberofcoordinates_output = timestamp_format_output * 2;
		if (data_format_in_userheader_output == LM_DOUBLE) Numberofcoordinates_output = timestamp_format_output == 0 ? 0 : 1;
		if (data_format_in_userheader_output == LM_SLONG)  Numberofcoordinates_output = timestamp_format_output;
		if (data_format_in_userheader_output == LM_SHORT || data_format_in_userheader_output == LM_DOUBLE || data_format_in_userheader_output == LM_SLONG) {
			Numberofcoordinates_output += number_of_channels_output  * (max_number_of_hits_output +1);
			Numberofcoordinates_output += number_of_channels2_output * (max_number_of_hits2_output+1);
		}
		if (data_format_in_userheader_output == LM_CAMAC) Numberofcoordinates_output = Numberofcoordinates;

		if (data_format_in_userheader_output == LM_USERDEF) {
			if (DAQVersion_output < 20080000) {this->errorflag = 17; return false;}
			if (DAQ_ID_output == DAQ_ID_TDC8HP) {
				//Numberofcoordinates_output = 2 + timestamp_format_output + number_of_channels_output*(1+max_number_of_hits_output); // old
				Numberofcoordinates_output = number_of_channels_output*(1+max_number_of_hits_output);
				if (LMF_Version >=9) Numberofcoordinates_output++; // for level info
			}
			if (DAQ_ID_output == DAQ_ID_TDC8 || DAQ_ID_output == DAQ_ID_2TDC8) {
				//Numberofcoordinates_output = 2 + timestamp_format_output*2 + (number_of_channels_output + number_of_channels2_output)*(1+max_number_of_hits_output); // old
				Numberofcoordinates_output = (number_of_channels_output + number_of_channels2_output)*(1+max_number_of_hits_output);
			}
			if (DAQ_ID_output == DAQ_ID_HM1) {
				//Numberofcoordinates_output = 2 + timestamp_format_output*2 + (number_of_channels_output + number_of_channels2_output)*(1+max_number_of_hits_output); // old
				Numberofcoordinates_output = (number_of_channels_output + number_of_channels2_output)*(1+max_number_of_hits_output);
			}
			if (DAQ_ID_output == DAQ_ID_FADC8) {
				Numberofcoordinates_output = 3*number_of_channels_output*(1+max_number_of_hits_output);
			}
			if (DAQ_ID_output == DAQ_ID_FADC4) {
				return false;
			}
		}
	}



//  WRITE LMF-HEADER:


	WriteFirstHeader();

	output_lmf->flush();

	Headersize_output = (unsigned __int32)(output_lmf->tell());

	unsigned __int64 seek_value;
	if (Cobold_Header_version_output <= 2002) seek_value = 3*sizeof(unsigned __int32);
	if (Cobold_Header_version_output >= 2008) seek_value = 2*sizeof(unsigned __int32) + sizeof(unsigned __int64);
	output_lmf->seek(seek_value);


	if (Cobold_Header_version_output <= 2002) *output_lmf << Headersize_output;
	if (Cobold_Header_version_output >= 2008) {
		unsigned __int64 temp = Headersize_output;
		*output_lmf << temp;
	}

	output_lmf->flush();
	output_lmf->seek(Headersize_output);

	if (LMF_Version_output == -1) {
		LMF_Version_output = LMF_Version;
		if (LMF_Version_output == -1) LMF_Version_output = 10; // XXX if necessary: modify to latest LMF version number
	}

	output_byte_counter = 0;

//  WRITE USER-HEADER
	if (Cobold_Header_version_output >= 2008 || DAQVersion_output >= 20080000) {
		*output_lmf << LMF_Header_version;
		output_byte_counter += sizeof(__int32);
	}
	if (Cobold_Header_version_output <= 2002) {
		*output_lmf << User_header_size_output;
		output_byte_counter += sizeof(__int32);
	}
	if (Cobold_Header_version_output >= 2008) {
		unsigned __int64 temp = User_header_size_output;
		*output_lmf << temp;
		output_byte_counter += sizeof(unsigned __int64);
	}

	*output_lmf << DAQVersion_output;			output_byte_counter += sizeof(__int32);	// Version is always 2nd value
	*output_lmf << DAQ_ID_output;		output_byte_counter += sizeof(__int32);	// DAQ_ID is always 3ed value

	if (DAQ_ID_output == DAQ_ID_TDC8)	 output_byte_counter += WriteTDC8PCI2Header();
	if (DAQ_ID_output == DAQ_ID_2TDC8)	 output_byte_counter += Write2TDC8PCI2Header();
	if (DAQ_ID_output == DAQ_ID_TDC8HP || DAQ_ID_output == DAQ_ID_TDC8HPRAW)	 {
		if (this->LMF_Version_output <  8) output_byte_counter += WriteTDC8HPHeader_LMFV_1_to_7();
		if (this->LMF_Version_output >= 8 && this->LMF_Version_output <= 9) output_byte_counter += WriteTDC8HPHeader_LMFV_8_to_9();
		if (this->LMF_Version_output >= 10) output_byte_counter += WriteTDC8HPHeader_LMFV_10();
	}

	if (DAQ_ID_output == DAQ_ID_HM1)	 output_byte_counter += WriteHM1Header();
	if (DAQ_ID_output == DAQ_ID_HM1_ABM) output_byte_counter += WriteHM1Header();
	if (DAQ_ID_output == DAQ_ID_CAMAC)   output_byte_counter += WriteCAMACHeader();
	if (DAQ_ID_output == DAQ_ID_TCPIP)   output_byte_counter += WriteTCPIPHeader();
	if (DAQ_ID_output == DAQ_ID_FADC8)   output_byte_counter += WritefADC8_header_LMFversion10();

	User_header_size_output = output_byte_counter;

	errorflag = 0; // no error
	OutputFileIsOpen = true;
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x1, 0x2b29(%rdi)
jne 0xd90a
movl $0xc, 0x12e0(%rbx)
jmp 0xd960
movq %rsi, %r14
movl $0x28, %edi
callq 0x2130
movl $0x0, 0x8(%rax)
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movb %cl, 0x18(%rax)
movq %rcx, (%rax)
movq %rcx, 0x20(%rax)
movq %rcx, 0x10(%rax)
movq %rax, 0x2b20(%rbx)
movb %cl, 0x1a78(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x13592
movq 0x2b20(%rbx), %rax
cmpl $0x0, 0x8(%rax)
je 0xd96e
movl $0xb, 0x12e0(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpl $-0x1, 0x132c(%rbx)
je 0xd986
movl $0x0, 0x132c(%rbx)
jmp 0xda0e
movslq 0x1328(%rbx), %r15
testq %r15, %r15
jle 0xd977
movl %r15d, 0x132c(%rbx)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, 0x1338(%rbx)
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20b0
movl $0x20, %edi
callq 0x2130
leaq 0x10(%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1338(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x1330(%rbx), %rax
movq 0x1338(%rbx), %rcx
movq (%rax,%r12,8), %rsi
movq (%rcx,%r12,8), %rdi
callq 0x20a0
incq %r12
movslq 0x1328(%rbx), %rax
cmpq %rax, %r12
jl 0xd9bc
cmpl $-0x1, 0x12f8(%rbx)
je 0xda26
movl $0x0, 0x12f8(%rbx)
jmp 0xdaae
movslq 0x12f4(%rbx), %r15
testq %r15, %r15
jle 0xda17
movl %r15d, 0x12f8(%rbx)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, 0x1308(%rbx)
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20b0
movl $0x20, %edi
callq 0x2130
leaq 0x10(%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1308(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x1300(%rbx), %rax
movq 0x1308(%rbx), %rcx
movq (%rax,%r12,8), %rsi
movq (%rcx,%r12,8), %rdi
callq 0x20a0
incq %r12
movslq 0x12f4(%rbx), %rax
cmpq %rax, %r12
jl 0xda5c
cmpl $-0x1, 0x1314(%rbx)
je 0xdac6
movl $0x0, 0x1314(%rbx)
jmp 0xdb4e
movslq 0x1310(%rbx), %r15
testq %r15, %r15
jle 0xdab7
movl %r15d, 0x1314(%rbx)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, 0x1320(%rbx)
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20b0
movl $0x20, %edi
callq 0x2130
leaq 0x10(%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1320(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x1318(%rbx), %rax
movq 0x1320(%rbx), %rcx
movq (%rax,%r12,8), %rsi
movq (%rcx,%r12,8), %rdi
callq 0x20a0
incq %r12
movslq 0x1310(%rbx), %rax
cmpq %rax, %r12
jl 0xdafc
movl 0x28c(%rbx), %eax
cmpl $0x65, %eax
je 0xdbbc
cmpl $0x64, %eax
jne 0xdc0b
movl 0x2c4(%rbx), %eax
testl %eax, %eax
jne 0xdb78
movl 0x2b4(%rbx), %eax
movl %eax, 0x2c4(%rbx)
movl 0x2cc(%rbx), %ecx
testl %ecx, %ecx
jne 0xdb8e
movl 0x2bc(%rbx), %ecx
movl %ecx, 0x2cc(%rbx)
testl %eax, %eax
sete %dl
testl %ecx, %ecx
sete %sil
orb %dl, %sil
cmpb $0x1, %sil
je 0xdbfc
incl %ecx
imull %eax, %ecx
movl %ecx, 0x2b48(%rbx)
movl $0xa, 0x294(%rbx)
jmp 0xe1f2
movl 0x2c4(%rbx), %eax
testl %eax, %eax
jne 0xdbd2
movl 0x2b4(%rbx), %eax
movl %eax, 0x2c4(%rbx)
movl 0x2cc(%rbx), %ecx
testl %ecx, %ecx
jne 0xdbe8
movl 0x2bc(%rbx), %ecx
movl %ecx, 0x2cc(%rbx)
testl %eax, %eax
sete %dl
testl %ecx, %ecx
sete %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0xdc73
movl $0xe, 0x12e0(%rbx)
jmp 0xd960
leaq 0x40(%rbx), %r15
movq 0x48(%rbx), %r12
movq %r14, %rdi
callq 0x2090
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x21f0
movl $0x0, 0x2b40(%rbx)
movl 0x284(%rbx), %eax
cmpl $-0x1, %eax
jne 0xdc4f
movl 0x280(%rbx), %eax
movl %eax, 0x284(%rbx)
movl 0x250(%rbx), %ecx
cmpl $0x1326580, %eax        # imm = 0x1326580
jb 0xdcc9
testl %ecx, %ecx
jne 0xdc6a
movl $0x7d8, 0x250(%rbx)     # imm = 0x7D8
leaq 0x250(%rbx), %r15
jmp 0xdce0
incl %ecx
imull %eax, %ecx
movl %ecx, 0x2b48(%rbx)
movl 0x27c(%rbx), %esi
testl %esi, %esi
jne 0xdc94
movl 0x288(%rbx), %esi
movl %esi, 0x27c(%rbx)
movq 0x2b20(%rbx), %rdi
callq 0x13378
movl 0x2b10(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x1365e
jmp 0xe1f2
leaq 0x250(%rbx), %r15
testl %ecx, %ecx
jne 0xdce0
movl 0x24c(%rbx), %ecx
movl %ecx, 0x250(%rbx)
xorpd %xmm0, %xmm0
ucomisd 0x12c0(%rbx), %xmm0
jbe 0xdcfe
movsd 0x12b8(%rbx), %xmm0
movsd %xmm0, 0x12c0(%rbx)
cmpq $0x0, 0x230(%rbx)
jne 0xdd16
movq 0x220(%rbx), %rcx
movq %rcx, 0x230(%rbx)
cmpq $0x0, 0x238(%rbx)
jne 0xdd2e
movq 0x228(%rbx), %rcx
movq %rcx, 0x238(%rbx)
cmpl $-0x1, 0x1290(%rbx)
jne 0xdd43
movl 0x128c(%rbx), %ecx
movl %ecx, 0x1290(%rbx)
cmpl $0x0, 0x244(%rbx)
jne 0xdd58
movl 0x240(%rbx), %ecx
movl %ecx, 0x244(%rbx)
cmpl $-0x1, 0x1298(%rbx)
jne 0xdd6d
movl 0x1294(%rbx), %ecx
movl %ecx, 0x1298(%rbx)
movl 0x2c4(%rbx), %edx
testl %edx, %edx
jne 0xdd83
movl 0x2b4(%rbx), %edx
movl %edx, 0x2c4(%rbx)
movl 0x2cc(%rbx), %ecx
testl %ecx, %ecx
jne 0xdd99
movl 0x2bc(%rbx), %ecx
movl %ecx, 0x2cc(%rbx)
movl 0x294(%rbx), %esi
cmpl $-0x2, %esi
jne 0xddb0
movl 0x290(%rbx), %esi
movl %esi, 0x294(%rbx)
movl 0x28c(%rbx), %edi
testl %edi, %edi
jne 0xddc6
movl 0x288(%rbx), %edi
movl %edi, 0x28c(%rbx)
cmpl $0x5, %edi
je 0xdde1
cmpl $0x10, %edi
jne 0xde12
movl $0x8, 0x28c(%rbx)
movl $0x8, %edi
jmp 0xde12
cmpl $-0x1, 0x2c8(%rbx)
jne 0xddf6
movl 0x2b8(%rbx), %edi
movl %edi, 0x2c8(%rbx)
movl $0x5, %edi
cmpl $-0x1, 0x2d0(%rbx)
jne 0xde12
movl 0x2c0(%rbx), %r8d
movl %r8d, 0x2d0(%rbx)
movl 0x2d0(%rbx), %r8d
cmpl $0x186a1, %r8d          # imm = 0x186A1
jb 0xde2b
movl %ecx, 0x2d0(%rbx)
movl %ecx, %r8d
movl 0x2ac(%rbx), %r9d
cmpl $-0x1, %r9d
jne 0xde46
movl 0x2a8(%rbx), %r9d
movl %r9d, 0x2ac(%rbx)
cmpl $-0x2, 0x2b48(%rbx)
jne 0xdee6
incl %esi
cmpl $0xb, %esi
ja 0xdee6
leaq 0x629f(%rip), %r10      # 0x14104
movslq (%r10,%rsi,4), %rsi
addq %r10, %rsi
jmpq *%rsi
cmpl $0x132657f, %eax        # imm = 0x132657F
ja 0xdeb5
movl $0x11, 0x12e0(%rbx)
jmp 0xd960
addl %r9d, %r9d
jmp 0xde94
xorl %eax, %eax
testl %r9d, %r9d
setne %al
movl %eax, %r9d
incl %ecx
imull %edx, %ecx
addl %r9d, %ecx
incl %r8d
imull 0x2c8(%rbx), %r8d
addl %ecx, %r8d
jmp 0xdedf
movl 0x270(%rbx), %r8d
jmp 0xdedf
leal -0x1(%rdi), %eax
cmpl $0x7, %eax
ja 0xe20a
leaq 0x626c(%rip), %rsi      # 0x14134
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
addl 0x2c8(%rbx), %edx
incl %ecx
imull %edx, %ecx
movl %ecx, %r8d
movl %r8d, 0x2b48(%rbx)
movq %rbx, %rdi
callq 0x7fae
movq 0x2b20(%rbx), %rax
movq (%rax), %rdi
callq 0x2160
movq 0x2b20(%rbx), %r12
movl 0x20(%r12), %eax
movl %eax, 0x2b40(%rbx)
xorl %eax, %eax
cmpl $0x7d8, 0x250(%rbx)     # imm = 0x7D8
setge %al
leaq 0xc(,%rax,4), %r14
movq (%r12), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x20c0
testl %eax, %eax
je 0xdf43
movl $0x1, 0x8(%r12)
jmp 0xdf48
movq %r14, 0x20(%r12)
movl (%r15), %eax
cmpl $0x7d2, %eax            # imm = 0x7D2
jg 0xdf6a
movq 0x2b20(%rbx), %rdi
movl 0x2b40(%rbx), %esi
callq 0x13378
movl 0x250(%rbx), %eax
cmpl $0x7d8, %eax            # imm = 0x7D8
jl 0xdf83
movl 0x2b40(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movq 0x2b20(%rbx), %rax
movq (%rax), %rdi
callq 0x2160
movq 0x2b20(%rbx), %r15
movl 0x2b40(%rbx), %r14d
movq (%r15), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x20c0
testl %eax, %eax
je 0xdfbb
movl $0x1, 0x8(%r15)
jmp 0xdfbf
movq %r14, 0x20(%r15)
cmpl $-0x1, 0x12a8(%rbx)
jne 0xdfdf
movl 0x12a4(%rbx), %eax
cmpl $-0x1, %eax
movl $0xa, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x12a8(%rbx)
movl $0x0, 0x2b44(%rbx)
movl 0x250(%rbx), %eax
cmpl $0x7d7, %eax            # imm = 0x7D7
jg 0xe002
cmpl $0x1326580, 0x284(%rbx) # imm = 0x1326580
jb 0xe021
movq 0x2b20(%rbx), %rdi
movl 0x12b0(%rbx), %esi
callq 0x13378
addl $0x4, 0x2b44(%rbx)
movl 0x250(%rbx), %eax
cmpl $0x7d2, %eax            # imm = 0x7D2
jg 0xe047
movq 0x2b20(%rbx), %rdi
movl 0x2a0(%rbx), %esi
callq 0x13378
addl $0x4, 0x2b44(%rbx)
movl 0x250(%rbx), %eax
cmpl $0x7d8, %eax            # imm = 0x7D8
jl 0xe067
movl 0x2a0(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13448
addl $0x8, 0x2b44(%rbx)
movq 0x2b20(%rbx), %rdi
movl 0x284(%rbx), %esi
callq 0x13378
addl $0x4, 0x2b44(%rbx)
movq 0x2b20(%rbx), %rdi
movl 0x28c(%rbx), %esi
callq 0x13378
movl 0x2b44(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x2, %ecx
jne 0xe0c6
movq %rbx, %rdi
callq 0x7c88
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x5, %ecx
jne 0xe0e5
movq %rbx, %rdi
callq 0xb47c
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x10, %ecx
je 0xe0ef
cmpl $0x8, %ecx
jne 0xe157
movl 0x12a8(%rbx), %ecx
cmpl $0x7, %ecx
jg 0xe114
movq %rbx, %rdi
callq 0xb7e6
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x12a8(%rbx), %ecx
movl %ecx, %edx
andl $-0x2, %edx
cmpl $0x8, %edx
jne 0xe138
movq %rbx, %rdi
callq 0xc05a
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x12a8(%rbx), %ecx
cmpl $0xa, %ecx
jl 0xe151
movq %rbx, %rdi
callq 0xca16
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x1, %ecx
jne 0xe176
movq %rbx, %rdi
callq 0xd29c
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x6, %ecx
jne 0xe195
movq %rbx, %rdi
callq 0xd29c
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x3, %ecx
jne 0xe1b4
movq %rbx, %rdi
callq 0xd7fa
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x9, %ecx
jne 0xe1d3
movq %rbx, %rdi
callq 0xb3a6
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl 0x28c(%rbx), %ecx
cmpl $0x11, %ecx
jne 0xe1ec
movq %rbx, %rdi
callq 0x977e
addl 0x2b44(%rbx), %eax
movl %eax, 0x2b44(%rbx)
movl %eax, 0x2a0(%rbx)
movl $0x0, 0x12e0(%rbx)
movb $0x1, 0x2b29(%rbx)
movb $0x1, %al
jmp 0xd962
cmpl $0x11, %edi
je 0xe23c
cmpl $0x12, %edi
je 0xd960
jmp 0xdee6
incl %ecx
imull %edx, %ecx
movl %ecx, 0x2b48(%rbx)
cmpl $0x9, 0x12a4(%rbx)
jl 0xdee6
incl %ecx
jmp 0xdedc
incl %ecx
imull %ecx, %edx
leal (%rdx,%rdx,2), %r8d
jmp 0xdedf