// File: /workspace/github_cpp_makefile_star2_O2/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 0x11072
movq 0x2b20(%rbx), %rdi
movl 0x2a4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x2ac(%rbx), %esi
callq 0x10d1e
movl 0xa8(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movq 0xa0(%rbx), %rsi
movl 0xa8(%rbx), %edx
callq 0x10e3c
movq 0xa8(%rbx), %r14
movq 0x2b20(%rbx), %rdi
movl 0x12a8(%rbx), %esi
callq 0x11094
movl 0x132c(%rbx), %esi
testl %esi, %esi
js 0x835a
cmpq $0x0, 0x1338(%rbx)
jne 0x8363
andl $0x0, 0x132c(%rbx)
xorl %esi, %esi
movq 0x2b20(%rbx), %rdi
callq 0x11094
addl $0x1c, %r14d
xorl %r15d, %r15d
movslq 0x132c(%rbx), %rax
cmpq %rax, %r15
jge 0x83d3
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x10e3c
movq 0x1338(%rbx), %rax
movq (%rax,%r15,8), %rax
movl 0x8(%rax), %eax
addl %eax, %r14d
addl $0x4, %r14d
incq %r15
jmp 0x8376
movq 0x2b20(%rbx), %rdi
movl 0x244(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movsd 0x12c0(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movl 0x12ac(%rbx), %esi
callq 0x11094
movslq 0x2c4(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movl 0x2bc(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15a8(%rbx), %esi
callq 0x11094
subl $-0x80, %r14d
xorl %ebp, %ebp
movq 0x2b20(%rbx), %rdi
cmpl 0x15a8(%rbx), %ebp
jge 0x8474
xorl %esi, %esi
callq 0x11160
incl %ebp
jmp 0x845a
movl 0x15b0(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15a4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15bc(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15c0(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15c4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15c8(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15cc(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15d0(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15d4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15d8(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15dc(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15e0(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15e4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15e8(%rbx), %esi
callq 0x11094
addl %ebp, %r14d
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x85a2
movq 0x2b20(%rbx), %rdi
movl 0x1858(%rbx,%r15,4), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1878(%rbx,%r15,4), %esi
callq 0x11094
incq %r15
jmp 0x856f
movq 0x2b20(%rbx), %rdi
movl 0x15a0(%rbx), %esi
callq 0x10d1e
pushq $0x14
popq %rbp
cmpl 0x15b0(%rbx), %ebp
jge 0x85d5
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
callq 0x10d1e
incl %ebp
addl $0x4, %r14d
jmp 0x85b7
movq 0x2b20(%rbx), %rdi
movl 0x15ac(%rbx), %esi
callq 0x11094
leaq 0x1614(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x8622
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0x8615
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x11094
incq %r13
jmp 0x85fa
addl $0x20, %r14d
incq %r12
addq $0x20, %r15
jmp 0x85f1
leaq 0x1714(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x865d
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0x8650
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x11094
incq %r13
jmp 0x8635
addl $0x20, %r14d
incq %r12
addq $0x20, %r15
jmp 0x862c
movq 0x2b20(%rbx), %rdi
movl 0x1814(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1818(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x181c(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1820(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1824(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1828(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x15b8(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x1898(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x189c(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x18a0(%rbx), %esi
callq 0x11094
addl $0x28, %r14d
leaq 0x18a4(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x8750
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0x8743
movq 0x2b20(%rbx), %rdi
movl (%r15,%r13,4), %esi
callq 0x11094
incq %r13
jmp 0x8728
addl $0x20, %r14d
incq %r12
addq $0x28, %r15
jmp 0x871f
movl 0x15ac(%rbx), %eax
cmpl $0x53, %eax
jl 0x8783
pushq $0x52
popq %rbp
cmpl %eax, %ebp
jge 0x8783
movq 0x2b20(%rbx), %rdi
movzbl 0x1854(%rbx), %esi
callq 0x11094
addl $0x4, %r14d
incl %ebp
movl 0x15ac(%rbx), %eax
jmp 0x875e
movq 0x2b20(%rbx), %rdi
movl 0x15b4(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movsd 0x19e8(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x19f0(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x19f8(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x1a00(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x1a08(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x1a10(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x1a18(%rbx), %xmm0
callq 0x11072
movq 0x2b20(%rbx), %rdi
movsd 0x1a20(%rbx), %xmm0
callq 0x11072
addl $0x48, %r14d
pushq $0x8
popq %rbp
movq 0x2b20(%rbx), %rdi
cmpl 0x15b4(%rbx), %ebp
jge 0x885b
xorps %xmm0, %xmm0
callq 0x11072
incl %ebp
addl $0x8, %r14d
jmp 0x883c
movl $0x75bcd15, %esi        # imm = 0x75BCD15
callq 0x11094
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop