// File: /workspace/github_cpp_makefile_star2_O3/NichtJens[P]lmf2txt/LMF_IO.cpp
// Function: LMF_IO::WriteFirstHeader()
void LMF_IO::WriteFirstHeader()
/////////////////////////////////////////////////////////////////
{
	if (Cobold_Header_version_output >= 2008) {
		unsigned __int32 ArchiveFlagtemp = 476759;

		ArchiveFlagtemp = ArchiveFlagtemp | DAN_SOURCE_CODE;
		ArchiveFlagtemp = ArchiveFlagtemp | DAQ_SOURCE_CODE; 
		ArchiveFlagtemp = ArchiveFlagtemp | CCF_HISTORY_CODE; 

		*output_lmf << ArchiveFlagtemp;
		*output_lmf << data_format_in_userheader_output;

		unsigned __int64 temp;
		temp = Numberofcoordinates_output;  *output_lmf << temp;
		temp = Headersize_output;			*output_lmf << temp;
		temp = User_header_size_output;		*output_lmf << temp;
		*output_lmf << uint64_number_of_written_events;
	}

	if (Cobold_Header_version_output <= 2002) {
		unsigned __int32 ArchiveFlagtemp = 476758;
		*output_lmf << ArchiveFlagtemp;
		*output_lmf << data_format_in_userheader_output;

		*output_lmf << Numberofcoordinates_output;
		*output_lmf << Headersize_output;
		*output_lmf << User_header_size_output;
		unsigned __int32 dummy = (unsigned __int32)(uint64_number_of_written_events);
		*output_lmf << dummy;
	}

	write_times(output_lmf,Starttime_output,Stoptime_output);

	Write_StdString_as_CString(*output_lmf,Versionstring);
	Write_StdString_as_CString(*output_lmf,OutputFilePathName);
	Write_StdString_as_CString(*output_lmf,Comment_output);

	if (CCFHistory_strings_output) {
		if (number_of_CCFHistory_strings_output > 0) {
			*output_lmf << number_of_CCFHistory_strings_output;
			for (__int32 i=0;i<number_of_CCFHistory_strings_output;++i) {
			unsigned __int32 unsigned_int_Dummy = (unsigned __int32)(CCFHistory_strings_output[i]->length());
				*output_lmf << unsigned_int_Dummy;					
			output_lmf->write(CCFHistory_strings_output[i]->c_str(),__int32(CCFHistory_strings_output[i]->length()));
			}
		} else *output_lmf << __int32(0);
	} else {
		number_of_CCFHistory_strings_output = 0;
		if (Cobold_Header_version >= 2008) *output_lmf << number_of_CCFHistory_strings_output;
	}

	if (DAN_source_strings_output) {
		if (number_of_DAN_source_strings_output > 0) {
			*output_lmf << number_of_DAN_source_strings_output;
			for (__int32 i=0;i<number_of_DAN_source_strings_output;++i) {
			unsigned __int32 unsigned_int_Dummy = (unsigned __int32)(DAN_source_strings_output[i]->length());
				*output_lmf << unsigned_int_Dummy;
			output_lmf->write(DAN_source_strings_output[i]->c_str(),__int32(DAN_source_strings_output[i]->length()));
			}
		} else *output_lmf << __int32(0);
	} else {
		number_of_DAN_source_strings_output = 0;
		if (Cobold_Header_version >= 2008) *output_lmf << number_of_DAN_source_strings_output;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x250(%rdi), %eax
cmpl $0x7d8, %eax            # imm = 0x7D8
jl 0x8035
movq 0x2b20(%rbx), %rdi
movl $0xe0074657, %esi       # imm = 0xE0074657
callq 0x13378
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x1365e
movslq 0x2b48(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movl 0x2b40(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movl 0x2a0(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movq 0x2b10(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x13448
movl 0x250(%rbx), %eax
cmpl $0x7d2, %eax            # imm = 0x7D2
jg 0x80a7
movq 0x2b20(%rbx), %rdi
movl $0x74656, %esi          # imm = 0x74656
callq 0x13378
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x2b48(%rbx), %esi
callq 0x1365e
movq 0x2b20(%rbx), %rdi
movl 0x2b40(%rbx), %esi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movl 0x2a0(%rbx), %esi
callq 0x13378
movl 0x2b10(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rsi
movq 0x230(%rbx), %rdx
movq 0x238(%rbx), %rcx
movq %rbx, %rdi
callq 0x237a
movq 0x2b20(%rbx), %r14
movl 0x8(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2526
movq (%rbx), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x1348c
movq 0x2b20(%rbx), %r14
movl 0x48(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2526
movq 0x40(%rbx), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x1348c
movq 0x2b20(%rbx), %r14
movl 0x88(%rbx), %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2526
movq 0x80(%rbx), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x1348c
cmpq $0x0, 0x1308(%rbx)
je 0x81a3
movl 0x12f8(%rbx), %esi
movq 0x2b20(%rbx), %rdi
testl %esi, %esi
jle 0x81c0
callq 0x1365e
cmpl $0x0, 0x12f8(%rbx)
jle 0x81c7
xorl %r14d, %r14d
movq 0x1308(%rbx), %rax
movq (%rax,%r14,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movq 0x1308(%rbx), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x1348c
incq %r14
movslq 0x12f8(%rbx), %rax
cmpq %rax, %r14
jl 0x815b
jmp 0x81c7
movl $0x0, 0x12f8(%rbx)
cmpl $0x7d8, 0x24c(%rbx)     # imm = 0x7D8
jl 0x81c7
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
callq 0x1365e
cmpq $0x0, 0x1320(%rbx)
je 0x823b
movl 0x1314(%rbx), %esi
movq 0x2b20(%rbx), %rdi
testl %esi, %esi
jle 0x8258
callq 0x1365e
cmpl $0x0, 0x1314(%rbx)
jle 0x8263
xorl %r14d, %r14d
movq 0x1320(%rbx), %rax
movq (%rax,%r14,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x13378
movq 0x2b20(%rbx), %rdi
movq 0x1320(%rbx), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x1348c
incq %r14
movslq 0x1314(%rbx), %rax
cmpq %rax, %r14
jl 0x81f3
jmp 0x8263
movl $0x0, 0x1314(%rbx)
cmpl $0x7d8, 0x24c(%rbx)     # imm = 0x7D8
jl 0x8263
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x1365e
popq %rbx
popq %r14
popq %rbp
retq