// File: /workspace/github_cpp_makefile_star2_O1/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 0x8817
cmpl $0x0, 0x12e0(%rbx)
jne 0x8821
movl %r8d, %r15d
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
movl $0x38, %edx
callq 0x139ac
movq 0x2b18(%rbx), %rdi
cmpl $0x0, 0x8(%rdi)
je 0x8832
cmpb $0x0, 0xc(%rdi)
movl $0x12, %eax
movl $0x1, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x12e0(%rbx)
jmp 0x8821
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 0x88dd
cmpb $0x8, 0x18(%r12)
je 0x88dd
movl 0x28(%r12), %eax
cmpl %r15d, %eax
cmovll %eax, %r15d
leal (,%r15,4), %edx
movq %r13, %rsi
callq 0x13d0a
movq 0x2b18(%rbx), %rax
movl 0x8(%rax), %ebp
testl %ebp, %ebp
je 0x889b
cmpb $0x0, 0xc(%rax)
movl $0x12, %eax
movl $0x1, %ecx
cmovnel %eax, %ecx
movl %ecx, 0x12e0(%rbx)
jmp 0x88d5
cmpl 0x28(%r12), %r15d
jge 0x88d5
cmpl %r15d, 0x28(%r12)
jle 0x88d5
xorl %r13d, %r13d
movq 0x2b18(%rbx), %rdi
leaq 0x3(%rsp), %rsi
movl $0x1, %edx
callq 0x139ac
incl %r13d
movl 0x28(%r12), %eax
subl %r15d, %eax
shll $0x2, %eax
cmpl %eax, %r13d
jl 0x88ac
testl %ebp, %ebp
jne 0x8821
movq 0x2b18(%rbx), %rdi
leaq 0x4(%rsp), %r15
movq %r15, %rsi
movl $0x4, %edx
callq 0x139ac
movl (%r15), %eax
testl %eax, %eax
je 0x8904
cmpl $0xbc614e, %eax         # imm = 0xBC614E
jne 0x8971
cmpl 0x15b8(%rbx), %eax
jne 0x8919
movb $0x1, (%r14)
incq 0x260(%rbx)
jmp 0x891d
movb $0x0, (%r14)
cmpb $0x1, (%r14)
jne 0x89bd
cmpb $0x1, 0x1854(%rbx)
jne 0x89bd
movq 0x2b18(%rbx), %rdi
leaq 0x1280(%rbx), %r14
movq %r14, %rsi
movl $0x4, %edx
callq 0x139ac
movq 0x2b18(%rbx), %rax
cmpl $0x0, 0x8(%rax)
jne 0x89ca
cmpl $0xfa0, (%r14)          # imm = 0xFA0
jle 0x8980
movl $0x15, 0x8(%rax)
jmp 0x8821
movl $0x2, 0x12e0(%rbx)
jmp 0x8821
cmpl $0x0, (%r14)
jle 0x89bd
xorl %r15d, %r15d
leaq 0x2(%rsp), %r14
movq 0x2b18(%rbx), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x139ac
movb 0x2(%rsp), %al
movb %al, 0x2e0(%rbx,%r15)
incq %r15
movslq 0x1280(%rbx), %rax
cmpq %rax, %r15
jl 0x898e
movq 0x2b18(%rbx), %rax
cmpl $0x0, 0x8(%rax)
je 0x89d3
cmpb $0x0, 0xc(%rax)
jmp 0x8802
movb $0x1, %al
jmp 0x8823