// File: NichtJens[P]lmf2txt/lmf2txt.cpp
// Function: main
int main(int argc, char* argv[])
{
	#ifdef _DEBUG
		printf("\n***********************\n    SLOW DEBUG VERSION USED\n***********************\n");
	#endif

	printf("syntax: lmf2txt filename [-f] [-ns]\n");
	printf("        if -f is omitted then only the header\n");
	printf("        and the first 100 events will be written.\n");
	printf("        -ns converts the values to nanoseconds.\n");

	char LMF_Filename[500];

	if (argc < 2 || argc > 4)	{
		printf("wrong number of arguments.");
		return 0;
	}

	bool only_100_events_flag = true;
	bool time_conversion_flag = false;

	if (argc >= 3)	{
		if (strcmp((char*)argv[2],"-f") == 0) only_100_events_flag = false;
		if (strcmp((char*)argv[2],"-ns") == 0) time_conversion_flag = true;
		
	}
	if (argc == 4)	{
		if (strcmp((char*)argv[3],"-f") == 0) only_100_events_flag = false;
		if (strcmp((char*)argv[3],"-ns") == 0) time_conversion_flag = true;
		
	}

	strcpy(LMF_Filename,(char*)argv[1]);
	unsigned int	i,j;
	unsigned int	number_of_hits[NUM_CHANNELS];
	memset(number_of_hits,0,NUM_CHANNELS*4);
	int				iTDC[NUM_CHANNELS][NUM_IONS];
	double			dTDC[NUM_CHANNELS][NUM_IONS];

	LMF_IO * LMF = new LMF_IO(NUM_CHANNELS,NUM_IONS);

	if (!LMF->OpenInputLMF(LMF_Filename)) {
		return false;
	}

	char error_text[512];
	std::string ascii_output_filename = LMF_Filename;
	ascii_output_filename += std::string(".txt");
	FILE * ascii_outputfile_handle = fopen(ascii_output_filename.c_str(),"wt");


//	bool flag = false;

// Print parts of the header information:
// ---------------------------------------
	FPRINT"File name = %s\n",LMF->FilePathName.c_str());
	FPRINT"Versionstring = %s\n",LMF->Versionstring.c_str());
	FPRINT"Comment = %s\n",LMF->Comment.c_str());

	FPRINT"Headersize = %i\n",LMF->Headersize);

	FPRINT"Number of channels = %i\n",LMF->GetNumberOfChannels());
	FPRINT"Number of hits = %i\n",LMF->GetMaxNumberOfHits());
	FPRINT"Number of Coordinates = %i\n",LMF->Numberofcoordinates);
	
	
	FPRINT"Timestamp info = %i\n",LMF->timestamp_format);
	if (LMF->common_mode == 0) FPRINT"Common start\n"); else FPRINT"Common stop\n");
	FPRINT"Number of events = %lli\n",LMF->uint64_Numberofevents);
	FPRINT"Data format = %i\n",LMF->data_format_in_userheader);
	FPRINT"DAQ_ID = 0x%x\n",LMF->DAQ_ID);

	FPRINT"TDC resolution = %lf ns\n",LMF->tdcresolution);
	if (LMF->DAQ_ID == 0x000008 || LMF->DAQ_ID == 0x000010) {
		//FPRINT"TDC8HP Header Version %i\n",LMF->TDC8HP.UserHeaderVersion);
		FPRINT"Trigger channel = %i (counting from 1)\n",LMF->TDC8HP.TriggerChannel_p64);
		FPRINT"Trigger dead time = %lf ns\n",LMF->TDC8HP.TriggerDeadTime_p68);
		FPRINT"Group range start = %lf ns\n",LMF->TDC8HP.GroupRangeStart_p69);
		FPRINT"Group range end = %lf ns\n",LMF->TDC8HP.GroupRangeEnd_p70);
	}
	
	FPRINT"Starttime: %s",ctime(&LMF->Starttime));
	FPRINT"Stoptime:  %s",ctime(&LMF->Stoptime));
	FPRINT"\n");


//	LMF->OpenOutputLMF("test.lmf");

	double first_timestamp = 0.;
	double last_timestamp = 0.;

// Start reading event data:
// ---------------------------------------
	while(true) {
		if (LMF->ReadNextEvent())  {
			FPRINT"------- #%llu -------\n",LMF->GetEventNumber());
			double new_timestamp = LMF->GetDoubleTimeStamp();
			if (first_timestamp == 0.) first_timestamp = new_timestamp;
			new_timestamp -= first_timestamp;
			if (LMF->timestamp_format != 0) FPRINT"T  = %.3lf ns = \t%lf s\n",new_timestamp*1.e9,new_timestamp);
			if (LMF->timestamp_format != 0) FPRINT"dT = %.3lf ns = \t%lf s\n",(new_timestamp-last_timestamp)*1.e9,new_timestamp-last_timestamp);

			last_timestamp = new_timestamp;

			LMF->GetNumberOfHitsArray(number_of_hits);
			if (LMF->errorflag) {
				LMF->GetErrorText(LMF->errorflag,error_text);
				FPRINT"%s",error_text);
				return false;
			}
			if (LMF->data_format_in_userheader==5) {
				LMF->GetTDCDataArray(&dTDC[0][0]);
			} else LMF->GetTDCDataArray(&iTDC[0][0]);;

			if (LMF->errorflag) {
				LMF->GetErrorText(LMF->errorflag,error_text);
				FPRINT"%s",error_text);
				return false;
			}

			for (i=0;i<LMF->GetNumberOfChannels();i++) {
				FPRINT"chan %5i",i+1);
				FPRINT" %5i",number_of_hits[i]);
				if (LMF->data_format_in_userheader==5) {
					for (j=0;j<number_of_hits[i];j++) FPRINT" %lf",dTDC[i][j]);
				} else
					for (j=0;j<number_of_hits[i];j++) {
						if (!time_conversion_flag) FPRINT" %5i",iTDC[i][j]);
						if ( time_conversion_flag) FPRINT" %.3lf",iTDC[i][j]*LMF->tdcresolution);
					}
				FPRINT"\n");
			}
			FPRINT"Levelinfo: %llx\n",LMF->GetLastLevelInfo());
			FPRINT"\n");
		}

//		if (LMF->GetEventNumber()%50000 == 0) {
//			__int8 c;
//			while (_kbhit()) c = _getch();
//			if (c == 'q') break;
//		}

		if (LMF->errorflag) break;
		if (LMF->GetEventNumber() > 100	&& only_100_events_flag) break;
	}

	//LMF->CloseOutputLMF();


	if (LMF) delete LMF;

	fclose(ascii_outputfile_handle);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f4b0, %rsp          # imm = 0x2F4B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x2058(%rip), %rdi      # 0x1f3e8
movb $0x0, %al
callq 0x2050
leaq 0x206f(%rip), %rdi      # 0x1f40d
movb $0x0, %al
callq 0x2050
leaq 0x2090(%rip), %rdi      # 0x1f43c
movb $0x0, %al
callq 0x2050
leaq 0x20b5(%rip), %rdi      # 0x1f46f
movb $0x0, %al
callq 0x2050
cmpl $0x2, -0x8(%rbp)
jl 0x1d3cd
cmpl $0x4, -0x8(%rbp)
jle 0x1d3e7
leaq 0x20cc(%rip), %rdi      # 0x1f4a0
movb $0x0, %al
callq 0x2050
movl $0x0, -0x4(%rbp)
jmp 0x1df95
movb $0x1, -0x211(%rbp)
movb $0x0, -0x212(%rbp)
cmpl $0x3, -0x8(%rbp)
jl 0x1d43d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x20b1(%rip), %rsi      # 0x1f4bb
callq 0x2270
cmpl $0x0, %eax
jne 0x1d41b
movb $0x0, -0x211(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x2094(%rip), %rsi      # 0x1f4be
callq 0x2270
cmpl $0x0, %eax
jne 0x1d43b
movb $0x1, -0x212(%rbp)
jmp 0x1d43d
cmpl $0x4, -0x8(%rbp)
jne 0x1d485
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x2069(%rip), %rsi      # 0x1f4bb
callq 0x2270
cmpl $0x0, %eax
jne 0x1d463
movb $0x0, -0x211(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x204c(%rip), %rsi      # 0x1f4be
callq 0x2270
cmpl $0x0, %eax
jne 0x1d483
movb $0x1, -0x212(%rbp)
jmp 0x1d485
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x210(%rbp), %rdi
callq 0x2170
leaq -0x360(%rbp), %rdi
xorl %esi, %esi
movl $0x140, %edx            # imm = 0x140
callq 0x20d0
movl $0x2b80, %edi           # imm = 0x2B80
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2f400(%rbp)
movl $0x50, %esi
movl $0xc8, %edx
callq 0x27f0
jmp 0x1d4d4
movq -0x2f400(%rbp), %rax
movq %rax, -0x2f168(%rbp)
movq -0x2f168(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x4230
testb $0x1, %al
jne 0x1d52d
movl $0x0, -0x4(%rbp)
jmp 0x1df95
movq -0x2f400(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f170(%rbp)
movl %eax, -0x2f174(%rbp)
movl $0x2b80, %esi           # imm = 0x2B80
callq 0x21a0
jmp 0x1dfa1
leaq -0x2f3a1(%rbp), %rdi
movq %rdi, -0x2f408(%rbp)
callq 0x2300
movq -0x2f408(%rbp), %rdx
leaq -0x2f3a0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x1dfb0
jmp 0x1d55c
leaq -0x2f3a1(%rbp), %rdi
callq 0x21c0
leaq -0x2f3c9(%rbp), %rdi
movq %rdi, -0x2f410(%rbp)
callq 0x2300
movq -0x2f410(%rbp), %rdx
leaq 0x1f39(%rip), %rsi      # 0x1f4c2
leaq -0x2f3c8(%rbp), %rdi
callq 0x1dfb0
jmp 0x1d597
leaq -0x2f3a0(%rbp), %rdi
leaq -0x2f3c8(%rbp), %rsi
callq 0x2230
jmp 0x1d5ac
leaq -0x2f3c8(%rbp), %rdi
callq 0x20f0
leaq -0x2f3c9(%rbp), %rdi
callq 0x21c0
leaq -0x2f3a0(%rbp), %rdi
callq 0x20b0
movq %rax, %rdi
leaq 0x1eed(%rip), %rsi      # 0x1f4c7
callq 0x2200
movq %rax, -0x2f418(%rbp)
jmp 0x1d5e8
movq -0x2f418(%rbp), %rax
movq %rax, -0x2f3d8(%rbp)
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f448(%rbp)
movq -0x2f168(%rbp), %rdi
addq $0x20, %rdi
callq 0x20b0
movq -0x2f448(%rbp), %rdi
movq %rax, %rdx
leaq 0x1ea5(%rip), %rsi      # 0x1f4ca
xorl %eax, %eax
movb %al, -0x2f429(%rbp)
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f440(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x20b0
movq -0x2f440(%rbp), %rdi
movq %rax, %rdx
movb -0x2f429(%rbp), %al
leaq 0x1e77(%rip), %rsi      # 0x1f4da
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f438(%rbp)
movq -0x2f168(%rbp), %rdi
addq $0x60, %rdi
callq 0x20b0
movq -0x2f438(%rbp), %rdi
movq %rax, %rdx
movb -0x2f429(%rbp), %al
leaq 0x1e51(%rip), %rsi      # 0x1f4ee
callq 0x2280
movb -0x2f429(%rbp), %al
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rcx
movl 0x298(%rcx), %edx
leaq 0x1e39(%rip), %rsi      # 0x1f4fc
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f428(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x1a000
movl %eax, -0x2f41c(%rbp)
jmp 0x1d6ea
movl -0x2f41c(%rbp), %edx
movq -0x2f428(%rbp), %rdi
leaq 0x1e0f(%rip), %rsi      # 0x1f50d
xorl %eax, %eax
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f458(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x1a020
movl %eax, -0x2f44c(%rbp)
jmp 0x1d727
movl -0x2f44c(%rbp), %edx
movq -0x2f458(%rbp), %rdi
leaq 0x1deb(%rip), %rsi      # 0x1f526
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movl 0x270(%rax), %edx
leaq 0x1dde(%rip), %rsi      # 0x1f53b
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movl 0x2a8(%rax), %edx
leaq 0x1dd8(%rip), %rsi      # 0x1f557
movb $0x0, %al
callq 0x2280
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x1294(%rax)
jne 0x1d831
movq -0x2f3d8(%rbp), %rdi
leaq 0x1dc4(%rip), %rsi      # 0x1f56c
movb $0x0, %al
callq 0x2280
jmp 0x1d846
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f170(%rbp)
movl %eax, -0x2f174(%rbp)
leaq -0x2f3a1(%rbp), %rdi
callq 0x21c0
jmp 0x1dfa1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f170(%rbp)
movl %eax, -0x2f174(%rbp)
jmp 0x1d809
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f170(%rbp)
movl %eax, -0x2f174(%rbp)
leaq -0x2f3c8(%rbp), %rdi
callq 0x20f0
leaq -0x2f3c9(%rbp), %rdi
callq 0x21c0
jmp 0x1df87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f170(%rbp)
movl %eax, -0x2f174(%rbp)
jmp 0x1df87
movq -0x2f3d8(%rbp), %rdi
leaq 0x1d3b(%rip), %rsi      # 0x1f57a
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movq 0x268(%rax), %rdx
leaq 0x1d25(%rip), %rsi      # 0x1f587
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movl 0x290(%rax), %edx
leaq 0x1d1c(%rip), %rsi      # 0x1f5a0
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movl 0x288(%rax), %edx
leaq 0x1d0c(%rip), %rsi      # 0x1f5b2
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movsd 0x12b8(%rax), %xmm0
leaq 0x1cf7(%rip), %rsi      # 0x1f5c1
movb $0x1, %al
callq 0x2280
movq -0x2f168(%rbp), %rax
cmpl $0x8, 0x288(%rax)
je 0x1d8f5
movq -0x2f168(%rbp), %rax
cmpl $0x10, 0x288(%rax)
jne 0x1d983
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movl 0x1414(%rax), %edx
leaq 0x1cca(%rip), %rsi      # 0x1f5da
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movsd 0x1428(%rax), %xmm0
leaq 0x1cce(%rip), %rsi      # 0x1f602
movb $0x1, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movsd 0x1430(%rax), %xmm0
leaq 0x1cc6(%rip), %rsi      # 0x1f61e
movb $0x1, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movq -0x2f168(%rbp), %rax
movsd 0x1438(%rax), %xmm0
leaq 0x1cbe(%rip), %rsi      # 0x1f63a
movb $0x1, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f468(%rbp)
movq -0x2f168(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
callq 0x2090
movq -0x2f468(%rbp), %rdi
movq %rax, %rdx
leaq 0x1c9f(%rip), %rsi      # 0x1f654
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f460(%rbp)
movq -0x2f168(%rbp), %rdi
addq $0x228, %rdi            # imm = 0x228
callq 0x2090
movq -0x2f460(%rbp), %rdi
movq %rax, %rdx
leaq 0x1c74(%rip), %rsi      # 0x1f662
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
leaq 0x1bfd(%rip), %rsi      # 0x1f600
movb $0x0, %al
callq 0x2280
xorps %xmm0, %xmm0
movsd %xmm0, -0x2f3e0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x2f3e8(%rbp)
jmp 0x1da22
movq -0x2f168(%rbp), %rdi
callq 0x17050
movb %al, -0x2f469(%rbp)
jmp 0x1da36
movb -0x2f469(%rbp), %al
testb $0x1, %al
jne 0x1da45
jmp 0x1ded9
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f480(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x19fe0
movq %rax, -0x2f478(%rbp)
jmp 0x1da68
movq -0x2f478(%rbp), %rdx
movq -0x2f480(%rbp), %rdi
leaq 0x1bf3(%rip), %rsi      # 0x1f670
xorl %eax, %eax
callq 0x2280
movq -0x2f168(%rbp), %rdi
callq 0x1a040
movsd %xmm0, -0x2f488(%rbp)
jmp 0x1da9a
movsd -0x2f488(%rbp), %xmm0
movsd %xmm0, -0x2f3f0(%rbp)
movsd -0x2f3e0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1dacd
jp 0x1dacd
movsd -0x2f3f0(%rbp), %xmm0
movsd %xmm0, -0x2f3e0(%rbp)
movsd -0x2f3e0(%rbp), %xmm1
movsd -0x2f3f0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x2f3f0(%rbp)
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x2a8(%rax)
je 0x1db26
movq -0x2f3d8(%rbp), %rdi
movsd 0x18d8(%rip), %xmm0     # 0x1f3e0
mulsd -0x2f3f0(%rbp), %xmm0
movsd -0x2f3f0(%rbp), %xmm1
leaq 0x1b68(%rip), %rsi      # 0x1f687
movb $0x2, %al
callq 0x2280
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x2a8(%rax)
je 0x1db77
movq -0x2f3d8(%rbp), %rdi
movsd -0x2f3f0(%rbp), %xmm0
subsd -0x2f3e8(%rbp), %xmm0
movsd 0x188b(%rip), %xmm1     # 0x1f3e0
mulsd %xmm1, %xmm0
movsd -0x2f3f0(%rbp), %xmm1
subsd -0x2f3e8(%rbp), %xmm1
leaq 0x1b2f(%rip), %rsi      # 0x1f69f
movb $0x2, %al
callq 0x2280
movsd -0x2f3f0(%rbp), %xmm0
movsd %xmm0, -0x2f3e8(%rbp)
movq -0x2f168(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x19df0
jmp 0x1db9c
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x12e0(%rax)
je 0x1dbf9
movq -0x2f168(%rbp), %rdi
movl 0x12e0(%rdi), %esi
leaq -0x2f380(%rbp), %rdx
callq 0x19f70
jmp 0x1dbc7
movq -0x2f3d8(%rbp), %rdi
leaq -0x2f380(%rbp), %rdx
leaq 0x1a91(%rip), %rsi      # 0x1f66d
movb $0x0, %al
callq 0x2280
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2f3f4(%rbp)
jmp 0x1df79
movq -0x2f168(%rbp), %rax
cmpl $0x5, 0x290(%rax)
jne 0x1dc20
movq -0x2f168(%rbp), %rdi
leaq -0x2f160(%rbp), %rsi
callq 0x19ad0
jmp 0x1dc1e
jmp 0x1dc37
movq -0x2f168(%rbp), %rdi
leaq -0xfd60(%rbp), %rsi
callq 0x19410
jmp 0x1dc35
jmp 0x1dc37
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x12e0(%rax)
je 0x1dc94
movq -0x2f168(%rbp), %rdi
movl 0x12e0(%rdi), %esi
leaq -0x2f380(%rbp), %rdx
callq 0x19f70
jmp 0x1dc62
movq -0x2f3d8(%rbp), %rdi
leaq -0x2f380(%rbp), %rdx
leaq 0x19f6(%rip), %rsi      # 0x1f66d
movb $0x0, %al
callq 0x2280
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2f3f4(%rbp)
jmp 0x1df79
movl $0x0, -0x218(%rbp)
movl -0x218(%rbp), %eax
movl %eax, -0x2f490(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x1a000
movl %eax, -0x2f48c(%rbp)
jmp 0x1dcbe
movl -0x2f490(%rbp), %eax
movl -0x2f48c(%rbp), %ecx
cmpl %ecx, %eax
jae 0x1de85
movq -0x2f3d8(%rbp), %rdi
movl -0x218(%rbp), %edx
addl $0x1, %edx
leaq 0x19ce(%rip), %rsi      # 0x1f6b7
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
movl -0x218(%rbp), %eax
movl -0x360(%rbp,%rax,4), %edx
leaq 0x19b0(%rip), %rsi      # 0x1f6bb
movb $0x0, %al
callq 0x2280
movq -0x2f168(%rbp), %rax
cmpl $0x5, 0x290(%rax)
jne 0x1dd90
movl $0x0, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movl -0x218(%rbp), %ecx
cmpl -0x360(%rbp,%rcx,4), %eax
jae 0x1dd8b
movq -0x2f3d8(%rbp), %rdi
movl -0x218(%rbp), %eax
movl %eax, %ecx
leaq -0x2f160(%rbp), %rax
imulq $0x640, %rcx, %rcx      # imm = 0x640
addq %rcx, %rax
movl -0x21c(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm0
leaq 0x194d(%rip), %rsi      # 0x1f6c0
movb $0x1, %al
callq 0x2280
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x1dd2c
jmp 0x1de5c
movl $0x0, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movl -0x218(%rbp), %ecx
cmpl -0x360(%rbp,%rcx,4), %eax
jae 0x1de5a
testb $0x1, -0x212(%rbp)
jne 0x1ddf3
movq -0x2f3d8(%rbp), %rdi
movl -0x218(%rbp), %eax
movl %eax, %ecx
leaq -0xfd60(%rbp), %rax
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movl -0x21c(%rbp), %ecx
movl (%rax,%rcx,4), %edx
leaq 0x18cf(%rip), %rsi      # 0x1f6bb
movb $0x0, %al
callq 0x2280
testb $0x1, -0x212(%rbp)
je 0x1de44
movq -0x2f3d8(%rbp), %rdi
movl -0x218(%rbp), %eax
movl %eax, %ecx
leaq -0xfd60(%rbp), %rax
imulq $0x320, %rcx, %rcx      # imm = 0x320
addq %rcx, %rax
movl -0x21c(%rbp), %ecx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movq -0x2f168(%rbp), %rax
mulsd 0x12b8(%rax), %xmm0
leaq 0x1888(%rip), %rsi      # 0x1f6c5
movb $0x1, %al
callq 0x2280
jmp 0x1de46
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x1dd9a
jmp 0x1de5c
movq -0x2f3d8(%rbp), %rdi
leaq 0x1796(%rip), %rsi      # 0x1f600
movb $0x0, %al
callq 0x2280
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
jmp 0x1dc9e
movq -0x2f3d8(%rbp), %rax
movq %rax, -0x2f4a0(%rbp)
movq -0x2f168(%rbp), %rdi
callq 0x40e0
movq %rax, -0x2f498(%rbp)
jmp 0x1dea8
movq -0x2f498(%rbp), %rdx
movq -0x2f4a0(%rbp), %rdi
leaq 0x180f(%rip), %rsi      # 0x1f6cc
movb $0x0, %al
callq 0x2280
movq -0x2f3d8(%rbp), %rdi
leaq 0x172e(%rip), %rsi      # 0x1f600
movb $0x0, %al
callq 0x2280
movq -0x2f168(%rbp), %rax
cmpl $0x0, 0x12e0(%rax)
je 0x1deeb
jmp 0x1df1d
movq -0x2f168(%rbp), %rdi
callq 0x19fe0
movq %rax, -0x2f4a8(%rbp)
jmp 0x1df00
movq -0x2f4a8(%rbp), %rax
cmpq $0x64, %rax
jbe 0x1df18
testb $0x1, -0x211(%rbp)
je 0x1df18
jmp 0x1df1d
jmp 0x1da20
cmpq $0x0, -0x2f168(%rbp)
je 0x1df5a
movq -0x2f168(%rbp), %rax
movq %rax, -0x2f4b0(%rbp)
cmpq $0x0, %rax
je 0x1df58
movq -0x2f4b0(%rbp), %rdi
callq 0x3480
movq -0x2f4b0(%rbp), %rdi
movl $0x2b80, %esi           # imm = 0x2B80
callq 0x21a0
jmp 0x1df5a
movq -0x2f3d8(%rbp), %rdi
callq 0x2180
jmp 0x1df68
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2f3f4(%rbp)
leaq -0x2f3a0(%rbp), %rdi
callq 0x20f0
jmp 0x1df95
leaq -0x2f3a0(%rbp), %rdi
callq 0x20f0
jmp 0x1dfa1
movl -0x4(%rbp), %eax
addq $0x2f4b0, %rsp          # imm = 0x2F4B0
popq %rbp
retq
movq -0x2f170(%rbp), %rdi
callq 0x22f0
nopl (%rax)