// File: /workspace/github_cpp_makefile_star2_O1/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::WriteCAMACArray(double, unsigned int*)
void LMF_IO::WriteCAMACArray(double timestamp, unsigned __int32 data[])
/////////////////////////////////////////////////////////////////
{
	unsigned __int16 dummy_uint16;
	unsigned __int8  dummy_uint8;


	if (!output_lmf || !OutputFileIsOpen) {
		errorflag = 10;
		return;
	}
	
	++uint64_number_of_written_events;

	myLARGE_INTEGER LARGE_Timestamp;
	LARGE_Timestamp.QuadPart = (__int64)(timestamp * frequency);

	if (timestamp_format_output >= 1) {
		if (data_format_in_userheader_output == 2) {
			dummy_uint16 = (unsigned __int16)(LARGE_Timestamp.LowPart & 0x0000ffff); *output_lmf << dummy_uint16;			// 32 Bit Low part, lower  16 Bit
			dummy_uint16 = (unsigned __int16)(LARGE_Timestamp.LowPart & 0xffff0000); *output_lmf << dummy_uint16;			// 32 Bit Low part, higher 16 Bit
		}
		if (data_format_in_userheader_output == 6) {
			dummy_uint8 = (unsigned __int8)(LARGE_Timestamp.LowPart & 0x000000ff); *output_lmf << dummy_uint8;			// 32 Bit Low part, lower 16 Bit, lower 8 bit
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.LowPart >> 8) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit Low part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)0; *output_lmf << dummy_uint8;	
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.LowPart >> 16) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit Low part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.LowPart >> 24) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit Low part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)0; *output_lmf << dummy_uint8;
		}
	}
	if (timestamp_format_output == 2) {
		if (data_format_in_userheader_output == 2) {
			dummy_uint16 = (unsigned __int16)(LARGE_Timestamp.HighPart & 0x0000ffff); *output_lmf << dummy_uint16;			// 32 Bit High part, lower  16 Bit
			dummy_uint16 = (unsigned __int16)(LARGE_Timestamp.HighPart & 0xffff0000); *output_lmf << dummy_uint16;			// 32 Bit High part, higher 16 Bit
		}
		if (data_format_in_userheader_output == 6) {
			dummy_uint8 = (unsigned __int8)(LARGE_Timestamp.HighPart & 0x000000ff); *output_lmf << dummy_uint8;			// 32 Bit High part, lower 16 Bit, lower 8 bit
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.HighPart >> 8) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit High part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)0; *output_lmf << dummy_uint8;	
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.HighPart >> 16) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit High part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)((LARGE_Timestamp.HighPart >> 24) & 0x000000ff); *output_lmf << dummy_uint8;	// 32 Bit High part, lower 16 Bit, high 8 bit
			dummy_uint8 = (unsigned __int8)0; *output_lmf << dummy_uint8;
		}
	}

	unsigned __int32 i;

	for (i=0;i<Numberofcoordinates - timestamp_format_output * 2;++i) {
		if (data_format_in_userheader_output == 2) {
			dummy_uint16 = (unsigned __int16)( data[i]        & 0x0000ffff); *output_lmf << dummy_uint16;
		}
		if (data_format_in_userheader_output == 6) {
			dummy_uint8 = (unsigned __int8)( data[i]        & 0x000000ff); *output_lmf << dummy_uint8;
			dummy_uint8 = (unsigned __int8)((data[i] >>  8) & 0x000000ff); *output_lmf << dummy_uint8;
			dummy_uint8 = (unsigned __int8)((data[i] >> 16) & 0x000000ff); *output_lmf << dummy_uint8;
		}
	}

	return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x2b20(%rdi), %rdi
testq %rdi, %rdi
je 0x11585
cmpb $0x0, 0x2b29(%r14)
je 0x11585
movq %rsi, %rbx
incq 0x2b10(%r14)
mulsd 0x12c8(%r14), %xmm0
cvttsd2si %xmm0, %r15
cmpl $0x0, 0x2ac(%r14)
je 0x11321
cmpl $0x2, 0x294(%r14)
jne 0x111eb
movzwl %r15w, %esi
callq 0x139f4
movq 0x2b20(%r14), %rdi
xorl %esi, %esi
callq 0x139f4
cmpl $0x6, 0x294(%r14)
jne 0x11321
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movsbl %r15b, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11229
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movl %r15d, %eax
shrl $0x8, %eax
movsbl %al, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x1125e
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
xorl %edi, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x1128c
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movl %r15d, %eax
shrl $0x10, %eax
movsbl %al, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x112c1
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movl %r15d, %edi
sarl $0x18, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x112f3
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
xorl %edi, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11321
movq %rax, 0x10(%r12)
cmpl $0x2, 0x2ac(%r14)
jne 0x1148e
movq %r15, %r12
shrq $0x20, %r12
cmpl $0x2, 0x294(%r14)
jne 0x1135e
movq 0x2b20(%r14), %rdi
movzwl %r12w, %esi
callq 0x139f4
movq 0x2b20(%r14), %rdi
xorl %esi, %esi
callq 0x139f4
cmpl $0x6, 0x294(%r14)
jne 0x1148e
movq 0x2b20(%r14), %r13
movq (%r13), %rsi
movsbl %r12b, %edi
callq 0x2190
movq 0x10(%r13), %rcx
movq 0x20(%r13), %rax
incq %rax
movq %rax, 0x20(%r13)
cmpq %rax, %rcx
jae 0x11398
movq %rax, 0x10(%r13)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movq %r15, %rdi
shrq $0x10, %rdi
sarl $0x18, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x113ce
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
xorl %edi, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x113fc
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
movq %r15, %rdi
shrq $0x18, %rdi
sarl $0x18, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11432
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
sarq $0x38, %r15
movl %r15d, %edi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11465
movq %rax, 0x10(%r12)
movq 0x2b20(%r14), %r15
movq (%r15), %rsi
xorl %edi, %edi
callq 0x2190
movq 0x10(%r15), %rcx
movq 0x20(%r15), %rax
incq %rax
movq %rax, 0x20(%r15)
cmpq %rax, %rcx
jae 0x1148e
movq %rax, 0x10(%r15)
movl 0x2ac(%r14), %eax
addl %eax, %eax
cmpl %eax, 0x270(%r14)
je 0x11590
xorl %r15d, %r15d
cmpl $0x2, 0x294(%r14)
jne 0x114c2
movzwl (%rbx,%r15,4), %esi
movq 0x2b20(%r14), %rdi
callq 0x139f4
cmpl $0x6, 0x294(%r14)
jne 0x11565
movsbl (%rbx,%r15,4), %edi
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11501
movq %rax, 0x10(%r12)
movsbl 0x1(%rbx,%r15,4), %edi
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11533
movq %rax, 0x10(%r12)
movsbl 0x2(%rbx,%r15,4), %edi
movq 0x2b20(%r14), %r12
movq (%r12), %rsi
callq 0x2190
movq 0x10(%r12), %rcx
movq 0x20(%r12), %rax
incq %rax
movq %rax, 0x20(%r12)
cmpq %rax, %rcx
jae 0x11565
movq %rax, 0x10(%r12)
incq %r15
movl 0x270(%r14), %eax
movl 0x2ac(%r14), %ecx
addl %ecx, %ecx
subl %ecx, %eax
cmpq %rax, %r15
jb 0x114a7
jmp 0x11590
movl $0xa, 0x12e0(%r14)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq