// File: /workspace/github_cpp_makefile_star2_O1/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 0x13c3c
movq 0x2b20(%rbx), %rdi
movl 0x2a4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x2ac(%rbx), %esi
callq 0x13968
movl 0xa8(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13968
movq 0x2b20(%rbx), %rdi
movq 0xa0(%rbx), %rsi
movl 0xa8(%rbx), %edx
callq 0x13a7c
movq 0xa8(%rbx), %r14
movq 0x2b20(%rbx), %rdi
movl 0x12a8(%rbx), %esi
callq 0x13c82
cmpl $0x0, 0x132c(%rbx)
js 0x99d1
cmpq $0x0, 0x1338(%rbx)
jne 0x99db
movl $0x0, 0x132c(%rbx)
movq 0x2b20(%rbx), %rdi
movl 0x132c(%rbx), %esi
callq 0x13c82
addl $0x1c, %r14d
cmpl $0x0, 0x132c(%rbx)
jle 0x9a58
xorl %r15d, %r15d
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13968
movq 0x2b20(%rbx), %rdi
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x13a7c
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movl 0x8(%rax), %eax
addl %eax, %r14d
addl $0x4, %r14d
incq %r15
movslq 0x132c(%rbx), %rax
cmpq %rax, %r15
jl 0x99fd
movq 0x2b20(%rbx), %rdi
movl 0x244(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movsd 0x12c0(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movl 0x12ac(%rbx), %esi
callq 0x13c82
movslq 0x2c4(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x13a38
movl 0x2bc(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13a38
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15a8(%rbx), %esi
callq 0x13c82
addl $0x28, %r14d
cmpl $0x0, 0x15a8(%rbx)
jle 0x9b1e
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 0x9b11
movq %rax, 0x10(%r15)
incl %ebp
cmpl 0x15a8(%rbx), %ebp
jl 0x9ae8
addl %ebp, %r14d
movq 0x2b20(%rbx), %rdi
movl 0x15b0(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15a4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15bc(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15c0(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15c4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15c8(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15cc(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15d0(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15d4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15d8(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15dc(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15e0(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15e4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15e8(%rbx), %esi
callq 0x13c82
xorl %r15d, %r15d
movq 0x2b20(%rbx), %rdi
movl 0x1858(%rbx,%r15,4), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1878(%rbx,%r15,4), %esi
callq 0x13c82
incq %r15
cmpq $0x3, %r15
jne 0x9c1d
addl $0x50, %r14d
movq 0x2b20(%rbx), %rdi
movl 0x15a0(%rbx), %esi
callq 0x13968
cmpl $0x15, 0x15b0(%rbx)
jl 0x9c8e
movl $0x14, %ebp
addl $0x4, %r14d
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
callq 0x13968
incl %ebp
cmpl 0x15b0(%rbx), %ebp
jl 0x9c72
movq 0x2b20(%rbx), %rdi
movl 0x15ac(%rbx), %esi
callq 0x13c82
leaq 0x1614(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x13c82
incq %r13
cmpq $0x8, %r13
jne 0x9cad
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x9caa
leaq 0x1714(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x13c82
incq %r13
cmpq $0x8, %r13
jne 0x9ce0
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x9cdd
movq 0x2b20(%rbx), %rdi
movl 0x1814(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1818(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x181c(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1820(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1824(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1828(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x15b8(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x1898(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x189c(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movl 0x18a0(%rbx), %esi
callq 0x13c82
leaq 0x18a4(%rbx), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x13c82
incq %r13
cmpq $0x8, %r13
jne 0x9dc7
incq %r12
addq $0x28, %r15
cmpq $0x3, %r12
jne 0x9dc4
addl $0x150, %r14d           # imm = 0x150
cmpl $0x53, 0x15ac(%rbx)
jl 0x9e23
movl $0x52, %ebp
movq 0x2b20(%rbx), %rdi
movzbl 0x1854(%rbx), %esi
callq 0x13c82
addl $0x4, %r14d
incl %ebp
cmpl 0x15ac(%rbx), %ebp
jl 0x9e02
movq 0x2b20(%rbx), %rdi
movl 0x15b4(%rbx), %esi
callq 0x13c82
movq 0x2b20(%rbx), %rdi
movsd 0x19e8(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x19f0(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x19f8(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x1a00(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x1a08(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x1a10(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x1a18(%rbx), %xmm0
callq 0x13c3c
movq 0x2b20(%rbx), %rdi
movsd 0x1a20(%rbx), %xmm0
callq 0x13c3c
addl $0x44, %r14d
cmpl $0x9, 0x15b4(%rbx)
jl 0x9f04
movl $0x8, %ebp
movq 0x2b20(%rbx), %rdi
xorps %xmm0, %xmm0
callq 0x13c3c
addl $0x8, %r14d
incl %ebp
cmpl 0x15b4(%rbx), %ebp
jl 0x9ee7
movq 0x2b20(%rbx), %rdi
movl $0x75bcd15, %esi        # imm = 0x75BCD15
callq 0x13c82
addl $0x4, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop