// File: NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::ReadTCPIPHeader()
__int32	LMF_IO::ReadTCPIPHeader()
/////////////////////////////////////////////////////////////////
{
	__int32	byte_counter = 0;
 

	*input_lmf >> frequency;	byte_counter += sizeof(double);		// frequency is always 4th value
	*input_lmf >> IOaddress;	byte_counter += sizeof(__int32);		// IO address (parameter 1) always 5th value
	*input_lmf >> timestamp_format;	byte_counter += sizeof(__int32);	// TimeInfo (parameter 2) always 6th value  (0,1,2)*32Bit

	*input_lmf >> DAQ_info_Length;	byte_counter += sizeof(__int32);		// Length of DAQInfo always 7th value
	__int8 * __int8_temp = new __int8[DAQ_info_Length+1];
	input_lmf->read(__int8_temp,DAQ_info_Length);	// DAQInfo always 8th value
	__int8_temp[DAQ_info_Length] = 0;
	DAQ_info = __int8_temp;
	delete[] __int8_temp; __int8_temp = 0;
	byte_counter += DAQ_info_Length;
	*input_lmf >> LMF_Version; byte_counter += sizeof(__int32);
	*input_lmf >> time_reference; byte_counter += sizeof(__int32);

	*input_lmf >> data_format_in_userheader;	byte_counter   += sizeof(__int32);
	*input_lmf >> number_of_channels;			byte_counter   += sizeof(__int32);
	*input_lmf >> max_number_of_hits;			byte_counter   += sizeof(__int32);

	if (int(number_of_channels) > num_channels)	{errorflag = 19;	return -100000;}
	if (int(max_number_of_hits) > num_ions)		{errorflag = 20;	return -100000;}

	tdcresolution = 1.;

	return byte_counter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x30(%rbp)
movl $0x0, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x12c8, %rsi           # imm = 0x12C8
callq 0x1d1f0
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x8, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x2a4, %rsi            # imm = 0x2A4
callq 0x1cf60
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x2a8, %rsi            # imm = 0x2A8
callq 0x1cb80
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x129c, %rsi           # imm = 0x129C
callq 0x1cf60
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq $0x4, %rcx
movl %ecx, -0x14(%rbp)
movl 0x129c(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq 0x2b18(%rax), %rdi
movq -0x20(%rbp), %rsi
movl 0x129c(%rax), %edx
callq 0x1cbe0
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq 0x129c(%rdi), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rsi
addq $0xa0, %rdi
callq 0x2250
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x8b0f
movq -0x28(%rbp), %rdi
callq 0x2240
movq -0x30(%rbp), %rsi
movq $0x0, -0x20(%rbp)
movl 0x129c(%rsi), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x12a4, %rsi           # imm = 0x12A4
callq 0x1cf60
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x240, %rsi            # imm = 0x240
callq 0x1cf60
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x290, %rsi            # imm = 0x290
callq 0x1cf60
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x2b4, %rsi            # imm = 0x2B4
callq 0x1cb80
movq -0x30(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movq 0x2b18(%rsi), %rdi
addq $0x2bc, %rsi            # imm = 0x2BC
callq 0x1cb80
movq -0x30(%rbp), %rcx
movslq -0x14(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x14(%rbp)
movl 0x2b4(%rcx), %eax
cmpl 0x2b70(%rcx), %eax
jle 0x8bf6
movq -0x30(%rbp), %rax
movl $0x13, 0x12e0(%rax)
movl $0xfffe7960, -0x4(%rbp) # imm = 0xFFFE7960
jmp 0x8c39
movq -0x30(%rbp), %rcx
movl 0x2bc(%rcx), %eax
cmpl 0x2b74(%rcx), %eax
jle 0x8c1f
movq -0x30(%rbp), %rax
movl $0x14, 0x12e0(%rax)
movl $0xfffe7960, -0x4(%rbp) # imm = 0xFFFE7960
jmp 0x8c39
movq -0x30(%rbp), %rax
movsd 0x163ed(%rip), %xmm0    # 0x1f018
movsd %xmm0, 0x12b8(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)