// File: /workspace/github_cpp_makefile_star2_O2/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::ReadfADC8_header_LMFversion10()
__int32	LMF_IO::ReadfADC8_header_LMFversion10()
{
	__int32 byte_counter = 0;
	*input_lmf >> this->number_of_DAQ_source_strings;  byte_counter += sizeof(__int32);

	DAQ_source_strings = new std::string*[number_of_DAQ_source_strings];
	memset(DAQ_source_strings,0,sizeof(std::string*)*number_of_DAQ_source_strings);
	for (__int32 i=0;i<number_of_DAQ_source_strings;++i) {
		__int32 string_len;
		*input_lmf >> string_len;	byte_counter += sizeof(__int32);
		DAQ_source_strings[i] = new std::string();
		DAQ_source_strings[i]->reserve(string_len);
		while (string_len > 0) {
			__int8 c;
			*input_lmf >> c;	byte_counter += sizeof(__int8);
			*DAQ_source_strings[i] += c;
			--string_len;
		}
	}

	*input_lmf >> time_reference;	byte_counter += sizeof(__int32);
	*input_lmf >> tdcresolution;	byte_counter += sizeof(double);		// tdc resolution in ns
	*input_lmf >> TDCDataType;		byte_counter += sizeof(__int32);

	unsigned __int64 temp_uint64;
	*input_lmf >> temp_uint64;		byte_counter += sizeof(unsigned __int64);		// number of channels
	number_of_channels =__int32(temp_uint64);

	*input_lmf >> temp_uint64;		byte_counter += sizeof(unsigned __int64);		// number of hits
	max_number_of_hits =__int32(temp_uint64);

	if (int(number_of_channels) > num_channels)	{errorflag = 19;	return -100000;}
	if (int(max_number_of_hits) > num_ions)		{errorflag = 20;	return -100000;}

	*input_lmf >> data_format_in_userheader;	byte_counter += sizeof(__int32);	// data format (2=short integer)


	// bools
	__int32 counter = 0;
	*input_lmf >> fADC8.number_of_bools; byte_counter += sizeof(__int32);
	for (__int32 i=counter;i<fADC8.number_of_bools;++i) {
		bool bool_dummy;
		*input_lmf >> bool_dummy;	byte_counter += sizeof(bool);
	}

	// unsigned 32bit
	counter = 0;
	*input_lmf >> fADC8.number_of_uint32s;		byte_counter += sizeof(__int32);
	
	*input_lmf >> fADC8.i32NumberOfDAQLoops;	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.i32NumberOfADCmodules;	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iEnableGroupMode;		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iTriggerChannel;		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iPreSamplings_in_4800ps_units;	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iPostSamplings_in_9600ps_units;	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iEnableTDCinputs;		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[0][0];		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[0][1];		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[1][0];		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[1][1];		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[2][0];		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iChannelMode[2][1];		byte_counter += sizeof(__int32); counter++;
	
	for (__int32 i=0;i<3;i++) {
		*input_lmf >> fADC8.firmware_version[i];	; byte_counter += sizeof(__int32); counter++; // adc module firmware
		*input_lmf >> fADC8.serial_number[i];		; byte_counter += sizeof(__int32); counter++; // adc module serial number
	}
	
	*input_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;
		*input_lmf >> uint_dummy;				byte_counter += sizeof(unsigned __int32);
	}

	// signed 32bit
	counter = 0;
	*input_lmf >> fADC8.number_of_int32s;		byte_counter += sizeof(__int32);

	for (__int32 imod = 0; imod < 3; imod++) {
		for (__int32 ich = 0; ich < 8; ich++) {
			*input_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++) {
			*input_lmf >> fADC8.iThreshold_LT[imod][ich];	byte_counter += sizeof(__int32);  counter++;
		}
	}
	*input_lmf >> fADC8.iSynchronMode[0][0];	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iSynchronMode[0][1];	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iSynchronMode[1][0];	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iSynchronMode[1][1];	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iSynchronMode[2][0];	byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.iSynchronMode[2][1];	byte_counter += sizeof(__int32); counter++;
	
	*input_lmf >> fADC8.GroupEndMarker;			byte_counter += sizeof(__int32); counter++;
	
	if (fADC8.GroupEndMarker != 12345678) return 0;
	
	*input_lmf >> fADC8.veto_gate_length;		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.veto_delay_length;		byte_counter += sizeof(__int32); counter++;
	*input_lmf >> fADC8.veto_mask;				byte_counter += sizeof(__int32); counter++;

	for (__int32 imod = 0; imod < 3; imod++) {
		for (__int32 ich = 0; ich < 8; ich++) {
			*input_lmf >> fADC8.GND_level[imod][ich]; byte_counter += sizeof(__int32); counter++;
		}
	}

	fADC8.bReadCustomData = false;
	if (counter < fADC8.number_of_int32s) {
		for (__int32 i=counter;i<fADC8.number_of_int32s;++i) {
			__int32 int_dummy;
			*input_lmf >> int_dummy;			byte_counter += sizeof(__int32);
			fADC8.bReadCustomData = int_dummy ? true:false;
		}
	}

	// doubles
	counter = 0;
	*input_lmf >> fADC8.number_of_doubles;		byte_counter += sizeof(__int32);
	*input_lmf >> fADC8.dGroupRangeStart;		byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dGroupRangeEnd;			byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[0][0];	byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[0][1];	byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[1][0];	byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[1][1];	byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[2][0];	byte_counter += sizeof(double); counter++;
	*input_lmf >> fADC8.dSyncTimeOffset[2][1];	byte_counter += sizeof(double); counter++;
	for (__int32 i=counter;i<fADC8.number_of_doubles;++i) {
		double double_dummy;
		*input_lmf >> double_dummy; byte_counter += sizeof(double);
	}

	__int32 int_dummy;
	*input_lmf >> int_dummy;	byte_counter += sizeof(__int32);
	if (int_dummy != 123456789) return 0;
	
	return byte_counter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x2b18(%rdi), %rdi
leaq 0x1328(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
movslq 0x1328(%rbx), %r12
leaq (,%r12,8), %r13
testq %r12, %r12
pushq $-0x1
popq %rdi
cmovnsq %r13, %rdi
callq 0x2030
movq %rax, 0x1330(%rbx)
xorl %r15d, %r15d
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20b0
pushq $0x4
popq %rbp
leaq 0x8(%rsp), %r13
movslq %r12d, %rax
cmpq %rax, %r15
jge 0x7d69
movq 0x2b18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10fca
addl $0x4, %ebp
pushq $0x20
popq %rdi
callq 0x2130
leaq 0x10(%rax), %rcx
movq %rcx, (%rax)
andq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1330(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x1330(%rbx), %rax
movq (%rax,%r15,8), %rdi
movslq 0x10(%rsp), %rsi
callq 0x2200
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0x7d5e
movq 0x2b18(%rbx), %rdi
movq %r13, %rsi
callq 0x11060
incl %ebp
movsbl 0x8(%rsp), %esi
movq 0x1330(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x20f0
movl 0x10(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
jmp 0x7d28
incq %r15
movl (%r14), %r12d
jmp 0x7ccc
movq 0x2b18(%rbx), %rdi
leaq 0x240(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x12b8(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x12ac(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x10d78
movl (%r14), %eax
movl %eax, 0x2b4(%rbx)
movq 0x2b18(%rbx), %rdi
movq %r14, %rsi
callq 0x10d78
movl (%r14), %eax
movl %eax, 0x2bc(%rbx)
movl 0x2b4(%rbx), %ecx
cmpl 0x2b70(%rbx), %ecx
jle 0x7df1
movl $0x13, 0x12e0(%rbx)
jmp 0x7e03
cmpl %eax, 0x2b74(%rbx)
jge 0x7e17
movl $0x14, 0x12e0(%rbx)
movl $0xfffe7960, %eax       # imm = 0xFFFE7960
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b18(%rbx), %rdi
leaq 0x290(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15a8(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
subl $-0x80, %ebp
xorl %r12d, %r12d
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7e64
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x1114e
incl %r12d
jmp 0x7e4b
movq 0x2b18(%rbx), %rdi
leaq 0x15b0(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15a4(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15bc(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15c0(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15c4(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15c8(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15cc(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15d0(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15d4(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15d8(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15dc(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15e0(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15e4(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15e8(%rbx), %rsi
callq 0x10fca
leaq 0x1878(%rbx), %r15
addl %r12d, %ebp
pushq $0x3
popq %r12
subq $0x1, %r12
jb 0x7faa
movq 0x2b18(%rbx), %rdi
leaq -0x20(%r15), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x10fca
addq $0x4, %r15
jmp 0x7f7f
leaq 0x15a0(%rbx), %rsi
movq 0x2b18(%rbx), %rdi
callq 0x10d66
pushq $0x14
popq %r12
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7fe2
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x10d66
addl $0x4, %ebp
incl %r12d
jmp 0x7fc6
movq 0x2b18(%rbx), %rdi
leaq 0x15ac(%rbx), %rsi
callq 0x10fca
leaq 0x1614(%rbx), %r14
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x8030
addl $0x20, %ebp
xorl %r12d, %r12d
cmpq $0x20, %r12
je 0x8027
movq 0x2b18(%rbx), %rdi
leaq (%r14,%r12), %rsi
callq 0x10fca
addq $0x4, %r12
jmp 0x800b
incq %r15
addq $0x20, %r14
jmp 0x7fff
leaq 0x1714(%rbx), %r14
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x806b
addl $0x20, %ebp
xorl %r12d, %r12d
cmpq $0x20, %r12
je 0x8062
movq 0x2b18(%rbx), %rdi
leaq (%r14,%r12), %rsi
callq 0x10fca
addq $0x4, %r12
jmp 0x8046
incq %r15
addq $0x20, %r14
jmp 0x803a
movq 0x2b18(%rbx), %rdi
leaq 0x1814(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x1818(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x181c(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x1820(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x1824(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x1828(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15b8(%rbx), %rsi
callq 0x10fca
xorl %eax, %eax
cmpl $0xbc614e, 0x15b8(%rbx) # imm = 0xBC614E
jne 0x7e08
movq 0x2b18(%rbx), %rdi
leaq 0x1898(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x189c(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x18a0(%rbx), %rsi
callq 0x10fca
addl $0x28, %ebp
leaq 0x18a4(%rbx), %r14
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x8179
addl $0x20, %ebp
xorl %r12d, %r12d
cmpq $0x20, %r12
je 0x8170
movq 0x2b18(%rbx), %rdi
leaq (%r14,%r12), %rsi
callq 0x10fca
addq $0x4, %r12
jmp 0x8154
incq %r15
addq $0x28, %r14
jmp 0x8148
movb $0x0, 0x1854(%rbx)
movl 0x15ac(%rbx), %eax
cmpl $0x53, %eax
jl 0x81c2
pushq $0x52
popq %r15
leaq 0x8(%rsp), %r14
cmpl %eax, %r15d
jge 0x81c2
movq 0x2b18(%rbx), %rdi
movq %r14, %rsi
callq 0x10fca
addl $0x4, %ebp
cmpl $0x0, 0x8(%rsp)
setne 0x1854(%rbx)
incl %r15d
movl 0x15ac(%rbx), %eax
jmp 0x8194
movq 0x2b18(%rbx), %rdi
leaq 0x15b4(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x19e8(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x19f0(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x19f8(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x1a00(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x1a08(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x1a10(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x1a18(%rbx), %rsi
callq 0x110e4
movq 0x2b18(%rbx), %rdi
leaq 0x1a20(%rbx), %rsi
callq 0x110e4
addl $0x48, %ebp
pushq $0x8
popq %r12
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x8298
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x110e4
incl %r12d
addl $0x8, %ebp
jmp 0x827c
movq 0x2b18(%rbx), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x10fca
xorl %eax, %eax
cmpl $0x75bcd15, (%rbx)      # imm = 0x75BCD15
cmovel %ebp, %eax
jmp 0x7e08