// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x7d8, 0x250(%rax)     # imm = 0x7D8
jl 0xa84a
movq -0x38(%rbp), %rax
movl $0x74657, -0xc(%rbp)    # imm = 0x74657
movl -0xc(%rbp), %ecx
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, -0xc(%rbp)
movl -0xc(%rbp), %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, -0xc(%rbp)
movl -0xc(%rbp), %ecx
orl $0x20000000, %ecx       # imm = 0x20000000
movl %ecx, -0xc(%rbp)
movq 0x2b20(%rax), %rdi
movl -0xc(%rbp), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x294(%rax), %esi
callq 0x1d170
movq -0x38(%rbp), %rax
movslq 0x2b48(%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x2b20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1cce0
movq -0x38(%rbp), %rax
movl 0x2b40(%rax), %ecx
movq %rcx, -0x18(%rbp)
movq 0x2b20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1cce0
movq -0x38(%rbp), %rax
movl 0x2a0(%rax), %ecx
movq %rcx, -0x18(%rbp)
movq 0x2b20(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1cce0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movq 0x2b10(%rax), %rsi
callq 0x1cce0
movq -0x38(%rbp), %rax
cmpl $0x7d2, 0x250(%rax)     # imm = 0x7D2
jg 0xa8ed
movq -0x38(%rbp), %rax
movl $0x74656, -0x1c(%rbp)   # imm = 0x74656
movq 0x2b20(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x294(%rax), %esi
callq 0x1d170
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x2b48(%rax), %esi
callq 0x1d170
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x2b40(%rax), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x2a0(%rax), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b10(%rax), %rcx
movl %ecx, -0x20(%rbp)
movq 0x2b20(%rax), %rdi
movl -0x20(%rbp), %esi
callq 0x1caf0
movq -0x38(%rbp), %rdi
movq 0x2b20(%rdi), %rsi
movq 0x230(%rdi), %rdx
movq 0x238(%rdi), %rcx
callq 0x2490
movq -0x38(%rbp), %rsi
movq 0x2b20(%rsi), %rdi
callq 0x2790
movq -0x38(%rbp), %rsi
movq 0x2b20(%rsi), %rdi
addq $0x40, %rsi
callq 0x2790
movq -0x38(%rbp), %rsi
movq 0x2b20(%rsi), %rdi
addq $0x80, %rsi
callq 0x2790
movq -0x38(%rbp), %rax
cmpq $0x0, 0x1308(%rax)
je 0xaa3f
movq -0x38(%rbp), %rax
cmpl $0x0, 0x12f8(%rax)
jle 0xaa2b
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x12f8(%rax), %esi
callq 0x1d170
movl $0x0, -0x24(%rbp)
movq -0x38(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x12f8(%rcx), %eax
jge 0xaa29
movq -0x38(%rbp), %rax
movq 0x1308(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x22b0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movl %ecx, -0x28(%rbp)
movq 0x2b20(%rax), %rdi
movl -0x28(%rbp), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x1308(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20b0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq 0x1308(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x22b0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl %eax, %edx
callq 0x1cd10
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa986
jmp 0xaa3d
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
xorl %esi, %esi
callq 0x1d170
jmp 0xaa71
movq -0x38(%rbp), %rax
movl $0x0, 0x12f8(%rax)
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0xaa6f
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x12f8(%rax), %esi
callq 0x1d170
jmp 0xaa71
movq -0x38(%rbp), %rax
cmpq $0x0, 0x1320(%rax)
je 0xab6a
movq -0x38(%rbp), %rax
cmpl $0x0, 0x1314(%rax)
jle 0xab56
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x1314(%rax), %esi
callq 0x1d170
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x1314(%rcx), %eax
jge 0xab54
movq -0x38(%rbp), %rax
movq 0x1320(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x22b0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movl %ecx, -0x30(%rbp)
movq 0x2b20(%rax), %rdi
movl -0x30(%rbp), %esi
callq 0x1caf0
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x1320(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20b0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq 0x1320(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x22b0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl %eax, %edx
callq 0x1cd10
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xaab1
jmp 0xab68
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
xorl %esi, %esi
callq 0x1d170
jmp 0xab9c
movq -0x38(%rbp), %rax
movl $0x0, 0x1314(%rax)
cmpl $0x7d8, 0x24c(%rax)     # imm = 0x7D8
jl 0xab9a
movq -0x38(%rbp), %rax
movq 0x2b20(%rax), %rdi
movl 0x1314(%rax), %esi
callq 0x1d170
jmp 0xab9c
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)