// File: /workspace/github_cpp_makefile_star2_O1/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::ReadfADC8_header_LMFversion9()
__int32	LMF_IO::ReadfADC8_header_LMFversion9()
{
	__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=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++;
	
	
	for (__int32 i=counter;i<fADC8.number_of_int32s;++i) {
		__int32 int_dummy;
		*input_lmf >> int_dummy;				byte_counter += sizeof(__int32);
	}

	// 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);
	}

	*input_lmf >> fADC8.GroupEndMarker;			byte_counter += sizeof(__int32); counter++;

	return byte_counter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq 0x2b18(%rdi), %rdi
leaq 0x1328(%r14), %r15
movl $0x4, %ebx
movq %r15, %rsi
movl $0x4, %edx
callq 0x139ac
movslq 0x1328(%r14), %rax
leaq (,%rax,8), %r12
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %r12, %rdi
callq 0x2030
movq %rax, 0x1330(%r14)
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x20b0
cmpl $0x0, 0x1328(%r14)
jle 0x8c57
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
movq 0x2b18(%r14), %rdi
movq %r12, %rsi
movl $0x4, %edx
callq 0x139ac
addl $0x4, %ebx
movl $0x20, %edi
callq 0x2130
leaq 0x10(%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1330(%r14), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x1330(%r14), %rax
movq (%rax,%rbp,8), %rdi
movslq 0x10(%rsp), %rsi
callq 0x2210
cmpl $0x0, 0x10(%rsp)
jle 0x8c43
movq 0x2b18(%r14), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x139ac
incl %ebx
movsbl 0x8(%rsp), %esi
movq 0x1330(%r14), %rax
movq (%rax,%rbp,8), %rdi
callq 0x20f0
movl 0x10(%rsp), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsp)
cmpl $0x1, %eax
jg 0x8c08
incq %rbp
movslq (%r15), %rax
cmpq %rax, %rbp
jl 0x8bad
addl $0x28, %ebx
jmp 0x8c5c
movl $0x2c, %ebx
movq 0x2b18(%r14), %rdi
leaq 0x240(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x12b8(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x12ac(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x8, %edx
callq 0x139ac
movl (%r15), %eax
movl %eax, 0x2b4(%r14)
movq 0x2b18(%r14), %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x139ac
movl (%r15), %eax
movl %eax, 0x2bc(%r14)
movl 0x2b4(%r14), %ecx
cmpl 0x2b70(%r14), %ecx
jle 0x8d02
movl $0x13, 0x12e0(%r14)
jmp 0x8d16
cmpl %eax, 0x2b74(%r14)
jge 0x8d20
movl $0x14, 0x12e0(%r14)
movl $0xfffe7960, %ebx       # imm = 0xFFFE7960
jmp 0x9190
movq 0x2b18(%r14), %rdi
leaq 0x290(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15a8(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
cmpl $0x0, 0x15a8(%r14)
jle 0x8d82
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
movq 0x2b18(%r14), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x139ac
incl %ebp
cmpl 0x15a8(%r14), %ebp
jl 0x8d61
addl %ebp, %ebx
movq 0x2b18(%r14), %rdi
leaq 0x15b0(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15a4(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15bc(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15c0(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15c4(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15c8(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15cc(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15d0(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15d4(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15d8(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15dc(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15e0(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15e4(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x15e8(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
addl $0x38, %ebx
cmpl $0xe, 0x15b0(%r14)
jl 0x8f0b
movl $0xd, %ebp
leaq 0x8(%rsp), %r15
movq 0x2b18(%r14), %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x139ac
addl $0x4, %ebx
incl %ebp
cmpl 0x15b0(%r14), %ebp
jl 0x8ee9
movq 0x2b18(%r14), %rdi
leaq 0x15ac(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
leaq 0x1614(%r14), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b18(%r14), %rdi
leaq (%r15,%r13), %rsi
movl $0x4, %edx
callq 0x139ac
addq $0x4, %r13
cmpq $0x20, %r13
jne 0x8f30
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x8f2d
leaq 0x1714(%r14), %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x2b18(%r14), %rdi
leaq (%r15,%r13), %rsi
movl $0x4, %edx
callq 0x139ac
addq $0x4, %r13
cmpq $0x20, %r13
jne 0x8f69
incq %r12
addq $0x20, %r15
cmpq $0x3, %r12
jne 0x8f66
movq 0x2b18(%r14), %rdi
leaq 0x1814(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1818(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x181c(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1820(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1824(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1828(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
addl $0xdc, %ebx
cmpl $0x37, 0x15ac(%r14)
jl 0x9061
movl $0x36, %ebp
leaq 0x8(%rsp), %r15
movq 0x2b18(%r14), %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x139ac
addl $0x4, %ebx
incl %ebp
cmpl 0x15ac(%r14), %ebp
jl 0x903f
movq 0x2b18(%r14), %rdi
leaq 0x15b4(%r14), %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x19e8(%r14), %rsi
movl $0x8, %ebp
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x19f0(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x19f8(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1a00(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1a08(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1a10(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1a18(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
movq 0x2b18(%r14), %rdi
leaq 0x1a20(%r14), %rsi
movl $0x8, %edx
callq 0x139ac
addl $0x44, %ebx
cmpl $0x9, 0x15b4(%r14)
jl 0x9172
leaq 0x8(%rsp), %r15
movq 0x2b18(%r14), %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x139ac
addl $0x8, %ebx
incl %ebp
cmpl 0x15b4(%r14), %ebp
jl 0x9150
movq 0x2b18(%r14), %rdi
addq $0x15b8, %r14           # imm = 0x15B8
movq %r14, %rsi
movl $0x4, %edx
callq 0x139ac
addl $0x4, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop