// File: NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::Write2TDC8PCI2Header()
__int32	LMF_IO::Write2TDC8PCI2Header()
/////////////////////////////////////////////////////////////////
{
	unsigned __int32 byte_counter;
	byte_counter = 0;
//	__int32 int_Dummy = 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 += __int32(DAQ_info.length());

	*output_lmf << LMF_Version_output; byte_counter += sizeof(__int32);

	*output_lmf << system_timeout_output; byte_counter += sizeof(__int32);		//   system time-out
	*output_lmf << time_reference_output; byte_counter += sizeof(__int32);
	*output_lmf << common_mode_output; byte_counter += sizeof(__int32);		//   0 common start    1 common stop
	*output_lmf << tdcresolution_output; byte_counter += sizeof(double);		// tdc resolution in ns

	TDCDataType = 1;
	*output_lmf << TDCDataType; byte_counter += sizeof(__int32);
	*output_lmf << timerange; byte_counter += sizeof(__int32);	// time range of the tdc in microseconds

	*output_lmf << number_of_channels_output; byte_counter += sizeof(__int32);			// number of channels
	*output_lmf << max_number_of_hits_output; byte_counter += sizeof(__int32);			// number of hits
	*output_lmf << number_of_channels2_output; byte_counter += sizeof(__int32);	// number of channels2
	*output_lmf << max_number_of_hits2_output; byte_counter += sizeof(__int32);	// number of hits2
	*output_lmf << data_format_in_userheader_output;	byte_counter += sizeof(__int32);				// data format (2=short integer)

	if (TDC8PCI2.use_normal_method_2nd_card) {
		if (DAQVersion_output >= 20020408) {
			*output_lmf << TDC8PCI2.GateDelay_1st_card;			byte_counter += sizeof(__int32); // gate delay 1st card
			*output_lmf << TDC8PCI2.OpenTime_1st_card ;			byte_counter += sizeof(__int32); // open time 1st card
			*output_lmf << TDC8PCI2.WriteEmptyEvents_1st_card;	byte_counter += sizeof(__int32); // write empty events 1st card
			*output_lmf << TDC8PCI2.TriggerFalling_1st_card;	byte_counter += sizeof(__int32); // trigger falling edge 1st card
			*output_lmf << TDC8PCI2.TriggerRising_1st_card;		byte_counter += sizeof(__int32); // trigger rising edge 1st card
			*output_lmf << TDC8PCI2.EmptyCounter_1st_card;		byte_counter += sizeof(__int32); // EmptyCounter 1st card
			*output_lmf << TDC8PCI2.EmptyCounter_since_last_Event_1st_card;	byte_counter += sizeof(__int32); // Empty Counter since last event 1st card
		}
		*output_lmf << TDC8PCI2.sync_test_on_off;			byte_counter += sizeof(__int32); // sync test on/off
		*output_lmf << TDC8PCI2.io_address_2nd_card;		byte_counter += sizeof(__int32); // io address 2nd card
		*output_lmf << TDC8PCI2.GateDelay_2nd_card;			byte_counter += sizeof(__int32); // gate delay 2nd card
		*output_lmf << TDC8PCI2.OpenTime_2nd_card;			byte_counter += sizeof(__int32); // open time 2nd card
		*output_lmf << TDC8PCI2.WriteEmptyEvents_2nd_card;	byte_counter += sizeof(__int32); // write empty events 2nd card
		*output_lmf << TDC8PCI2.TriggerFallingEdge_2nd_card;	byte_counter += sizeof(__int32); // trigger falling edge 2nd card
		*output_lmf << TDC8PCI2.TriggerRisingEdge_2nd_card;	byte_counter += sizeof(__int32); // trigger rising edge 2nd card
		*output_lmf << TDC8PCI2.EmptyCounter_2nd_card;		byte_counter += sizeof(__int32); // EmptyCounter 2nd card
		*output_lmf << TDC8PCI2.EmptyCounter_since_last_Event_2nd_card;	byte_counter += sizeof(__int32); // Empty Counter since last event 2nd card
	} else {
		*output_lmf << module_2nd;							byte_counter += sizeof(__int32); // indicator for 2nd module data
		*output_lmf << TDC8PCI2.GateDelay_1st_card;			byte_counter += sizeof(__int32); // gate delay 1st card
		*output_lmf << TDC8PCI2.OpenTime_1st_card ;			byte_counter += sizeof(__int32); // open time 1st card
		*output_lmf << TDC8PCI2.WriteEmptyEvents_1st_card;	byte_counter += sizeof(__int32); // write empty events 1st card
		*output_lmf << TDC8PCI2.TriggerFalling_1st_card;	byte_counter += sizeof(__int32); // trigger falling edge 1st card
		*output_lmf << TDC8PCI2.TriggerRising_1st_card;		byte_counter += sizeof(__int32); // trigger rising edge 1st card

		*output_lmf << TDC8PCI2.GateDelay_2nd_card;			byte_counter += sizeof(__int32); // gate delay 2nd card
		*output_lmf << TDC8PCI2.OpenTime_2nd_card;			byte_counter += sizeof(__int32); // open time 2nd card
		*output_lmf << TDC8PCI2.WriteEmptyEvents_2nd_card;	byte_counter += sizeof(__int32); // write empty events 2nd card
		*output_lmf << TDC8PCI2.TriggerFallingEdge_2nd_card;	byte_counter += sizeof(__int32); // trigger falling edge 2nd card
		*output_lmf << TDC8PCI2.TriggerRisingEdge_2nd_card;	byte_counter += sizeof(__int32); // trigger rising edge 2nd card
	}
	return byte_counter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movsd 0x12c8(%rax), %xmm0
callq 0x1d130
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x8, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2a4(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2ac(%rax), %esi
callq 0x1caf0
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
addq $0x4, %rax
movl %eax, -0xc(%rbp)
addq $0xa0, %rdi
callq 0x22b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movl %ecx, -0x10(%rbp)
movq 0x2b20(%rax), %rdi
movl -0x10(%rbp), %esi
callq 0x1caf0
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
addq $0x4, %rax
movl %eax, -0xc(%rbp)
movq 0x2b20(%rdi), %rax
movq %rax, -0x28(%rbp)
addq $0xa0, %rdi
callq 0x20b0
movq -0x18(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0xa0, %rdi
callq 0x22b0
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl %eax, %edx
callq 0x1cd10
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
callq 0x22b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
addl -0xc(%rbp), %ecx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x12a8(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1290(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x244(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1298(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movsd 0x12c0(%rax), %xmm0
callq 0x1d130
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x8, %rcx
movl %ecx, -0xc(%rbp)
movl $0x1, 0x12ac(%rax)
movq 0x2b20(%rax), %rdi
movl 0x12ac(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2b0(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2c4(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2cc(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2c8(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x2d0(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x294(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
testb $0x1, 0x1575(%rax)
je 0x101a9
movq -0x18(%rbp), %rax
cmpl $0x1317cb8, 0x284(%rax) # imm = 0x1317CB8
jb 0x10084
movq -0x18(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x1558(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x155c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1560(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1564(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1568(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x156c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1570(%rax), %esi
callq 0x1d170
movl -0xc(%rbp), %eax
addq $0x4, %rax
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x1578(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x157c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1580(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1584(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1588(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x158c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1590(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1594(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1598(%rax), %esi
callq 0x1d170
movl -0xc(%rbp), %eax
addq $0x4, %rax
movl %eax, -0xc(%rbp)
jmp 0x10309
movq -0x18(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x1288(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1558(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x155c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1560(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1564(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1568(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1580(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1584(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1588(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x158c(%rax), %esi
callq 0x1d170
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
addq $0x4, %rcx
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl 0x1590(%rax), %esi
callq 0x1d170
movl -0xc(%rbp), %eax
addq $0x4, %rax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)