// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x250(%rdi), %eax
cmpl $0x7d8, %eax            # imm = 0x7D8
jl 0x6ef7
movq 0x2b20(%rbx), %rdi
movl $0xe0074657, %esi       # imm = 0xE0074657
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x11094
movslq 0x2b48(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movl 0x2b40(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movl 0x2a0(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movq 0x2b10(%rbx), %rsi
movq 0x2b20(%rbx), %rdi
callq 0x10e18
movl 0x250(%rbx), %eax
cmpl $0x7d2, %eax            # imm = 0x7D2
jg 0x6f69
movq 0x2b20(%rbx), %rdi
movl $0x74656, %esi          # imm = 0x74656
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movl 0x294(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x2b48(%rbx), %esi
callq 0x11094
movq 0x2b20(%rbx), %rdi
movl 0x2b40(%rbx), %esi
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movl 0x2a0(%rbx), %esi
callq 0x10d1e
movl 0x2b10(%rbx), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10d1e
movq 0x2b20(%rbx), %rsi
movq 0x230(%rbx), %rdx
movq 0x238(%rbx), %rcx
movq %rbx, %rdi
callq 0x238a
movq 0x2b20(%rbx), %rdi
movq %rbx, %rsi
callq 0x258d
movq 0x2b20(%rbx), %rdi
leaq 0x40(%rbx), %rsi
callq 0x258d
movq 0x2b20(%rbx), %rdi
leaq 0x80(%rbx), %rsi
callq 0x258d
cmpq $0x0, 0x1308(%rbx)
je 0x7023
movl 0x12f8(%rbx), %esi
movq 0x2b20(%rbx), %rdi
testl %esi, %esi
jle 0x703d
callq 0x11094
xorl %r14d, %r14d
movslq 0x12f8(%rbx), %rax
cmpq %rax, %r14
jge 0x7044
movq 0x1308(%rbx), %rax
movq (%rax,%r14,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movq 0x1308(%rbx), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x10e3c
incq %r14
jmp 0x6fdb
andl $0x0, 0x12f8(%rbx)
cmpl $0x7d8, 0x24c(%rbx)     # imm = 0x7D8
jl 0x7044
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
callq 0x11094
cmpq $0x0, 0x1320(%rbx)
je 0x70af
movl 0x1314(%rbx), %esi
movq 0x2b20(%rbx), %rdi
testl %esi, %esi
jle 0x70c9
callq 0x11094
xorl %r14d, %r14d
movslq 0x1314(%rbx), %rax
cmpq %rax, %r14
jge 0x70d7
movq 0x1320(%rbx), %rax
movq (%rax,%r14,8), %rax
movl 0x8(%rax), %esi
movq 0x2b20(%rbx), %rdi
callq 0x10d1e
movq 0x2b20(%rbx), %rdi
movq 0x1320(%rbx), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
callq 0x10e3c
incq %r14
jmp 0x7067
andl $0x0, 0x1314(%rbx)
cmpl $0x7d8, 0x24c(%rbx)     # imm = 0x7D8
jl 0x70d7
movq 0x2b20(%rbx), %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x11094
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop