// File: /workspace/github_cpp_makefile_star2_O2/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::ReadNextfADC8Signal(fADC8_signal_info_struct&, bool&, unsigned int*, int)
bool LMF_IO::ReadNextfADC8Signal(fADC8_signal_info_struct& signal_info, bool& bEnd_of_group_detected, unsigned __int32 * ui32buffer, __int32 buffersize_in_32bit_words)
/////////////////////////////////////////////////////////////////
{
	if (!input_lmf) {
		errorflag = 9;
		return false;
	}
	if (errorflag) return false;

//L100:

	input_lmf->read((char*)(&signal_info),sizeof(signal_info));

	if (input_lmf->error) {
		if (input_lmf->eof) this->errorflag = 18; else this->errorflag = 1;
		return false;
	}

	if (signal_info.adc_channel == -1 && signal_info.ModuleIndex == -1) {
		goto L200;
	}

	if (signal_info.signal_type != 8) {
		__int32 leng = buffersize_in_32bit_words > signal_info.signallength_including_header_in_32bit_words ? signal_info.signallength_including_header_in_32bit_words : buffersize_in_32bit_words;
		input_lmf->read(ui32buffer, leng*4);
		if (input_lmf->error) {
			if (input_lmf->eof) this->errorflag = 18; else this->errorflag = 1;
			return false;
		}
		if (leng < signal_info.signallength_including_header_in_32bit_words) {
			__int8 byte_dummy;
			for (__int32 i=0;i<(signal_info.signallength_including_header_in_32bit_words-leng)*4;i++) input_lmf->read(&byte_dummy,1);
		}
	}


L200:

	__int32 header_word;
	*input_lmf >> header_word;

	if (header_word != 12345678 && header_word != 0) {
		errorflag = 2;
		return false;
	}

	if (header_word == fADC8.GroupEndMarker) { // end of group
		bEnd_of_group_detected = true;
		++uint64_number_of_read_events;
	} else bEnd_of_group_detected = false;

	if (bEnd_of_group_detected && fADC8.bReadCustomData) {
		*input_lmf >> number_of_bytes_in_PostEventData;
		if (input_lmf->error) {
			if (input_lmf->eof) this->errorflag = 18; else this->errorflag = 1;
			return false;
		}
		if (number_of_bytes_in_PostEventData > MAX_NUMBER_OF_BYTES_IN_POSTEVENTDATA) {
			input_lmf->error = 21;
			return false;
		}
		for (__int32 i=0;i<number_of_bytes_in_PostEventData;i++) {
			unsigned __int8 byte_dummy;
			*input_lmf >> byte_dummy;
			ui8_PostEventData[i] = byte_dummy;
		}
	}

	if (input_lmf->error) {
		if (input_lmf->eof) this->errorflag = 18; else this->errorflag = 1;
		return false;
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x2b18(%rdi), %rdi
testq %rdi, %rdi
je 0x74a3
cmpl $0x0, 0x12e0(%rbx)
jne 0x74ad
movl %r8d, %r15d
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
pushq $0x38
popq %rdx
callq 0x10d8a
movq 0x2b18(%rbx), %rdi
cmpl $0x0, 0x8(%rdi)
je 0x74be
cmpb $0x0, 0xc(%rdi)
pushq $0x12
popq %rax
pushq $0x1
popq %rcx
cmovnel %eax, %ecx
movl %ecx, 0x12e0(%rbx)
jmp 0x74ad
movl $0x9, 0x12e0(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpw $-0x1, 0x2e(%r12)
sete %al
cmpb $-0x1, (%r12)
sete %cl
testb %cl, %al
jne 0x7544
cmpb $0x8, 0x18(%r12)
je 0x7544
movl 0x28(%r12), %eax
cmpl %r15d, %eax
cmovll %eax, %r15d
leal (,%r15,4), %edx
movq %r13, %rsi
callq 0x11108
movq 0x2b18(%rbx), %rdi
cmpl $0x0, 0x8(%rdi)
jne 0x748e
movl 0x28(%r12), %eax
cmpl %eax, %r15d
jge 0x7544
xorl %r13d, %r13d
pushq $0x1
popq %rbp
subl %r15d, %eax
shll $0x2, %eax
cmpl %eax, %r13d
jge 0x753d
movq 0x2b18(%rbx), %rdi
leaq 0x3(%rsp), %rsi
movl %ebp, %edx
callq 0x10d8a
incl %r13d
movl 0x28(%r12), %eax
jmp 0x7515
movq 0x2b18(%rbx), %rdi
leaq 0x4(%rsp), %r15
movq %r15, %rsi
callq 0x10fca
movl (%r15), %eax
testl %eax, %eax
je 0x755f
cmpl $0xbc614e, %eax         # imm = 0xBC614E
jne 0x75c1
cmpl 0x15b8(%rbx), %eax
jne 0x75a7
incq 0x260(%rbx)
movb $0x1, (%r14)
cmpb $0x1, 0x1854(%rbx)
jne 0x75ab
movq 0x2b18(%rbx), %rdi
leaq 0x1280(%rbx), %r14
movq %r14, %rsi
callq 0x10fca
movq 0x2b18(%rbx), %rcx
cmpl $0x0, 0x8(%rcx)
je 0x75d7
cmpb $0x0, 0xc(%rcx)
jmp 0x7492
movb $0x0, (%r14)
movq 0x2b18(%rbx), %rax
cmpl $0x0, 0x8(%rax)
je 0x75d0
cmpb $0x0, 0xc(%rax)
jmp 0x7492
movl $0x2, 0x12e0(%rbx)
jmp 0x74ad
movb $0x1, %al
jmp 0x74af
movl (%r14), %eax
cmpl $0xfa0, %eax            # imm = 0xFA0
jle 0x75ed
movl $0x15, 0x8(%rcx)
jmp 0x74ad
xorl %r15d, %r15d
leaq 0x2(%rsp), %r14
cltq
cmpq %rax, %r15
jge 0x75ab
movq 0x2b18(%rbx), %rdi
movq %r14, %rsi
callq 0x10d42
movb 0x2(%rsp), %al
movb %al, 0x2e0(%rbx,%r15)
incq %r15
movl 0x1280(%rbx), %eax
jmp 0x75f5