// File: /workspace/github_cpp_makefile_star2_O2/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, %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 0x7821
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 0x7816
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 0x77e0
incq %r15
movl (%r14), %r12d
jmp 0x7784
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 0x78a9
movl $0x13, 0x12e0(%rbx)
jmp 0x78bb
cmpl %eax, 0x2b74(%rbx)
jge 0x78c5
movl $0x14, 0x12e0(%rbx)
movl $0xfffe7960, %ebp       # imm = 0xFFFE7960
jmp 0x7c56
movq 0x2b18(%rbx), %rdi
leaq 0x290(%rbx), %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rdi
leaq 0x15a8(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
addl $0xc4, %ebp
xorl %r12d, %r12d
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7915
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x1114e
incl %r12d
jmp 0x78fc
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
addl %r12d, %ebp
pushq $0xd
popq %r12
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7a4a
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x10d66
incl %r12d
addl $0x4, %ebp
jmp 0x7a2e
movq 0x2b18(%rbx), %rdi
leaq 0x15ac(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
leaq 0x1614(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x7a9b
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x7a8f
movq 0x2b18(%rbx), %rdi
leaq (%r15,%r13), %rsi
callq 0x10fca
addq $0x4, %r13
jmp 0x7a73
incq %r12
addl $0x20, %ebp
addq $0x20, %r15
jmp 0x7a6a
leaq 0x1714(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x7ad6
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x7aca
movq 0x2b18(%rbx), %rdi
leaq (%r15,%r13), %rsi
callq 0x10fca
addq $0x4, %r13
jmp 0x7aae
incq %r12
addl $0x20, %ebp
addq $0x20, %r15
jmp 0x7aa5
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
pushq $0x36
popq %r12
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7b6d
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x10fca
incl %r12d
addl $0x4, %ebp
jmp 0x7b51
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
pushq $0x8
popq %r12
leaq 0x8(%rsp), %r15
cmpl (%r14), %r12d
jge 0x7c40
movq 0x2b18(%rbx), %rdi
movq %r15, %rsi
callq 0x110e4
incl %r12d
addl $0x8, %ebp
jmp 0x7c24
movq 0x2b18(%rbx), %rdi
addq $0x15b8, %rbx           # imm = 0x15B8
movq %rbx, %rsi
callq 0x10fca
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop