// File: /workspace/github_c_makefile_star2_O0/Openvario[P]sensord/compdata.c
// Function: main
int main (int argc, char **argv) {

	// local variables
	int iter=300,ch,pos=0,oldpos=0,i=0;
	double pf[2][3], rmserr[2][3];
	char valstr[5]={'0','3','0','0',0};
	char goodbadstr[2][21] = {{0x1b,'[','3','2','m','G','O','O','D',0x1b,'[','0','m',0},{0x1b,'[','3','1','m','B','A','D',0x1b,'[','0','m',0,0}};
	char colors[2][6] ={{0x1b,'[','0','m',0},{0x1b,'[','3','1','m',0}};
	// signals and action handlers
	struct sigaction sigact;

	// socket communication

	// initialize variables
	static_sensor.offset = 0.0;
	static_sensor.linearity = 1.0;
	static_sensor.address = 0x76;
	static_sensor.bus = 1;

	tep_sensor.offset = 0.0;
	tep_sensor.linearity = 1.0;
	tep_sensor.Pcomp2 = static_sensor.Pcomp2 = -0.0000004638;
	tep_sensor.Pcomp1 = static_sensor.Pcomp1 =  0.9514328801;
	tep_sensor.Pcomp0 = static_sensor.Pcomp0 =  0.1658634996;
	tep_sensor.address = 0x77;
	tep_sensor.bus = 1;

	config.timing_log  = 0.06666666666;
	config.timing_mult = 50;
	config.timing_off  = 12;

	//parse command line arguments
	cmdline_parser(argc, argv, &io_mode);

	// get config file options
	if (fp_config != NULL) {
		cfgfile_parser(fp_config, &static_sensor, &tep_sensor, &dynamic_sensor, &voltage_sensor, &temp_sensor, &config);
		fclose(fp_config);
	}

	// check if we are a daemon or stay in foreground
	// stay in foreground
	// install signal handler for CTRL-C
	sigact.sa_handler = sigintHandler;
	sigemptyset (&sigact.sa_mask);
	sigact.sa_flags = 0;
	sigaction(SIGINT, &sigact, NULL);

	// open console again, but as file_pointer
	setbuf(stderr, NULL);

	// ignore SIGPIPE
	signal(SIGPIPE, SIG_IGN);
	// we need hardware sensors for running !!
	// open sensor for static pressure
	/// @todo remove hardcoded i2c address static pressure

	struct termios tio, tio2;

	tcgetattr( 0, &tio );
	tcgetattr( 0, &tio2 );
	tio.c_lflag &= (~ICANON & ~ECHO);
	tcsetattr( 0, TCSANOW, &tio );

	printf ("This program calculates compensation data to compensate for timing glitches on the static and tek sensors.\nThe pressure sensors are sensitive to air movement.\nFor best results, ensure the air is as still as possible when taking measurements.\nHow many thousand data points? %s\033[4D",valstr);
	do {
		ch=getc(stdin);
		if (ch==0x1b)
			if (getc(stdin)==0x5b)
				ch=getc(stdin)+256;
		if ((ch==0x143) && (pos<3)) pos++;
		if ((ch==0x144) && (pos>0)) pos--;
		if (ch==0x141)
			switch (pos) {
				case 0: iter+=1000;
					break;
				case 1: iter+=100;
					break;
				case 2: iter+=10;
					break;
				case 3: iter+=1;
					break;
			}
		if (ch==0x142)
			switch (pos) {
				case 0: iter-=1000;
					break;
				case 1: iter-=100;
					break;
				case 2: iter-=10;
					break;
				case 3: iter-=1;
					break;
			}
		if ((ch>='0') && (ch<='9')) {
			valstr[pos]=ch;
			sscanf (valstr,"%d",&iter);
		}
		if (iter<1) iter=1;
		if (iter>1000) iter=1000;
		sprintf (valstr,"%04d",iter);
		for (i=0;i<oldpos;++i) printf ("\033[1D");
		printf ("%s",valstr);
		for (i=0;i<(4-pos);++i) printf("\033[1D");
		oldpos=pos;
	} while (ch!=0xa);
	printf ("\033[1C\n");
	if (iter>1000) iter=1000;
	iter*=1000;
	printf ("Collecting %d data points.\n",iter);

	tcgetattr( 0, &tio );
	tio.c_lflag |= ICANON | ECHO;
	tcsetattr( 0, TCSANOW, &tio );

	if (ms5611_open(&static_sensor) != 0)
	{
		fprintf(stderr, "Open static sensor failed !!\n");
		return 1;
	}

	//initialize static pressure sensor
	ms5611_reset(&static_sensor);
	usleep(10000);
	ms5611_init(&static_sensor);
	static_sensor.secordcomp = g_secordcomp;
	static_sensor.valid = 1;

	// open sensor for velocity pressure
	if (ms5611_open(&tep_sensor) != 0)
	{
		fprintf(stderr, "Open tep sensor failed !!\n");
		return 1;
	}

	//initialize tep pressure sensor
	ms5611_reset(&tep_sensor);

	usleep(10000);
	ms5611_init(&tep_sensor);
	tep_sensor.secordcomp = g_secordcomp;
	tep_sensor.valid = 1;

	// poll sensors for offset compensation
	tep_sensor.D2f=static_sensor.D2f=0;
	for (i=0;i<120;++i)
	{
		ms5611_start_temp(&static_sensor);
		ms5611_start_temp(&tep_sensor);
		if (i==0) sensor_wait_mark();
		sensor_wait(12500);
		sensor_wait_mark();
		ms5611_read_temp(&static_sensor,0);
		ms5611_read_temp(&tep_sensor,0);
	}

	ms5611_start_pressure(&static_sensor);
	ms5611_start_temp(&tep_sensor);
	sensor_wait(12500);
	sensor_wait_mark();

	ms5611_read_pressure(&static_sensor);
	ms5611_read_temp(&tep_sensor,0);
	ms5611_start_pressure(&tep_sensor);
	ms5611_start_temp(&static_sensor);
	sensor_wait(12500);
	sensor_wait_mark();

	ms5611_read_pressure(&tep_sensor);
	ms5611_read_temp(&static_sensor,0);
	ms5611_calculate_pressure(&tep_sensor);
	ms5611_calculate_pressure(&static_sensor);
	ms5611_start_temp(&tep_sensor);
	ms5611_start_pressure(&static_sensor);
	for (i=0;i<1000;++i)
		pressure_measurement_handler(0);
	// main data acquisition loop

	for (i=0;sidx<iter;)
	{
		if (noglitch>29) sensor_wait(250e3);
		pressure_measurement_handler(1);
		if ((sidx%1000)==0) {
			if (i==0) {
				printf ("%d points collected.\n",sidx);
				i=1;
			}
		} else i=0;
	}
	if (fp_datalog!=NULL) fclose(fp_datalog);
	fp_config  = fopen (config_filename,"a+");

	polyfit (statval, sidx, &pf[0][0],&rmserr[0][0]);
	polyfit (tepval, tidx, &pf[1][0],&rmserr[1][0]);
	pos=0;
	printf ("Total data points (the more the better): static: %d, tek: %d\n",sidx, tidx);
	if (rmserr[0][2]>=80) i=3; else i=0;
	if (rmserr[1][2]>=80) i|=5;
	printf ("%s\tTotal RMS Error (lower is better, ideally below 80): static: %s%f%s, tek: %s%f%s\n",goodbadstr[i&1],colors[(i>>1)&1],rmserr[0][2],colors[0],colors[(i>>2)&1],rmserr[1][2],colors[0]);
	pos|=i;
	if (rmserr[0][0]>=1e-3) i=3; else i=0;
	if (rmserr[1][0]>=1e-3) i|=5;
	printf ("%s\tMean Error (This should be very close to zero): static %s%f%s, tek: %s%f%s\n",goodbadstr[i&1],colors[(i>>1)&1],rmserr[0][0],colors[0],colors[(i>>2)&1],rmserr[1][0],colors[0]);
	pos|=i;
	if (rmserr[0][1]>=80) i=3; else i=0;
	if (rmserr[1][1]>=80) i|=5;
	printf ("%s\tStd Deviation of Error (should be RMS error or slightly less): static: %s%f%s, tek: %s%f%s\n",goodbadstr[i&1],colors[(i>>1)&1],rmserr[0][1],colors[0],colors[(i>>2)&1],rmserr[1][1],colors[0]);
	pos|=i;
	if (urun>0) i=3; else i=0;
	if (orun>0) i|=5;
	if (i) printf ("%s\tGlitches (zero is ideal), Underrun: %s%d%s, Overrun: %s%d%s\n",goodbadstr[1],colors[(i>>1)&1],urun,colors[0],colors[(i>>2)&1],orun,colors[0]);
	else printf ("%s\tNo overruns/underruns errors found during glitches.\n",goodbadstr[0]);
	pos|=i;
	printf ("static_comp %.10lf %.10lf %.10lf\ntek_comp %.10lf %.10lf %.10lf\n",pf[0][0],pf[0][1],pf[0][2],pf[1][0],pf[1][1],pf[1][2]);
	printf ("Empirical testing seems to show: \n");
	if ((2.5e-6<pf[0][0]) || (pf[0][0]<-2.5e-6)) i=3; else i=0;
	if ((2.5e-6<pf[1][0]) || (pf[1][0]<-2.5e-6)) i|=5;
	printf ("%s\t2.5e-6 > quadrature term (%s%4.3e%s and %s%4.3e%s) > -2.5e-6\n",goodbadstr[i&1],colors[(i>>1)&1],pf[0][0],colors[0],colors[(i>>2)&1],pf[1][0],colors[0]);
	pos|=i;
	if ((-.20<pf[0][1]) || (pf[0][1]<-0.35)) i=3; else i=0;
	if ((-.20<pf[1][1]) || (pf[1][1]<-0.35)) i|=5;
	printf ("%s\t-0.20 > linear term (%s%6.5f%s and %s%6.5f%s) > -0.35\n",goodbadstr[i&1],colors[(i>>1)&1],pf[0][1],colors[0],colors[(i>>2)&1],pf[1][1],colors[0]);
	pos|=i;
	if ((0<pf[0][2]) || (pf[0][2]<-50)) i=3; else i=0;
	if ((0<pf[1][2]) || (pf[1][2]<-50)) i|=5;
	printf ("%s\t0 > constant term (%s%6.5f%s and %s%6.5f%s) > -50\n",goodbadstr[i&1],colors[(i>>1)&1],pf[0][2],colors[0],colors[(i>>2)&1],pf[1][2],colors[0]);
	pos=(pos|i)&1;
	if (pos)
		printf ("These results could be better.  Suggest trying again.\n");
	else
		printf ("These results are good.\n");
	if (fp_config!=NULL) {
		tcgetattr( 0, &tio );
		tio.c_lflag &= (~ICANON & ~ECHO);
		tcsetattr( 0, TCSANOW, &tio );
		if (pos) strcpy(valstr,"no "); else strcpy(valstr,"yes");
		printf ("Do you wish to save results? %s\033[3D",valstr);
		do {
			ch=getc(stdin);
			if (ch==0x1b)
				if (getc(stdin)==0x5b)
					ch=getc(stdin)+256;
			switch (ch) {
				case 0x141 : case 0x142 : case 0x143 : case 0x144 : pos ^=1; break;
				case 'n' : case 'N' : pos = 1; ch = 0xa; break;
				case 'y' : case 'Y' : pos = 0; ch = 0xa; break;
				default : break;
			}
			if (pos) strcpy(valstr,"no "); else strcpy(valstr,"yes");
			if (ch==0xa) printf ("%s\n",valstr); else  printf ("%s\033[3D",valstr);
		} while (ch!=0xa);
		tcgetattr( 0, &tio );
		tio.c_lflag |= ICANON | ECHO;
		tcsetattr( 0, TCSANOW, &tio );

		if (pos==0) {
			printf ("Saving...\n");
			fprintf(fp_config,"\nstatic_comp %.10lf %.10lf %.10lf\ntek_comp %.10lf %.10lf %.10lf\n",pf[0][0],pf[0][1],pf[0][2],pf[1][0],pf[1][1],pf[1][2]);
		}
		fclose (fp_config);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x12c, -0x14(%rbp)     # imm = 0x12C
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl 0x40bb(%rip), %eax      # 0x64b6
movl %eax, -0x95(%rbp)
movb 0x40b3(%rip), %al       # 0x64ba
movb %al, -0x91(%rbp)
leaq -0xc0(%rbp), %rdi
leaq 0x4065(%rip), %rsi      # 0x6480
movl $0x2a, %edx
callq 0x1180
movq 0x407e(%rip), %rax      # 0x64aa
movq %rax, -0xcc(%rbp)
movl 0x4079(%rip), %eax      # 0x64b2
movl %eax, -0xc4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, 0x6db6(%rip)     # 0x9200
movss 0x3ffe(%rip), %xmm0     # 0x6450
movss %xmm0, 0x6da2(%rip)     # 0x91fc
movb $0x76, 0x6d13(%rip)     # 0x9174
movb $0x1, 0x6d0d(%rip)      # 0x9175
xorps %xmm0, %xmm0
movss %xmm0, 0x6e2d(%rip)     # 0x92a0
movss 0x3fd5(%rip), %xmm0     # 0x6450
movss %xmm0, 0x6e19(%rip)     # 0x929c
movsd 0x3f75(%rip), %xmm0     # 0x6400
movsd %xmm0, 0x6d35(%rip)     # 0x91c8
movsd 0x3f65(%rip), %xmm0     # 0x6400
movsd %xmm0, 0x6dc5(%rip)     # 0x9268
movsd 0x3f4d(%rip), %xmm0     # 0x63f8
movsd %xmm0, 0x6d1d(%rip)     # 0x91d0
movsd 0x3f3d(%rip), %xmm0     # 0x63f8
movsd %xmm0, 0x6dad(%rip)     # 0x9270
movsd 0x3f25(%rip), %xmm0     # 0x63f0
movsd %xmm0, 0x6d05(%rip)     # 0x91d8
movsd 0x3f15(%rip), %xmm0     # 0x63f0
movsd %xmm0, 0x6d95(%rip)     # 0x9278
movb $0x77, 0x6d2a(%rip)     # 0x9214
movb $0x1, 0x6d24(%rip)      # 0x9215
movsd 0x3eef(%rip), %xmm0     # 0x63e8
movsd %xmm0, 0x6dbf(%rip)     # 0x92c0
movsd 0x3ed7(%rip), %xmm0     # 0x63e0
movsd %xmm0, 0x6db7(%rip)     # 0x92c8
movsd 0x3ebf(%rip), %xmm0     # 0x63d8
movsd %xmm0, 0x6daf(%rip)     # 0x92d0
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x6da9(%rip), %rdx      # 0x92d8
callq 0x44d0
leaq 0x3006e7d(%rip), %rax   # 0x30093b8
cmpq $0x0, (%rax)
je 0x258d
leaq 0x3006e70(%rip), %rax   # 0x30093b8
movq (%rax), %rdi
leaq 0x6c1e(%rip), %rsi      # 0x9170
leaq 0x6cb7(%rip), %rdx      # 0x9210
leaq 0x6d7c(%rip), %rcx      # 0x92dc
leaq 0x6d9d(%rip), %r8       # 0x9304
leaq 0x6db2(%rip), %r9       # 0x9320
leaq 0x6d3b(%rip), %rax      # 0x92b0
movq %rax, (%rsp)
callq 0x4960
leaq 0x3006e33(%rip), %rax   # 0x30093b8
movq (%rax), %rdi
callq 0x10a0
leaq 0xe7c(%rip), %rax       # 0x3410
movq %rax, -0x168(%rbp)
leaq -0x168(%rbp), %rdi
addq $0x8, %rdi
callq 0x1160
movl $0x0, -0xe0(%rbp)
movl $0x2, %edi
leaq -0x168(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1070
movq 0x6a27(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10b0
movl $0xd, %edi
movl $0x1, %esi
callq 0x1140
xorl %edi, %edi
leaq -0x1a4(%rbp), %rsi
callq 0x11a0
xorl %edi, %edi
leaq -0x1e0(%rbp), %rsi
callq 0x11a0
movl -0x198(%rbp), %eax
andl $-0xb, %eax
movl %eax, -0x198(%rbp)
xorl %esi, %esi
leaq -0x1a4(%rbp), %rdx
movl %esi, %edi
callq 0x11b0
leaq -0x95(%rbp), %rsi
leaq 0x3e86(%rip), %rdi      # 0x64bb
movb $0x0, %al
callq 0x10c0
movq 0x6985(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
movl %eax, -0x18(%rbp)
cmpl $0x1b, -0x18(%rbp)
jne 0x2681
movq 0x696d(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
cmpl $0x5b, %eax
jne 0x267f
movq 0x6959(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x18(%rbp)
jmp 0x2681
cmpl $0x143, -0x18(%rbp)     # imm = 0x143
jne 0x2699
cmpl $0x3, -0x1c(%rbp)
jge 0x2699
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x144, -0x18(%rbp)     # imm = 0x144
jne 0x26b1
cmpl $0x0, -0x1c(%rbp)
jle 0x26b1
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x141, -0x18(%rbp)     # imm = 0x141
jne 0x270f
movl -0x1c(%rbp), %eax
movq %rax, -0x1e8(%rbp)
subq $0x3, %rax
ja 0x270d
movq -0x1e8(%rbp), %rax
leaq 0x3d88(%rip), %rcx      # 0x6460
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
addl $0x3e8, %eax            # imm = 0x3E8
movl %eax, -0x14(%rbp)
jmp 0x270d
movl -0x14(%rbp), %eax
addl $0x64, %eax
movl %eax, -0x14(%rbp)
jmp 0x270d
movl -0x14(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x14(%rbp)
jmp 0x270d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x270f
cmpl $0x142, -0x18(%rbp)     # imm = 0x142
jne 0x276d
movl -0x1c(%rbp), %eax
movq %rax, -0x1f0(%rbp)
subq $0x3, %rax
ja 0x276b
movq -0x1f0(%rbp), %rax
leaq 0x3d3a(%rip), %rcx      # 0x6470
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
subl $0x3e8, %eax            # imm = 0x3E8
movl %eax, -0x14(%rbp)
jmp 0x276b
movl -0x14(%rbp), %eax
subl $0x64, %eax
movl %eax, -0x14(%rbp)
jmp 0x276b
movl -0x14(%rbp), %eax
subl $0xa, %eax
movl %eax, -0x14(%rbp)
jmp 0x276b
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x276d
cmpl $0x30, -0x18(%rbp)
jl 0x27a2
cmpl $0x39, -0x18(%rbp)
jg 0x27a2
movl -0x18(%rbp), %eax
movb %al, %cl
movslq -0x1c(%rbp), %rax
movb %cl, -0x95(%rbp,%rax)
leaq -0x95(%rbp), %rdi
leaq 0x497d(%rip), %rsi      # 0x7114
leaq -0x14(%rbp), %rdx
movb $0x0, %al
callq 0x1190
cmpl $0x1, -0x14(%rbp)
jge 0x27af
movl $0x1, -0x14(%rbp)
cmpl $0x3e8, -0x14(%rbp)     # imm = 0x3E8
jle 0x27bf
movl $0x3e8, -0x14(%rbp)     # imm = 0x3E8
leaq -0x95(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq 0x3e03(%rip), %rsi      # 0x65d3
movb $0x0, %al
callq 0x1200
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x27ff
leaq 0x3deb(%rip), %rdi      # 0x65d8
movb $0x0, %al
callq 0x10c0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x27de
leaq -0x95(%rbp), %rsi
leaq 0x4732(%rip), %rdi      # 0x6f3f
movb $0x0, %al
callq 0x10c0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl $0x4, %ecx
subl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2843
leaq 0x3da7(%rip), %rdi      # 0x65d8
movb $0x0, %al
callq 0x10c0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x281b
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0xa, -0x18(%rbp)
jne 0x263c
leaq 0x3d83(%rip), %rdi      # 0x65dd
movb $0x0, %al
callq 0x10c0
cmpl $0x3e8, -0x14(%rbp)     # imm = 0x3E8
jle 0x2871
movl $0x3e8, -0x14(%rbp)     # imm = 0x3E8
imull $0x3e8, -0x14(%rbp), %eax # imm = 0x3E8
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3d5e(%rip), %rdi      # 0x65e3
movb $0x0, %al
callq 0x10c0
xorl %edi, %edi
leaq -0x1a4(%rbp), %rsi
callq 0x11a0
movl -0x198(%rbp), %eax
orl $0xa, %eax
movl %eax, -0x198(%rbp)
xorl %esi, %esi
leaq -0x1a4(%rbp), %rdx
movl %esi, %edi
callq 0x11b0
leaq 0x68b0(%rip), %rdi      # 0x9170
callq 0x1530
cmpl $0x0, %eax
je 0x28ee
movq 0x6727(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x3d24(%rip), %rsi      # 0x65ff
movb $0x0, %al
callq 0x1150
movl $0x1, -0x4(%rbp)
jmp 0x33f9
leaq 0x687b(%rip), %rdi      # 0x9170
callq 0x1b70
movl $0x2710, %edi           # imm = 0x2710
callq 0x1260
leaq 0x6865(%rip), %rdi      # 0x9170
callq 0x17a0
leaq 0x3006a8b(%rip), %rax   # 0x30093a2
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x68e4(%rip)      # 0x9208
movl $0x1, 0x68d6(%rip)      # 0x9204
leaq 0x68db(%rip), %rdi      # 0x9210
callq 0x1530
cmpl $0x0, %eax
je 0x2963
movq 0x66b2(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x3ccd(%rip), %rsi      # 0x661d
movb $0x0, %al
callq 0x1150
movl $0x1, -0x4(%rbp)
jmp 0x33f9
leaq 0x68a6(%rip), %rdi      # 0x9210
callq 0x1b70
movl $0x2710, %edi           # imm = 0x2710
callq 0x1260
leaq 0x6890(%rip), %rdi      # 0x9210
callq 0x17a0
leaq 0x3006a16(%rip), %rax   # 0x30093a2
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x690f(%rip)      # 0x92a8
movl $0x1, 0x6901(%rip)      # 0x92a4
movl $0x0, 0x67f3(%rip)      # 0x91a0
movl $0x0, 0x6889(%rip)      # 0x9240
movl $0x0, -0x24(%rbp)
cmpl $0x78, -0x24(%rbp)
jge 0x2a20
leaq 0x67a5(%rip), %rdi      # 0x9170
callq 0x1bf0
leaq 0x6839(%rip), %rdi      # 0x9210
callq 0x1bf0
cmpl $0x0, -0x24(%rbp)
jne 0x29e7
callq 0x1370
movss 0x3a65(%rip), %xmm0     # 0x6454
callq 0x1390
callq 0x1370
leaq 0x6770(%rip), %rdi      # 0x9170
xorl %esi, %esi
callq 0x1cf0
leaq 0x6802(%rip), %rdi      # 0x9210
xorl %esi, %esi
callq 0x1cf0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x29be
leaq 0x6749(%rip), %rdi      # 0x9170
callq 0x1c70
leaq 0x67dd(%rip), %rdi      # 0x9210
callq 0x1bf0
movss 0x3a14(%rip), %xmm0     # 0x6454
callq 0x1390
callq 0x1370
leaq 0x671f(%rip), %rdi      # 0x9170
callq 0x2100
leaq 0x67b3(%rip), %rdi      # 0x9210
xorl %esi, %esi
callq 0x1cf0
leaq 0x67a5(%rip), %rdi      # 0x9210
callq 0x1c70
leaq 0x66f9(%rip), %rdi      # 0x9170
callq 0x1bf0
movss 0x39d0(%rip), %xmm0     # 0x6454
callq 0x1390
callq 0x1370
leaq 0x677b(%rip), %rdi      # 0x9210
callq 0x2100
leaq 0x66cf(%rip), %rdi      # 0x9170
xorl %esi, %esi
callq 0x1cf0
leaq 0x6761(%rip), %rdi      # 0x9210
callq 0x21e0
leaq 0x66b5(%rip), %rdi      # 0x9170
callq 0x21e0
leaq 0x6749(%rip), %rdi      # 0x9210
callq 0x1bf0
leaq 0x669d(%rip), %rdi      # 0x9170
callq 0x1c70
movl $0x0, -0x24(%rbp)
cmpl $0x3e8, -0x24(%rbp)     # imm = 0x3E8
jge 0x2afa
xorl %edi, %edi
callq 0x3470
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2adf
movl $0x0, -0x24(%rbp)
movl 0x6871(%rip), %eax      # 0x9378
cmpl -0x14(%rbp), %eax
jge 0x2b6b
cmpl $0x1d, 0x6869(%rip)     # 0x937c
jle 0x2b22
movss 0x393b(%rip), %xmm0     # 0x6458
callq 0x1390
movl $0x1, %edi
callq 0x3470
movl 0x6846(%rip), %eax      # 0x9378
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2b62
cmpl $0x0, -0x24(%rbp)
jne 0x2b60
movl 0x682d(%rip), %esi      # 0x9378
leaq 0x3ae6(%rip), %rdi      # 0x6638
movb $0x0, %al
callq 0x10c0
movl $0x1, -0x24(%rbp)
jmp 0x2b69
movl $0x0, -0x24(%rbp)
jmp 0x2b01
leaq 0x300683e(%rip), %rax   # 0x30093b0
cmpq $0x0, (%rax)
je 0x2b87
leaq 0x3006831(%rip), %rax   # 0x30093b0
movq (%rax), %rdi
callq 0x10a0
leaq 0x3006832(%rip), %rdi   # 0x30093c0
leaq 0x3ab9(%rip), %rsi      # 0x664e
callq 0x11d0
movq %rax, %rcx
leaq 0x3006814(%rip), %rax   # 0x30093b8
movq %rcx, (%rax)
movl 0x67cb(%rip), %esi      # 0x9378
leaq -0x60(%rbp), %rdx
leaq -0x90(%rbp), %rcx
leaq 0x67c1(%rip), %rdi      # 0x9380
callq 0x3cf0
movl 0x30067b6(%rip), %esi   # 0x3009380
leaq -0x60(%rbp), %rdx
addq $0x18, %rdx
leaq -0x90(%rbp), %rcx
addq $0x18, %rcx
leaq 0x180679c(%rip), %rdi   # 0x1809380
callq 0x3cf0
movl $0x0, -0x1c(%rbp)
movl 0x6782(%rip), %esi      # 0x9378
movl 0x3006784(%rip), %edx   # 0x3009380
leaq 0x3a4e(%rip), %rdi      # 0x6651
movb $0x0, %al
callq 0x10c0
movsd -0x80(%rbp), %xmm0
movsd 0x37f1(%rip), %xmm1     # 0x6408
ucomisd %xmm1, %xmm0
jb 0x2c26
movl $0x3, -0x24(%rbp)
jmp 0x2c2d
movl $0x0, -0x24(%rbp)
movsd -0x68(%rbp), %xmm0
movsd 0x37ce(%rip), %xmm1     # 0x6408
ucomisd %xmm1, %xmm0
jb 0x2c49
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x80(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x68(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x39e0(%rip), %rdi      # 0x668f
movb $0x2, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x90(%rbp), %xmm0
movsd 0x3741(%rip), %xmm1     # 0x6410
ucomisd %xmm1, %xmm0
jb 0x2cde
movl $0x3, -0x24(%rbp)
jmp 0x2ce5
movl $0x0, -0x24(%rbp)
movsd -0x78(%rbp), %xmm0
movsd 0x371e(%rip), %xmm1     # 0x6410
ucomisd %xmm1, %xmm0
jb 0x2d01
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x90(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x78(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x397a(%rip), %rdi      # 0x66e4
movb $0x2, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x88(%rbp), %xmm0
movsd 0x367e(%rip), %xmm1     # 0x6408
ucomisd %xmm1, %xmm0
jb 0x2d99
movl $0x3, -0x24(%rbp)
jmp 0x2da0
movl $0x0, -0x24(%rbp)
movsd -0x70(%rbp), %xmm0
movsd 0x365b(%rip), %xmm1     # 0x6408
ucomisd %xmm1, %xmm0
jb 0x2dbc
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x88(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x70(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x390e(%rip), %rdi      # 0x6733
movb $0x2, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, 0x3006548(%rip)   # 0x3009384
jle 0x2e47
movl $0x3, -0x24(%rbp)
jmp 0x2e4e
movl $0x0, -0x24(%rbp)
cmpl $0x0, 0x3006533(%rip)   # 0x3009388
jle 0x2e60
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x2ed6
leaq -0xc0(%rbp), %rsi
addq $0x15, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movl 0x30064f5(%rip), %ecx   # 0x3009384
leaq -0xcc(%rbp), %r8
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r9
imulq $0x6, %rax, %rax
addq %rax, %r9
movl 0x30064d2(%rip), %r10d  # 0x3009388
leaq -0xcc(%rbp), %rax
leaq 0x38ce(%rip), %rdi      # 0x6792
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x10c0
jmp 0x2eeb
leaq -0xc0(%rbp), %rsi
leaq 0x38ee(%rip), %rdi      # 0x67d2
movb $0x0, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movsd -0x40(%rbp), %xmm4
movsd -0x38(%rbp), %xmm5
leaq 0x3a4d(%rip), %rdi      # 0x6966
movb $0x6, %al
callq 0x10c0
leaq 0x38e3(%rip), %rdi      # 0x680a
movb $0x0, %al
callq 0x10c0
movsd -0x60(%rbp), %xmm0
movsd 0x34dd(%rip), %xmm1     # 0x6418
ucomisd %xmm1, %xmm0
ja 0x2f50
movsd 0x34d7(%rip), %xmm0     # 0x6420
ucomisd -0x60(%rbp), %xmm0
jbe 0x2f59
movl $0x3, -0x24(%rbp)
jmp 0x2f60
movl $0x0, -0x24(%rbp)
movsd -0x48(%rbp), %xmm0
movsd 0x34ab(%rip), %xmm1     # 0x6418
ucomisd %xmm1, %xmm0
ja 0x2f82
movsd 0x34a5(%rip), %xmm0     # 0x6420
ucomisd -0x48(%rbp), %xmm0
jbe 0x2f8b
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x60(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x48(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x383c(%rip), %rdi      # 0x682d
movb $0x2, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x341a(%rip), %xmm1     # 0x6428
ucomisd %xmm1, %xmm0
ja 0x3023
movsd 0x3414(%rip), %xmm0     # 0x6430
ucomisd -0x58(%rbp), %xmm0
jbe 0x302c
movl $0x3, -0x24(%rbp)
jmp 0x3033
movl $0x0, -0x24(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0x33e8(%rip), %xmm1     # 0x6428
ucomisd %xmm1, %xmm0
ja 0x3055
movsd 0x33e2(%rip), %xmm0     # 0x6430
ucomisd -0x40(%rbp), %xmm0
jbe 0x305e
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x58(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x40(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x37aa(%rip), %rdi      # 0x686e
movb $0x2, %al
callq 0x10c0
movl -0x24(%rbp), %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x30f1
movsd 0x334e(%rip), %xmm0     # 0x6438
ucomisd -0x50(%rbp), %xmm0
jbe 0x30fa
movl $0x3, -0x24(%rbp)
jmp 0x3101
movl $0x0, -0x24(%rbp)
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x311e
movsd 0x3321(%rip), %xmm0     # 0x6438
ucomisd -0x38(%rbp), %xmm0
jbe 0x3127
movl -0x24(%rbp), %eax
orl $0x5, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cltq
leaq -0xc0(%rbp), %rsi
imulq $0x15, %rax, %rax
addq %rax, %rsi
movl -0x24(%rbp), %eax
sarl %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %rdx
imulq $0x6, %rax, %rax
addq %rax, %rdx
movsd -0x50(%rbp), %xmm0
leaq -0xcc(%rbp), %rcx
movl -0x24(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cltq
leaq -0xcc(%rbp), %r8
imulq $0x6, %rax, %rax
addq %rax, %r8
movsd -0x38(%rbp), %xmm1
leaq -0xcc(%rbp), %r9
leaq 0x371b(%rip), %rdi      # 0x68a8
movb $0x2, %al
callq 0x10c0
movl -0x1c(%rbp), %eax
orl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x31b6
leaq 0x3731(%rip), %rdi      # 0x68de
movb $0x0, %al
callq 0x10c0
jmp 0x31c4
leaq 0x3758(%rip), %rdi      # 0x6915
movb $0x0, %al
callq 0x10c0
leaq 0x30061ed(%rip), %rax   # 0x30093b8
cmpq $0x0, (%rax)
je 0x33f2
xorl %edi, %edi
leaq -0x1a4(%rbp), %rsi
callq 0x11a0
movl -0x198(%rbp), %eax
andl $-0xb, %eax
movl %eax, -0x198(%rbp)
xorl %esi, %esi
leaq -0x1a4(%rbp), %rdx
movl %esi, %edi
callq 0x11b0
cmpl $0x0, -0x1c(%rbp)
je 0x321d
leaq -0x95(%rbp), %rdi
leaq 0x3718(%rip), %rsi      # 0x692e
callq 0x1050
jmp 0x3230
leaq -0x95(%rbp), %rdi
leaq 0x3707(%rip), %rsi      # 0x6932
callq 0x1050
leaq -0x95(%rbp), %rsi
leaq 0x36f8(%rip), %rdi      # 0x6936
movb $0x0, %al
callq 0x10c0
movq 0x5d7c(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
movl %eax, -0x18(%rbp)
cmpl $0x1b, -0x18(%rbp)
jne 0x328a
movq 0x5d64(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
cmpl $0x5b, %eax
jne 0x3288
movq 0x5d50(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x1250
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x18(%rbp)
jmp 0x328a
movl -0x18(%rbp), %eax
movl %eax, -0x1f4(%rbp)
subl $0x4e, %eax
je 0x32de
jmp 0x329a
movl -0x1f4(%rbp), %eax
subl $0x59, %eax
je 0x32ee
jmp 0x32a7
movl -0x1f4(%rbp), %eax
subl $0x6e, %eax
je 0x32de
jmp 0x32b4
movl -0x1f4(%rbp), %eax
subl $0x79, %eax
je 0x32ee
jmp 0x32c1
movl -0x1f4(%rbp), %eax
addl $0xfffffebf, %eax       # imm = 0xFFFFFEBF
subl $0x3, %eax
ja 0x32fe
jmp 0x32d3
movl -0x1c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3300
movl $0x1, -0x1c(%rbp)
movl $0xa, -0x18(%rbp)
jmp 0x3300
movl $0x0, -0x1c(%rbp)
movl $0xa, -0x18(%rbp)
jmp 0x3300
jmp 0x3300
cmpl $0x0, -0x1c(%rbp)
je 0x331b
leaq -0x95(%rbp), %rdi
leaq 0x361a(%rip), %rsi      # 0x692e
callq 0x1050
jmp 0x332e
leaq -0x95(%rbp), %rdi
leaq 0x3609(%rip), %rsi      # 0x6932
callq 0x1050
cmpl $0xa, -0x18(%rbp)
jne 0x334b
leaq -0x95(%rbp), %rsi
leaq 0x3ad8(%rip), %rdi      # 0x6e1a
movb $0x0, %al
callq 0x10c0
jmp 0x3360
leaq -0x95(%rbp), %rsi
leaq 0x35fa(%rip), %rdi      # 0x6953
movb $0x0, %al
callq 0x10c0
jmp 0x3362
cmpl $0xa, -0x18(%rbp)
jne 0x3245
xorl %edi, %edi
leaq -0x1a4(%rbp), %rsi
callq 0x11a0
movl -0x198(%rbp), %eax
orl $0xa, %eax
movl %eax, -0x198(%rbp)
xorl %esi, %esi
leaq -0x1a4(%rbp), %rdx
movl %esi, %edi
callq 0x11b0
cmpl $0x0, -0x1c(%rbp)
jne 0x33e3
leaq 0x35b4(%rip), %rdi      # 0x695a
movb $0x0, %al
callq 0x10c0
leaq 0x3006004(%rip), %rax   # 0x30093b8
movq (%rax), %rdi
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movsd -0x40(%rbp), %xmm4
movsd -0x38(%rbp), %xmm5
leaq 0x3589(%rip), %rsi      # 0x6965
movb $0x6, %al
callq 0x1150
leaq 0x3005fce(%rip), %rax   # 0x30093b8
movq (%rax), %rdi
callq 0x10a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopw %cs:(%rax,%rax)