// File: /workspace/github_cpp_makefile_star2_O2/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
orq $-0x1, 0x258(%rdi)
xorl %r12d, %r12d
movb %r12b, 0x2b3c(%rdi)
andl $0x0, 0x12e0(%rdi)
andl $0x0, 0x27c(%rdi)
andl $0x0, 0x288(%rdi)
xorps %xmm1, %xmm1
movups %xmm1, 0x2b18(%rdi)
andw $0x0, 0x2b28(%rdi)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x12c8(%rdi)
andl $0x0, 0x1294(%rdi)
movups %xmm1, 0x2b0(%rdi)
movb $0x1, %al
movb %al, 0x2b4c(%rdi)
andq $0x0, 0x260(%rdi)
andq $0x0, 0x2b10(%rdi)
movaps 0xf84f(%rip), %xmm0     # 0x12010
movups %xmm0, 0x2c4(%rdi)
pushq $-0x2
popq %rax
movl %eax, 0x294(%rdi)
andl $0x0, 0x2b44(%rdi)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x2a8(%rdi)
movb %r12b, 0x12e4(%rdi)
andl $0x0, 0x244(%rdi)
movups %xmm1, 0x12d0(%rdi)
orl $-0x1, 0x1290(%rdi)
movl %eax, 0x270(%rdi)
movl %eax, 0x2b48(%rdi)
andl $0x0, 0x28c(%rdi)
andq $0x0, 0x2b78(%rdi)
xorps %xmm0, %xmm0
movhps 0xf846(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
movups %xmm0, 0x12b8(%rdi)
andl $0x0, 0x14e4(%rdi)
andl $0x0, 0x13f8(%rdi)
andq $0x0, 0x29c(%rdi)
movl $0x7, 0x14dc(%rdi)
movb $0x1, %al
movb %al, 0x13bc(%rdi)
movw $0x101, 0x1574(%rdi)    # imm = 0x101
movb %al, 0x14e0(%rdi)
orl $-0x1, 0x1298(%rdi)
leaq 0xa0(%rdi), %r15
leaq 0xfd69(%rip), %r14      # 0x125e6
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
andl $0x0, 0x129c(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x60(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x80(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
leaq 0xc0(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
andl $0x0, 0x14e8(%rbx)
orl $-0x1, 0x284(%rbx)
orq $-0x1, 0x12a4(%rbx)
leaq 0x1470(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x1490(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
leaq 0x14b0(%rbx), %rdi
movq %r14, %rsi
callq 0x2230
movslq 0x2b70(%rbx), %r13
movslq 0x2b74(%rbx), %rax
imulq %r13, %rax
leaq (,%rax,8), %r14
testl %eax, %eax
pushq $-0x1
popq %rbp
cmovsq %rbp, %r14
leaq (%rax,%rax), %r15
testl %eax, %eax
cmovsq %rbp, %r15
movq %rax, %rdi
shlq $0x2, %rdi
testl %eax, %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x12e8(%rbx)
movups %xmm0, 0x1300(%rbx)
movups %xmm0, 0x1310(%rbx)
movups %xmm0, 0x1320(%rbx)
cmovsq %rbp, %rdi
movups %xmm0, 0x1330(%rbx)
andq $0x0, 0x141c(%rbx)
andl $0x0, 0x1528(%rbx)
andl $0x0, 0x1530(%rbx)
andl $0x0, 0x159c(%rbx)
andl $0x0, 0x12f8(%rbx)
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)
andl $0x0, 0x1550(%rbx)
movss 0xf6ac(%rip), %xmm0     # 0x120d0
movups %xmm0, 0x1518(%rbx)
andl $0x0, 0x14f8(%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x2100
movq (%r14), %rax
movq %rax, 0x220(%rbx)
movq %rax, 0x228(%rbx)
andq $0x0, 0x274(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x230(%rbx)
orl $-0x1, 0x132c(%rbx)
orl $-0x1, 0x12f8(%rbx)
orl $-0x1, 0x1314(%rbx)
andl $0x0, 0x1280(%rbx)
movl $0x74657, 0x12b0(%rbx)  # imm = 0x74657
andq $0x0, 0x2d8(%rbx)
movq $0x7d2, 0x24c(%rbx) # imm = 0x7D2
andq $0x0, 0x1460(%rbx)
andl $0x0, 0x1468(%rbx)
pushq $0x50
popq %r14
cmpq $0x3, %r12
je 0x2af9
andq $0x0, 0x1500(%rbx,%r12,8)
movq %r14, %rdi
callq 0x2130
movq %rax, %r15
movq %rax, 0x1500(%rbx,%r12,8)
andq $0x0, 0x38(%rax)
movl $0x8000, %edi           # imm = 0x8000
callq 0x2030
movq %rax, 0x38(%r15)
andq $0x0, 0x40(%r15)
movl $0x4000, %edi           # imm = 0x4000
callq 0x2030
movq %rax, 0x40(%r15)
incq %r12
jmp 0x2aac
xorl %eax, %eax
movb %al, 0x1854(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x15a0(%rbx)
movups %xmm0, 0x15b0(%rbx)
movl $0x1, 0x15c0(%rbx)
andq $0x0, 0x1898(%rbx)
andl $0x0, 0x18a0(%rbx)
leaq 0x19e8(%rbx), %rdi
movb %al, 0x1a78(%rbx)
leaq 0x18a4(%rbx), %rcx
leaq 0x1714(%rbx), %rdx
leaq 0x19f8(%rbx), %rsi
movups %xmm0, 0x15c4(%rbx)
movups %xmm0, (%rdi)
cmpq $0x8, %rax
je 0x2bb3
andl $0x0, 0x1858(%rbx,%rax,4)
andl $0x0, 0x1878(%rbx,%rax,4)
xorl %edi, %edi
cmpq $0x8, %rdi
je 0x2b8a
andl $0x0, (%rcx,%rdi,4)
andl $0x0, -0x100(%rdx,%rdi,4)
andl $0x0, (%rdx,%rdi,4)
incq %rdi
jmp 0x2b6f
andq $0x0, 0x15d4(%rbx,%rax,8)
andq $0x0, 0x1814(%rbx,%rax,8)
movq %rax, %rdi
shlq $0x4, %rdi
addq %rsi, %rdi
incq %rax
addq $0x28, %rcx
addq $0x20, %rdx
jmp 0x2b54
xorps %xmm0, %xmm0
movups %xmm0, 0x1a94(%rbx)
movabsq $-0xff439eb2, %rax      # imm = 0xFFFFFFFF00BC614E
movq %rax, 0x1ab8(%rbx)
andq $0x0, 0x1a80(%rbx)
movl $0x1, 0x1a88(%rbx)
movb $0x1, 0x1a8c(%rbx)
andl $0x0, 0x1a90(%rbx)
leaq 0x2af0(%rbx), %rdi
movups %xmm0, 0x1aa8(%rbx)
leaq 0xf9e3(%rip), %rsi      # 0x125e6
callq 0x2230
leaq 0x2ad0(%rbx), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x20a0
leaq 0x2ab0(%rbx), %rdi
movq %r14, %rsi
callq 0x20a0
xorl %eax, %eax
cmpq $0x14, %rax
je 0x2c3f
andq $0x0, 0x2a10(%rbx,%rax,8)
incq %rax
jmp 0x2c2b
xorl %eax, %eax
cmpq $0x50, %rax
je 0x2c55
andq $0x0, 0x24c0(%rbx,%rax,8)
incq %rax
jmp 0x2c41
andl $0x0, 0x2b38(%rbx)
andq $0x0, 0x2b30(%rbx)
leaq 0xf4b9(%rip), %rax      # 0x12124
movq %rax, 0xe0(%rbx)
leaq 0xf4b4(%rip), %rax      # 0x1212d
movq %rax, 0xe8(%rbx)
leaq 0xf4be(%rip), %rax      # 0x12145
movq %rax, 0xf0(%rbx)
leaq 0xf4c3(%rip), %rax      # 0x12158
movq %rax, 0xf8(%rbx)
leaq 0xf4d0(%rip), %rax      # 0x12173
movq %rax, 0x100(%rbx)
leaq 0xf4dc(%rip), %rax      # 0x1218d
movq %rax, 0x108(%rbx)
leaq 0xf4f7(%rip), %rax      # 0x121b6
movq %rax, 0x110(%rbx)
leaq 0xf4fe(%rip), %rax      # 0x121cb
movq %rax, 0x118(%rbx)
leaq 0xf529(%rip), %rax      # 0x12204
movq %rax, 0x120(%rbx)
leaq 0xf569(%rip), %rax      # 0x12252
movq %rax, 0x128(%rbx)
leaq 0xf56f(%rip), %rax      # 0x12266
movq %rax, 0x130(%rbx)
leaq 0xf576(%rip), %rax      # 0x1227b
movq %rax, 0x138(%rbx)
leaq 0xf583(%rip), %rax      # 0x12296
movq %rax, 0x140(%rbx)
leaq 0xf591(%rip), %rax      # 0x122b2
movq %rax, 0x148(%rbx)
leaq 0xf5ad(%rip), %rax      # 0x122dc
movq %rax, 0x150(%rbx)
leaq 0xf5c3(%rip), %rax      # 0x12300
movq %rax, 0x158(%rbx)
leaq 0xf5e2(%rip), %rax      # 0x1232d
movq %rax, 0x160(%rbx)
leaq 0xf604(%rip), %rax      # 0x1235d
movq %rax, 0x168(%rbx)
leaq 0xf641(%rip), %rax      # 0x123a8
movq %rax, 0x170(%rbx)
leaq 0xf645(%rip), %rax      # 0x123ba
movq %rax, 0x178(%rbx)
leaq 0xf66c(%rip), %rax      # 0x123ef
movq %rax, 0x180(%rbx)
leaq 0xf69b(%rip), %rax      # 0x1242c
movq %rax, 0x188(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop