// File: /workspace/github_cpp_makefile_star2_O3/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::WritefADC8_header_LMFversion10()
__int32	LMF_IO::WritefADC8_header_LMFversion10()
{
	unsigned __int32 unsigned_int_Dummy;

	__int32 byte_counter = 0;

	*output_lmf << frequency;	byte_counter += sizeof(double);			// frequency is always 4th value
	*output_lmf << IOaddress;	byte_counter += sizeof(__int32);		// IO address (parameter 1) always 5th value
	*output_lmf << timestamp_format_output;	byte_counter += sizeof(__int32);		// TimeInfo (parameter 2) always 6th value  (0,1,2)*32Bit

	unsigned __int32 dummy = (unsigned __int32)(DAQ_info.length());
	*output_lmf << dummy;
	byte_counter += sizeof(__int32);		// Length of DAQInfo always 7th value

	output_lmf->write(DAQ_info.c_str(), __int32(DAQ_info.length()));	// DAQInfo always 8th value
	byte_counter += (unsigned __int32)(DAQ_info.length());

	*output_lmf << LMF_Version_output; byte_counter += sizeof(__int32);

	if ((number_of_DAQ_source_strings_output < 0) || (!DAQ_source_strings_output)) number_of_DAQ_source_strings_output = 0;
	*output_lmf << number_of_DAQ_source_strings_output;  byte_counter += sizeof(__int32);

	for (__int32 i=0;i<number_of_DAQ_source_strings_output;++i) {
		unsigned_int_Dummy = (unsigned __int32)(DAQ_source_strings_output[i]->length());
		*output_lmf << unsigned_int_Dummy;   byte_counter += sizeof(__int32);
		output_lmf->write(DAQ_source_strings_output[i]->c_str(),__int32(DAQ_source_strings_output[i]->length()));
		byte_counter += (unsigned __int32)(DAQ_source_strings_output[i]->length());
	}

	*output_lmf <<  time_reference_output;	byte_counter += sizeof(__int32);
	*output_lmf <<  tdcresolution_output;	byte_counter += sizeof(double);		// tdc resolution in ns
	*output_lmf <<  TDCDataType;		byte_counter += sizeof(__int32);

	unsigned __int64 temp_uint64 = number_of_channels_output;
	*output_lmf <<  temp_uint64;		byte_counter += sizeof(unsigned __int64);		// number of channels

	temp_uint64 = max_number_of_hits;
	*output_lmf <<  temp_uint64;		byte_counter += sizeof(unsigned __int64);		// number of hits

	*output_lmf <<  data_format_in_userheader_output;	byte_counter += sizeof(__int32);	// data format (2=short integer)

	// bools
	__int32 counter = 0;
	*output_lmf <<  fADC8.number_of_bools; byte_counter += sizeof(__int32);
	for (__int32 i=counter;i<fADC8.number_of_bools;++i) {
		bool bool_dummy = false;
		*output_lmf <<  bool_dummy;	byte_counter += sizeof(bool);
	}

	// unsigned 32bit
	counter = 0;
	*output_lmf <<  fADC8.number_of_uint32s;		byte_counter += sizeof(__int32);
	
	*output_lmf <<  fADC8.i32NumberOfDAQLoops;		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.i32NumberOfADCmodules;	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iEnableGroupMode;			byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iTriggerChannel;			byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iPreSamplings_in_4800ps_units;	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iPostSamplings_in_9600ps_units;	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iEnableTDCinputs;			byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[0][0];		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[0][1];		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[1][0];		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[1][1];		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[2][0];		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iChannelMode[2][1];		byte_counter += sizeof(__int32); counter++;
	
	for (__int32 i=0;i<3;i++) {
		*output_lmf <<  fADC8.firmware_version[i];	byte_counter += sizeof(__int32); counter++; // adc module firmware
		*output_lmf <<  fADC8.serial_number[i];		byte_counter += sizeof(__int32); counter++; // adc module serial number
	}
	
	*output_lmf <<  fADC8.driver_version; byte_counter += sizeof(__int32); counter++; // adc driver version number
	
	for (__int32 i=counter;i<fADC8.number_of_uint32s;++i) {
		unsigned __int32 uint_dummy = 0;
		*output_lmf <<  uint_dummy;				byte_counter += sizeof(unsigned __int32);
	}

	// signed 32bit
	counter = 0;
	*output_lmf <<  fADC8.number_of_int32s;		byte_counter += sizeof(__int32);

	for (__int32 imod = 0; imod < 3; imod++) {
		for (__int32 ich = 0; ich < 8; ich++) {
			*output_lmf <<  fADC8.iThreshold_GT[imod][ich];	byte_counter += sizeof(__int32);  counter++;
		}
	}
	for (__int32 imod = 0; imod < 3; imod++) {
		for (__int32 ich = 0; ich < 8; ich++) {
			*output_lmf <<  fADC8.iThreshold_LT[imod][ich];	byte_counter += sizeof(__int32);  counter++;
		}
	}
	*output_lmf <<  fADC8.iSynchronMode[0][0];	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iSynchronMode[0][1];	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iSynchronMode[1][0];	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iSynchronMode[1][1];	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iSynchronMode[2][0];	byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.iSynchronMode[2][1];	byte_counter += sizeof(__int32); counter++;
	
	*output_lmf <<  fADC8.GroupEndMarker;			byte_counter += sizeof(__int32); counter++;
	
	*output_lmf <<  fADC8.veto_gate_length;		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.veto_delay_length;		byte_counter += sizeof(__int32); counter++;
	*output_lmf <<  fADC8.veto_mask;				byte_counter += sizeof(__int32); counter++;

	for (__int32 imod = 0; imod < 3; imod++) {
		for (__int32 ich = 0; ich < 8; ich++) {
			*output_lmf <<  fADC8.GND_level[imod][ich]; byte_counter += sizeof(__int32); counter++;
		}
	}

	if (counter < fADC8.number_of_int32s) {
		for (__int32 i=counter;i<fADC8.number_of_int32s;++i) {
			*output_lmf <<  __int32(fADC8.bReadCustomData ? 1 : 0);	byte_counter += sizeof(__int32);
		}
	}

	// doubles
	counter = 0;
	*output_lmf <<  fADC8.number_of_doubles;		byte_counter += sizeof(__int32);
	*output_lmf <<  fADC8.dGroupRangeStart;			byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dGroupRangeEnd;			byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[0][0];	byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[0][1];	byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[1][0];	byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[1][1];	byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[2][0];	byte_counter += sizeof(double); counter++;
	*output_lmf <<  fADC8.dSyncTimeOffset[2][1];	byte_counter += sizeof(double); counter++;
	for (__int32 i=counter;i<fADC8.number_of_doubles;++i) {
		double double_dummy = 0.;
		*output_lmf <<  double_dummy; byte_counter += sizeof(double);
	}

	__int32 int_dummy = 123456789;
	*output_lmf <<  int_dummy;	byte_counter += sizeof(__int32);

	return byte_counter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x2b20(%rdi), %rdi
movsd 0x12c8(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movl 0x2a4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x2ac(%rbx), %esi
callq 0x13378
movl 0xa8(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movq 0xa0(%rbx), %rsi
movl 0xa8(%rbx), %edx
callq 0x1348c
movq 0xa8(%rbx), %r14
movq 0x2b20(%rbx), %rdi
movl 0x12a8(%rbx), %esi
callq 0x1365e
movl 0x132c(%rbx), %esi
testl %esi, %esi
js 0x981c
cmpq $0x0, 0x1338(%rbx)
jne 0x9828
movl $0x0, 0x132c(%rbx)
xorl %esi, %esi
movq 0x2b20(%rbx), %rdi
callq 0x1365e
addl $0x1c, %r14d
cmpl $0x0, 0x132c(%rbx)
jle 0x989f
movq 0x1338(%rbx), %rax
xorl %r15d, %r15d
movq (%rax,%r15,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x1348c
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rcx
movl 0x8(%rcx), %ecx
addl %ecx, %r14d
addl $0x4, %r14d
incq %r15
movslq 0x132c(%rbx), %rcx
cmpq %rcx, %r15
jl 0x984b
movq 0x2b20(%rbx), %rdi
movl 0x244(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movsd 0x12c0(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movl 0x12ac(%rbx), %esi
callq 0x1365e
movslq 0x2c4(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movl 0x2bc(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15a8(%rbx), %esi
callq 0x1365e
addl $0x28, %r14d
cmpl $0x0, 0x15a8(%rbx)
jle 0x9965
xorl %ebp, %ebp
movq 0x2b20(%rbx), %r15
movq (%r15), %rsi
xorl %edi, %edi
callq 0x2190
movq 0x10(%r15), %rcx
movq 0x20(%r15), %rax
incq %rax
movq %rax, 0x20(%r15)
cmpq %rax, %rcx
jae 0x9958
movq %rax, 0x10(%r15)
incl %ebp
cmpl 0x15a8(%rbx), %ebp
jl 0x992f
addl %ebp, %r14d
movq 0x2b20(%rbx), %rdi
movl 0x15b0(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15a4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15bc(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15c0(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15c4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15c8(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15cc(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15d0(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15d4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15d8(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15dc(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15e0(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15e4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15e8(%rbx), %esi
callq 0x1365e
xorl %r15d, %r15d
movq 0x2b20(%rbx), %rdi
movl 0x1858(%rbx,%r15,4), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1878(%rbx,%r15,4), %esi
callq 0x1365e
incq %r15
cmpq $0x3, %r15
jne 0x9a64
addl $0x50, %r14d
movq 0x2b20(%rbx), %rdi
movl 0x15a0(%rbx), %esi
callq 0x13378
cmpl $0x15, 0x15b0(%rbx)
jl 0x9ad5
movl $0x14, %ebp
addl $0x4, %r14d
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
callq 0x13378
incl %ebp
cmpl 0x15b0(%rbx), %ebp
jl 0x9ab9
movq 0x2b20(%rbx), %rdi
movl 0x15ac(%rbx), %esi
callq 0x1365e
leaq 0x1614(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x1365e
incq %r13
cmpq $0x8, %r13
jne 0x9af4
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x9af1
leaq 0x1714(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x1365e
incq %r13
cmpq $0x8, %r13
jne 0x9b27
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x9b24
movq 0x2b20(%rbx), %rdi
movl 0x1814(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1818(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x181c(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1820(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1824(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1828(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x15b8(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x1898(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x189c(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x18a0(%rbx), %esi
callq 0x1365e
leaq 0x18a4(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x1365e
incq %r13
cmpq $0x8, %r13
jne 0x9c0e
incq %r12
addq $0x28, %r15
cmpq $0x3, %r12
jne 0x9c0b
addl $0x150, %r14d           # imm = 0x150
cmpl $0x53, 0x15ac(%rbx)
jl 0x9c6a
movl $0x52, %ebp
movq 0x2b20(%rbx), %rdi
movzbl 0x1854(%rbx), %esi
callq 0x1365e
addl $0x4, %r14d
incl %ebp
cmpl 0x15ac(%rbx), %ebp
jl 0x9c49
movq 0x2b20(%rbx), %rdi
movl 0x15b4(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movsd 0x19e8(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x19f0(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x19f8(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x1a00(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x1a08(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x1a10(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x1a18(%rbx), %xmm0
callq 0x13618
movq 0x2b20(%rbx), %rdi
movsd 0x1a20(%rbx), %xmm0
callq 0x13618
addl $0x44, %r14d
cmpl $0x9, 0x15b4(%rbx)
jl 0x9d4b
movl $0x8, %ebp
movq 0x2b20(%rbx), %rdi
xorps %xmm0, %xmm0
callq 0x13618
addl $0x8, %r14d
incl %ebp
cmpl 0x15b4(%rbx), %ebp
jl 0x9d2e
movq 0x2b20(%rbx), %rdi
movl $0x75bcd15, %esi        # imm = 0x75BCD15
callq 0x1365e
addl $0x4, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq