// File: /workspace/github_cpp_makefile_star2_O3/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::Initialize()
void LMF_IO::Initialize()
/////////////////////////////////////////////////////////////////
{
	uint64_LMF_EventCounter = -1;
	not_Cobold_LMF = false;
	errorflag = 0;
	number_of_channels2 = 0;
	InputFileIsOpen = false;
	OutputFileIsOpen = false;
	SIMPLE_DAQ_ID_Orignial = 0;
	input_lmf = 0;
	output_lmf = 0;
	DAQ_ID = 0;
	frequency = 1.;
	common_mode = 0;
	timerange = 0;
	must_read_first = true;
	uint64_number_of_read_events = 0;
	uint64_number_of_written_events = 0;
	number_of_channels_output = 0;
	number_of_channels2_output = -1;
	number_of_channels = 0;
	max_number_of_hits = 0;
	max_number_of_hits_output = 0;
	max_number_of_hits2_output = -1;
	data_format_in_userheader_output = -2;
	output_byte_counter = 0;
	timestamp_format = 0;
	timestamp_format_output = -1;
	DOUBLE_timestamp = 0.;
	ui64_timestamp = 0;
	skip_header = false;
	time_reference_output = 0;
	system_timeout_output = -1;
	Numberofcoordinates = -2;
	Numberofcoordinates_output = -2;
	DAQ_ID_output = 0;
	User_header_size_output = 0;
	CAMAC_Data = 0;
	tdcresolution_output = -1.;
	tdcresolution = 0.;
	TDC8HP.SyncValidationChannel = 0;
	TDC8HP.exotic_file_type = 0;
	User_header_size = 0;
	TDC8HP.UserHeaderVersion = 7; // 4 = Cobold 2008 first release in 2008
								  // 5 = Cobold 2008 R2 in August 2009
								  // 6 = Cobold 2009?
								  // 7 = Cobold 2011 R1 + R2

	HM1.use_normal_method = true;
	TDC8PCI2.use_normal_method_2nd_card = true;
	TDC8PCI2.use_normal_method = true;
	TDC8HP.VHR_25ps = true;
	common_mode_output = -1;
	DAQ_info = "";
	DAQ_info_Length = 0;
	Versionstring = "";
	FilePathName = "";
	OutputFilePathName = "";
	Comment = "";
	Comment_output = "";
	DAQ_info = "";
	Camac_CIF = "";
	TDC8HP.variable_event_length = 0;
	DAQVersion_output = -1;
	LMF_Version = -1;
	LMF_Version_output = -1;
	TDC8HP.csConfigFile = "";
	TDC8HP.csINLFile = "";
	TDC8HP.csDNLFile = "";
	TDC8HP.GroupingEnable_p66		 = false;
	TDC8HP.GroupingEnable_p66_output = false;

	DAQ_SOURCE_CODE_bitmasked  = 0;
	DAN_SOURCE_CODE_bitmasked  = 0;
	CCF_HISTORY_CODE_bitmasked = 0;
	number_of_CCFHistory_strings = 0;
	number_of_DAN_source_strings = 0;
	number_of_DAQ_source_strings = 0;
	number_of_CCFHistory_strings_output = 0;
	number_of_DAN_source_strings_output = 0;
	number_of_DAQ_source_strings_output = 0;
	CCFHistory_strings = 0;
	DAN_source_strings = 0;
	DAQ_source_strings = 0;
	CCFHistory_strings_output = 0;
	DAN_source_strings_output = 0;
	DAQ_source_strings_output = 0;

	TDC8HP.number_of_bools   = 0;
	TDC8HP.number_of_doubles = 0;
	TDC8HP.number_of_doubles = 0;

	TDC8PCI2.variable_event_length = 0;

	i32TDC =	new __int32[num_channels*num_ions];
	us16TDC =	new unsigned __int16[num_channels*num_ions];
	dTDC =		new double [num_channels*num_ions];
	number_of_hits = new unsigned __int32[num_channels];

	TDC8HP.DMAEnable = true;
	TDC8HP.SSEEnable = false;
	TDC8HP.MMXEnable = true;
	TDC8HP.GroupTimeOut = 0.1;

	TDC8HP.channel_offset_for_rising_transitions = 0;

//	TDC8HP.bdummy = false;
//	TDC8HP.idummy = 0;
//	TDC8HP.ddummy = 0.;

	TDC8HP.i32NumberOfDAQLoops  = 1;
	TDC8HP.TDC8HP_DriverVersion = 0x00000000;
	TDC8HP.iTriggerChannelMask  = 0;
	TDC8HP.iTime_zero_channel   = 0;

	TDC8HP.Number_of_TDCs = 0;

	time_t osBinaryTime;
	time( &osBinaryTime );
	time_t time_dummy(osBinaryTime);
	Starttime = time_dummy;
	Stoptime = time_dummy;
	Starttime_output = 0;
	Stoptime_output  = 0;
	CTime_version    = 0;
	CTime_version_output = 0;
	number_of_DAQ_source_strings_output = -1;
	number_of_CCFHistory_strings_output = -1;
	number_of_DAN_source_strings_output = -1;

	number_of_bytes_in_PostEventData = 0;

	LMF_Header_version = 476759;
	ui64LevelInfo = 0;

	Cobold_Header_version = 2002;
	Cobold_Header_version_output = 0;

	TDC8HP.OffsetTimeZeroChannel_s = 0.;
	TDC8HP.BinsizeType = 0;

	for (__int32 i=0;i<3;++i) {
		TDC8HP.TDC_info[i] = 0;
		TDC8HP.TDC_info[i] = new TDC8HP_info_struct;
		TDC8HP.TDC_info[i]->INLCorrection = 0;
		TDC8HP.TDC_info[i]->INLCorrection	= new __int32[8*1024];
		TDC8HP.TDC_info[i]->DNLData = 0;
		TDC8HP.TDC_info[i]->DNLData			= new unsigned __int16[8*1024];
	}



	fADC8.driver_version = 0;
	fADC8.bReadCustomData = false;
	fADC8.i32NumberOfDAQLoops = 0;
	fADC8.number_of_bools = 0;
	fADC8.number_of_int32s = 0;
	fADC8.number_of_uint32s = 0;
	fADC8.number_of_doubles = 0;
	fADC8.GroupEndMarker = 0;
	fADC8.i32NumberOfADCmodules = 0;
	fADC8.iEnableGroupMode = 1;
	fADC8.iTriggerChannel = 0;
	fADC8.iPreSamplings_in_4800ps_units = 0;
	fADC8.iPostSamplings_in_9600ps_units = 0;
	fADC8.iEnableTDCinputs = 0;
	fADC8.veto_gate_length = 0;
	fADC8.veto_delay_length = 0;
	fADC8.veto_mask = 0;
	fADC8.dGroupRangeStart = 0.;
	fADC8.at_least_1_signal_was_written = false;
	fADC8.dGroupRangeEnd = 0.;
	for (__int32 mod = 0;mod<8;mod++) {
		fADC8.firmware_version[mod]	= 0;
		fADC8.serial_number[mod]		= 0;
		for (__int32 ch = 0;ch<8;ch++) {
			fADC8.GND_level[mod][ch] = 0;
			fADC8.iThreshold_GT[mod][ch] = 0;
			fADC8.iThreshold_LT[mod][ch] = 0;
		}
		fADC8.iChannelMode [mod][0] = fADC8.iChannelMode [mod][1] = 0;
		fADC8.iSynchronMode[mod][0] = fADC8.iSynchronMode[mod][1] = 0;
		fADC8.dSyncTimeOffset[mod][0] = fADC8.dSyncTimeOffset[mod][1] = 0.;
	}

///////////////////////////////////


	fADC4.packet_count = -1;
	fADC4.number_of_bools = 0;
	fADC4.number_of_int32s = 0;
	fADC4.number_of_uint32s = 0;
	fADC4.number_of_doubles = 0;
	fADC4.GroupEndMarker = 12345678;
	fADC4.driver_version = 0;
	fADC4.i32NumberOfDAQLoops = 1;
	fADC4.bReadCustomData = true;
	fADC4.i32NumberOfADCmodules = 0;
	fADC4.iTriggerChannel = 0;
	fADC4.dGroupRangeStart = 0.;
	fADC4.dGroupRangeEnd = 0.;
	fADC4.csConfigFile = fADC4.csINLFile = fADC4.csDNLFile = "";
	for (__int32 i=0;i<20;i++) fADC4.bits_per_mVolt[i] = 0.;
	for (__int32 i=0;i<80;i++) fADC4.GND_level[i] = 0.;

	ui32buffer_size = 0;
	ui32buffer = 0;

	error_text[0] = (char*)"no error";
	error_text[1] = (char*)"error reading timestamp";
	error_text[2] = (char*)"error reading data";
	error_text[3] = (char*)"input file is already open";
	error_text[4] = (char*)"could not open input file";
	error_text[5] = (char*)"could not connect CAchrive to input file";
	error_text[6] = (char*)"error reading header";
	error_text[7] = (char*)"LMF not data of TDC8PCI2 or 2TDC8PCI2 or TDC8HP or CAMAC";
	error_text[8] = (char*)"file format not supported (only unsigned __int16 16bit and signed integer 32)";
	error_text[9] = (char*)"input file not open";
	error_text[10] = (char*)"output file not open";
	error_text[11] = (char*)"could not open output file";
	error_text[12] = (char*)"output file is already open";
	error_text[13] = (char*)"could not connect CAchrive to output file";
	error_text[14] = (char*)"some parameters are not initialized";
	error_text[15] = (char*)"CAMAC data tried to read with wrong function";
	error_text[16] = (char*)"seek does not work with non-fixed event lengths";
	error_text[17] = (char*)"writing file with non-fixed event length dan DAQVersion < 2008 no possible";
	error_text[18] = (char*)"end of input file";
	error_text[19] = (char*)"more channels in file than specified at new LMF_IO()";
	error_text[20] = (char*)"more hits per channel in file than specified at new LMF_IO()";
	error_text[21] = (char*)"more bytes after event than are reserved in LMF_IO source code";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq $-0x1, %r13
movq %r13, 0x258(%rdi)
xorl %r12d, %r12d
movb %r12b, 0x2b3c(%rdi)
movl %r12d, 0x12e0(%rdi)
movl %r12d, 0x27c(%rdi)
movl %r12d, 0x288(%rdi)
xorps %xmm1, %xmm1
movups %xmm1, 0x2b18(%rdi)
movw $0x0, 0x2b28(%rdi)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x12c8(%rdi)
movl %r12d, 0x1294(%rdi)
movups %xmm1, 0x2b0(%rdi)
movb $0x1, %al
movb %al, 0x2b4c(%rdi)
movq %r12, 0x260(%rdi)
movq %r12, 0x2b10(%rdi)
movaps 0x116f0(%rip), %xmm0    # 0x14010
movups %xmm0, 0x2c4(%rdi)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %eax, 0x294(%rdi)
movl %r12d, 0x2b44(%rdi)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x2a8(%rdi)
movb %r12b, 0x12e4(%rdi)
movl %r12d, 0x244(%rdi)
movups %xmm1, 0x12d0(%rdi)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, 0x1290(%rdi)
movl %eax, 0x270(%rdi)
movl %eax, 0x2b48(%rdi)
movl %r12d, 0x28c(%rdi)
xorps %xmm0, %xmm0
movhps 0x11719(%rip), %xmm0    # xmm0 = xmm0[0,1],mem[0,1]
movq %r12, 0x2b78(%rdi)
movups %xmm0, 0x12b8(%rdi)
movl %r12d, 0x14e4(%rdi)
movl %r12d, 0x13f8(%rdi)
movq %r12, 0x29c(%rdi)
movl $0x7, 0x14dc(%rdi)
movb $0x1, %al
movb %al, 0x13bc(%rdi)
movw $0x101, 0x1574(%rdi)    # imm = 0x101
movb %al, 0x14e0(%rdi)
movl %ebp, 0x1298(%rdi)
leaq 0xa0(%rdi), %r15
movq 0xa8(%rdi), %rdx
leaq 0x11c30(%rip), %r14     # 0x14616
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
movl %r12d, 0x129c(%rbx)
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x20(%rbx), %rdi
movq 0x28(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x40(%rbx), %rdi
movq 0x48(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x60(%rbx), %rdi
movq 0x68(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x80(%rbx), %rdi
movq 0x88(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
movq 0xa8(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0xc0(%rbx), %rdi
movq 0xc8(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
movl %r12d, 0x14e8(%rbx)
movl %ebp, 0x284(%rbx)
movq %r13, 0x12a4(%rbx)
leaq 0x1470(%rbx), %rdi
movq 0x1478(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x1490(%rbx), %rdi
movq 0x1498(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
leaq 0x14b0(%rbx), %rdi
movq 0x14b8(%rbx), %rdx
xorl %esi, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x21f0
movslq 0x2b70(%rbx), %r13
movslq 0x2b74(%rbx), %rax
imulq %r13, %rax
leaq (,%rax,8), %r14
testl %eax, %eax
movq $-0x1, %rcx
cmovsq %rcx, %r14
leaq (%rax,%rax), %r15
testl %eax, %eax
cmovsq %rcx, %r15
movq $-0x1, %rbp
movq %rax, %rdi
shlq $0x2, %rdi
testl %eax, %eax
movq %r12, 0x141c(%rbx)
movl %r12d, 0x1528(%rbx)
movl %r12d, 0x1530(%rbx)
movl %r12d, 0x159c(%rbx)
movl %r12d, 0x12f8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x12e8(%rbx)
movups %xmm0, 0x1330(%rbx)
movups %xmm0, 0x1320(%rbx)
movups %xmm0, 0x1310(%rbx)
movups %xmm0, 0x1300(%rbx)
cmovsq %rbp, %rdi
callq 0x2030
movq %rax, 0x2b58(%rbx)
movq %r15, %rdi
callq 0x2030
movq %rax, 0x2b60(%rbx)
movq %r14, %rdi
callq 0x2030
leaq (,%r13,4), %rdi
testq %r13, %r13
movq %rax, 0x2b68(%rbx)
cmovsq %rbp, %rdi
callq 0x2030
movq %rax, 0x2b50(%rbx)
movb $0x1, %al
movb %al, 0x14ee(%rbx)
movw $0x100, 0x14ec(%rbx)    # imm = 0x100
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0x14f0(%rbx)
movl %r12d, 0x1550(%rbx)
movss 0x114fa(%rip), %xmm0    # 0x14100
movups %xmm0, 0x1518(%rbx)
movl %r12d, 0x14f8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x2100
movq (%r14), %rax
movq %rax, 0x220(%rbx)
movq %rax, 0x228(%rbx)
movq %r12, 0x274(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x230(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x132c(%rbx)
movl %eax, 0x12f8(%rbx)
movl %eax, 0x1314(%rbx)
movl %r12d, 0x1280(%rbx)
movl $0x74657, 0x12b0(%rbx)  # imm = 0x74657
movq %r12, 0x2d8(%rbx)
movq $0x7d2, 0x24c(%rbx) # imm = 0x7D2
movq %r12, 0x1460(%rbx)
movl %r12d, 0x1468(%rbx)
xorl %r15d, %r15d
movq %r12, 0x1500(%rbx,%r15,8)
movl $0x50, %edi
callq 0x2130
movq %rax, %r14
movq %rax, 0x1500(%rbx,%r15,8)
movq %r12, 0x38(%rax)
movl $0x8000, %edi           # imm = 0x8000
callq 0x2030
movq %rax, 0x38(%r14)
movq %r12, 0x40(%r14)
movl $0x4000, %edi           # imm = 0x4000
callq 0x2030
movq %rax, 0x40(%r14)
incq %r15
cmpq $0x3, %r15
jne 0x2c8c
xorl %eax, %eax
movb %al, 0x1854(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x15a0(%rbx)
movups %xmm0, 0x15b0(%rbx)
movl $0x1, 0x15c0(%rbx)
movq $0x0, 0x1898(%rbx)
movl $0x0, 0x18a0(%rbx)
movb %al, 0x1a78(%rbx)
leaq 0x18a4(%rbx), %rcx
leaq 0x1714(%rbx), %rdx
leaq 0x19f8(%rbx), %rsi
movups %xmm0, 0x15c4(%rbx)
movups %xmm0, 0x19e8(%rbx)
xorl %edi, %edi
movl %eax, 0x1858(%rbx,%rdi,4)
movl %eax, 0x1878(%rbx,%rdi,4)
xorl %r8d, %r8d
movups %xmm0, (%rcx,%r8,4)
movups %xmm0, -0x100(%rdx,%r8,4)
movups %xmm0, (%rdx,%r8,4)
addq $0x4, %r8
cmpq $0x8, %r8
jne 0x2d4a
movq %rax, 0x15d4(%rbx,%rdi,8)
movq %rax, 0x1814(%rbx,%rdi,8)
movq %rdi, %r8
shlq $0x4, %r8
incq %rdi
movups %xmm0, (%rsi,%r8)
addq $0x28, %rcx
addq $0x20, %rdx
cmpq $0x8, %rdi
jne 0x2d39
xorps %xmm0, %xmm0
movups %xmm0, 0x1a94(%rbx)
movabsq $-0xff439eb2, %rax      # imm = 0xFFFFFFFF00BC614E
movq %rax, 0x1ab8(%rbx)
xorl %r15d, %r15d
movq %r15, 0x1a80(%rbx)
movl $0x1, 0x1a88(%rbx)
movb $0x1, 0x1a8c(%rbx)
movl %r15d, 0x1a90(%rbx)
leaq 0x2af0(%rbx), %rdi
movups %xmm0, 0x1aa8(%rbx)
movq 0x2af8(%rbx), %rdx
leaq 0x11829(%rip), %rcx     # 0x14616
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x21f0
leaq 0x2ad0(%rbx), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x20a0
leaq 0x2ab0(%rbx), %rdi
movq %r14, %rsi
callq 0x20a0
leaq 0x2a10(%rbx), %rdi
movl $0xa0, %edx
xorl %esi, %esi
callq 0x20b0
leaq 0x24c0(%rbx), %rdi
movl $0x280, %edx            # imm = 0x280
xorl %esi, %esi
callq 0x20b0
movl %r15d, 0x2b38(%rbx)
movq %r15, 0x2b30(%rbx)
leaq 0x11301(%rip), %rax     # 0x14154
movq %rax, 0xe0(%rbx)
leaq 0x112fc(%rip), %rax     # 0x1415d
movq %rax, 0xe8(%rbx)
leaq 0x11306(%rip), %rax     # 0x14175
movq %rax, 0xf0(%rbx)
leaq 0x1130b(%rip), %rax     # 0x14188
movq %rax, 0xf8(%rbx)
leaq 0x11318(%rip), %rax     # 0x141a3
movq %rax, 0x100(%rbx)
leaq 0x11324(%rip), %rax     # 0x141bd
movq %rax, 0x108(%rbx)
leaq 0x1133f(%rip), %rax     # 0x141e6
movq %rax, 0x110(%rbx)
leaq 0x11346(%rip), %rax     # 0x141fb
movq %rax, 0x118(%rbx)
leaq 0x11371(%rip), %rax     # 0x14234
movq %rax, 0x120(%rbx)
leaq 0x113b1(%rip), %rax     # 0x14282
movq %rax, 0x128(%rbx)
leaq 0x113b7(%rip), %rax     # 0x14296
movq %rax, 0x130(%rbx)
leaq 0x113be(%rip), %rax     # 0x142ab
movq %rax, 0x138(%rbx)
leaq 0x113cb(%rip), %rax     # 0x142c6
movq %rax, 0x140(%rbx)
leaq 0x113d9(%rip), %rax     # 0x142e2
movq %rax, 0x148(%rbx)
leaq 0x113f5(%rip), %rax     # 0x1430c
movq %rax, 0x150(%rbx)
leaq 0x1140b(%rip), %rax     # 0x14330
movq %rax, 0x158(%rbx)
leaq 0x1142a(%rip), %rax     # 0x1435d
movq %rax, 0x160(%rbx)
leaq 0x1144c(%rip), %rax     # 0x1438d
movq %rax, 0x168(%rbx)
leaq 0x11489(%rip), %rax     # 0x143d8
movq %rax, 0x170(%rbx)
leaq 0x1148d(%rip), %rax     # 0x143ea
movq %rax, 0x178(%rbx)
leaq 0x114b4(%rip), %rax     # 0x1441f
movq %rax, 0x180(%rbx)
leaq 0x114e3(%rip), %rax     # 0x1445c
movq %rax, 0x188(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop