// File: /workspace/github_cpp_makefile_star2_O3/ashlall[P]StreamStats/ChiSquareExperiments/VarySizeOneSample.cpp
// Function: main
int main(int argc, char* argv[])
{
  if (argc < 10)
  {
    cout << "usage: VarySize lower-size upper-size num-streams(>0) [N|U|P|E] location scale [0|1] memory-percent num-buckets" << endl;
    throw ParameterError();
  }
  
  double lower = atof (argv[1]);
  double upper = atof (argv[2]);
  int data_repeats = atoi (argv[3]);
  char distribution_type = argv[4][0];
  double location = atof (argv[5]);
  double scale = atof (argv[6]);
  int all_quantiles = atoi (argv[7]);
  double memory_percent = atof (argv[8]);
  int num_buckets = atoi(argv[9]);
  int seed = 1; 

  // ensures that the parameters will not create error
  if (data_repeats <= 0)
  {
    cout << "The number of streams must be greater than zero." << endl;
    throw ParameterError();
  }
  if (distribution_type != 'N' && distribution_type != 'U' && distribution_type != 'P' && distribution_type != 'E')
  {
    cout << "The distribution is either N, U, P, or E." << endl;
    throw ParameterError();
  }
  if (lower <= 0)
  {
    cout << "The lower stream size must be greater than 0." << endl;
    throw ParameterError();
  }
  if (memory_percent <= 0)
  {
    cout << "The memory percent must be greater than 0.\n";
    throw ParameterError();
  }
  if (num_buckets <= 0)
  {
    cout << "The number of bins must be greater than 0.\n";
    throw ParameterError();
  }

  // finds the number of different sizes the experiment will run on
  int stream_size;
  int num_sizes = 0, size = lower;
  while (size <= upper)
  {
    num_sizes++;
    size *= 10;
  }

  // creates the arrays that will hold the calculated statistics
  double actual_values[data_repeats][num_sizes];
  double GK_values[data_repeats][num_sizes];
  double QD_values[data_repeats][num_sizes];
  double RS_values[data_repeats][num_sizes];
  int sizes[num_sizes];
  long times[data_repeats][num_sizes];
  long times2[data_repeats][num_sizes];

  // creates and initializes the log file
  ofstream data_file;
  char str[150];
  name_file(str, argv, 0);
  data_file.open(str);
  data_file << "Distribution: " << distribution_type << ", location = " << location << ", scale = " << scale << endl;

  for (int i = 0; i < data_repeats; i++) // runs all tests data_repeats times
  {
    stream_size = lower;
    int j = 0;
    data_file << "Stream " << i+1 << ":" << endl;
    while (stream_size <= upper)  // runs tests for every stream size
    {
      int sample_size = memory_percent * stream_size;
      if (i == 0)
        sizes[j] = stream_size;
      data_file << "stream_size = " << stream_size << endl;
      
      // generates the data based on inputed parameters
      DataGenerator data(distribution_type, stream_size, seed, location, scale);
      double *stream = data.get_stream();

      // computes GK estimate
      ChiSquareContinuous sketch1(sample_size, 1); 

	  timeval timeBefore, timeAfter; // initializes variables
  	  long diffSeconds, diffUSeconds;
 	  gettimeofday(&timeBefore, NULL); 

      for (int i = 0; i < stream_size; i++)
	      sketch1.insert(stream[i]);

	  gettimeofday(&timeAfter, NULL); // get time for insertion
  	  diffSeconds = timeAfter.tv_sec - timeBefore.tv_sec;
  	  diffUSeconds = timeAfter.tv_usec - timeBefore.tv_usec;

	  times[i][j] = diffSeconds;
	  times2[i][j] = diffUSeconds;


      double GK_stat = get_estimate(&sketch1, distribution_type, num_buckets, location, scale);
      GK_values[i][j] = GK_stat;
      data_file << "GK = " << GK_stat << endl;

      if (all_quantiles)
      {
      	// computes QDigest estimate
	ChiSquareContinuous sketch2(sample_size, 2);
	for (int i = 0; i < stream_size; i++)
          sketch2.insert(stream[i]);
	double QD_stat = get_estimate(&sketch2, distribution_type, num_buckets, location, scale);
	QD_values[i][j] = QD_stat;
        data_file << "QDigest = " << QD_stat << endl;

	// computes ReservoirSampling estimate
	ChiSquareContinuous sketch3(sample_size, 3);
	for (int i = 0; i < stream_size; i++)
	  sketch3.insert(stream[i]);
	double RS_stat = get_estimate(&sketch3, distribution_type, num_buckets, location, scale);
	RS_values[i][j] = RS_stat;
        data_file << "Reservoir Sampling = " << RS_stat << endl;
      }

      // computes actual statistic
      double *upper_interval = sketch1.get_upper();
      double *lower_interval = sketch1.get_lower();
      double actual = data.get_stat_one_sample(num_buckets, upper_interval, lower_interval);
      actual_values[i][j] = actual;
      data_file << "Real = " << actual << endl;

      stream_size *= 10;
      j++;
    }
    seed++; // changes seed for next repeat?
  }
  data_file.close();

  // creates table file
  name_file(str, argv, 1);
  data_file.open(str);

  // creates time table file
  ofstream time_file;
  char str2[150];
  name_file(str2, argv, 5);
  time_file.open(str2);

  // creates pvalues file
  ofstream data2_file;
  char st[150];
  name_file(st, argv, 3);
  data2_file.open(st);

  int deg_freedom = num_buckets - get_DOF(distribution_type);
  for (int i = 0; i < num_sizes; i++)
  {
    data_file << sizes[i] << "\t";
	time_file << sizes[i] << "\t";

    // adds pvalue error from the GK sketch to the table file
    double error = 0;
    for (int j = 0; j < data_repeats; j++)
      error += abs(pochisq(GK_values[j][i], deg_freedom) - pochisq(actual_values[j][i], deg_freedom));
    data_file << error / data_repeats;

	// adds times to the time table
	long double avg_time = 0.0;
	for (int j = 0; j < data_repeats; j++)
		avg_time += times[j][i] + times2[j][i]/1000000.0;// diffSeconds + diffUSeconds/1000000.0
	time_file << avg_time / data_repeats << endl;

    if (all_quantiles)
    {
      // adds pvalue error from the QDigest sketch to the table file
      error = 0;
      for (int j = 0; j < data_repeats; j++)
	error += abs(pochisq(QD_values[j][i], deg_freedom) - pochisq(actual_values[j][i], deg_freedom));
      data_file << "\t" << error / data_repeats << "\t";

      // adds pvalue error from the Reservoir Sampling sketch to the table file
      error = 0;
      for (int j = 0; j < data_repeats; j++)
	error += abs(pochisq(RS_values[j][i], deg_freedom) - pochisq(actual_values[j][i], deg_freedom));
      data_file << error / data_repeats;
    }
    data_file << endl;

    // adds all pvalues to the pvalue file
    data2_file << "streamsize = " << sizes[i] << endl;
    for (int j = 0; j < data_repeats; j++)
    {
      data2_file << pochisq(actual_values[j][i], deg_freedom) << " actual" << endl;
      data2_file << pochisq(GK_values[j][i], deg_freedom) << " GK" << endl;
      if (all_quantiles)
      {
	data2_file << pochisq(QD_values[j][i], deg_freedom) << " QD" << endl;
	data2_file << pochisq(RS_values[j][i], deg_freedom) << " RS" << endl;
      }
    }
  }
  data2_file.close();
  data_file.close();
  time_file.close();

  // Creates extra file
  name_file(str, argv, 2);
  data_file.open(str);

  // adds actual statistics to the extra file
  for (int i = 0; i < num_sizes; i++)
  {
    for (int j = 0; j < data_repeats; j++)
	    data_file << actual_values[j][i] << "\t";
  }
  data_file << endl;

  // adds GK statistics to the extra file
  for (int i = 0; i < num_sizes; i++)
  {
    for(int j = 0; j <data_repeats; j++)
      data_file << GK_values[j][i] << "\t";
  }
  data_file << endl;
  if (all_quantiles)
  {
    // adds QDigest statistics to the extra file
    for (int i = 0; i < num_sizes; i++)
    {
	    for(int j = 0; j <data_repeats; j++)
	      data_file << QD_values[j][i] << "\t";
    }
    data_file << endl;

    // adds Reservoir Sampling statistcs to the extra file
    for (int i = 0; i < num_sizes; i++)
    {
	    for(int j = 0; j <data_repeats; j++)
	     data_file << RS_values[j][i] << "\t";
    }
    data_file << endl;
  }
  data_file.close();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x938, %rsp            # imm = 0x938
cmpl $0x9, %edi
jle 0x631d
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x2250
movapd %xmm0, -0x60(%rbp)
movq 0x10(%rbx), %rdi
callq 0x2250
movsd %xmm0, -0x90(%rbp)
movq 0x18(%rbx), %rdi
callq 0x22b0
movl %eax, %r14d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rdi
movb (%rax), %r15b
callq 0x2250
movsd %xmm0, -0xb0(%rbp)
movq 0x30(%rbx), %rdi
callq 0x2250
movsd %xmm0, -0x80(%rbp)
movq 0x38(%rbx), %rdi
callq 0x22b0
movl %eax, -0x84(%rbp)
movq 0x40(%rbx), %rdi
callq 0x2250
movsd %xmm0, -0x128(%rbp)
movq 0x48(%rbx), %rdi
callq 0x22b0
movq %rax, -0x40(%rbp)
testl %r14d, %r14d
jle 0x632d
movzbl %r15b, %eax
addl $-0x45, %eax
cmpl $0x10, %eax
ja 0x6372
movl $0x10a01, %ecx          # imm = 0x10A01
btl %eax, %ecx
jae 0x6372
xorpd %xmm0, %xmm0
movapd -0x60(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x633d
ucomisd -0x128(%rbp), %xmm0
jae 0x634d
cmpl $0x0, -0x40(%rbp)
jle 0x635d
movb %r15b, -0x29(%rbp)
movq %rbx, -0xb8(%rbp)
cvttsd2si %xmm1, %eax
movl %eax, -0xd4(%rbp)
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
xorl %eax, %eax
movsd -0x90(%rbp), %xmm1
movapd %xmm0, -0x160(%rbp)
ucomisd %xmm0, %xmm1
jb 0x51dd
xorl %eax, %eax
movl -0xd4(%rbp), %ecx
incl %eax
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
ucomisd %xmm0, %xmm1
jae 0x51c9
movl %r14d, -0x104(%rbp)
movl %r14d, %ecx
movl %eax, %edx
movq %rdx, %rax
movq %rcx, -0x68(%rbp)
imulq %rcx, %rax
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xd0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xc8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xc0(%rbp)
movq %rcx, %rsp
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
movq %rsp, %rsi
movq %rdx, -0x38(%rbp)
leaq 0xf(,%rdx,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rsi
movq %rsi, -0x120(%rbp)
movq %rsi, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xe8(%rbp)
movq %rcx, %rsp
leaq -0x380(%rbp), %rbx
movq %rbx, %rdi
callq 0x2320
leaq -0x960(%rbp), %r14
movq %r14, %rdi
movq -0xb8(%rbp), %rsi
xorl %edx, %edx
callq 0x6520
movq %rbx, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2060
leaq 0x419b(%rip), %rsi      # 0x9452
leaq -0x380(%rbp), %rdi
movl $0xe, %edx
callq 0x2230
leaq -0x820(%rbp), %rsi
movb -0x29(%rbp), %al
movb %al, (%rsi)
leaq -0x380(%rbp), %rdi
movl $0x1, %edx
callq 0x2230
movq %rax, %rbx
leaq 0x4172(%rip), %rsi      # 0x9461
movl $0xd, %edx
movq %rax, %rdi
callq 0x2230
movq %rbx, %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x22c0
movq %rax, %rbx
leaq 0x4159(%rip), %rsi      # 0x946f
movl $0xa, %edx
movq %rax, %rdi
callq 0x2230
movq %rbx, %rdi
movsd -0x80(%rbp), %xmm0
callq 0x22c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movl $0x1, -0x98(%rbp)
movq $0x0, -0x70(%rbp)
movq %r13, -0xe0(%rbp)
movl $0x7, %edx
leaq -0x380(%rbp), %rdi
leaq 0x40f4(%rip), %rsi      # 0x947a
callq 0x2230
movq -0x70(%rbp), %rax
leaq 0x1(%rax), %rsi
leaq -0x380(%rbp), %rdi
movq %rsi, -0x130(%rbp)
callq 0x2340
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x40ca(%rip), %rsi      # 0x9482
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movsd -0x90(%rbp), %xmm0
ucomisd -0x160(%rbp), %xmm0
jb 0x5901
movq -0x70(%rbp), %rax
imulq -0x38(%rbp), %rax
movq -0xf0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x100(%rbp)
movq -0xe8(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xf8(%rbp)
movq -0xc8(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x118(%rbp)
movq -0xc0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x140(%rbp)
leaq (%r13,%rax,8), %rcx
movq %rcx, -0x138(%rbp)
movq -0xd0(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0x148(%rbp)
movq $0x0, -0x60(%rbp)
movaps -0x160(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, %ebx
cmpq $0x0, -0x70(%rbp)
jne 0x549a
movq -0x120(%rbp), %rax
movq -0x60(%rbp), %rcx
movl %ebx, (%rax,%rcx,4)
movl $0xe, %edx
leaq -0x380(%rbp), %rdi
leaq 0x3fd7(%rip), %rsi      # 0x9484
callq 0x2230
movb -0x29(%rbp), %r15b
leaq -0x380(%rbp), %rdi
movl %ebx, %esi
callq 0x2340
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movsbl %r15b, %r14d
leaq -0x8c0(%rbp), %rdi
movl %r14d, %esi
movl %ebx, %edx
movl -0x98(%rbp), %ecx
movsd -0xb0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x251c
movsd -0x48(%rbp), %xmm0
mulsd -0x128(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movq -0x8c0(%rbp), %r13
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq -0x820(%rbp), %rdi
movsd %xmm0, -0x48(%rbp)
movl $0x1, %esi
callq 0x4506
leaq -0x180(%rbp), %rdi
xorl %esi, %esi
callq 0x22d0
movl %ebx, %r15d
testl %ebx, %ebx
jle 0x557e
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movq -0x800(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
cmpq %r12, %r15
jne 0x5563
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
callq 0x22d0
movq -0x170(%rbp), %rax
movq -0x168(%rbp), %rcx
subq -0x180(%rbp), %rax
subq -0x178(%rbp), %rcx
movq -0x100(%rbp), %rdx
movq -0x60(%rbp), %rsi
movq %rax, (%rdx,%rsi,8)
movq -0xf8(%rbp), %rax
movq %rcx, (%rax,%rsi,8)
leaq -0x820(%rbp), %rdi
movl %r14d, %esi
movq -0x40(%rbp), %rdx
movsd -0xb0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x674d
movq -0x118(%rbp), %rax
movq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x5, %edx
leaq -0x380(%rbp), %rdi
leaq 0x3e8e(%rip), %rsi      # 0x9493
movsd %xmm0, -0x78(%rbp)
callq 0x2230
movsd -0x78(%rbp), %xmm0
leaq -0x380(%rbp), %rdi
callq 0x22c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x84(%rbp)
je 0x581f
leaq -0x620(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl $0x2, %esi
callq 0x4506
testl %ebx, %ebx
jle 0x568f
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movq -0x600(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
cmpq %r12, %r15
jne 0x5674
leaq -0x620(%rbp), %rdi
movl %r14d, %esi
movq -0x40(%rbp), %rdx
movsd -0xb0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x674d
movq -0x140(%rbp), %rax
movq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0xa, %edx
leaq -0x380(%rbp), %rdi
leaq 0x3dc7(%rip), %rsi      # 0x9499
movsd %xmm0, -0x78(%rbp)
callq 0x2230
movsd -0x78(%rbp), %xmm0
leaq -0x380(%rbp), %rdi
callq 0x22c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
leaq -0x420(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movl $0x3, %esi
callq 0x4506
testl %ebx, %ebx
jle 0x574f
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movq -0x400(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
cmpq %r12, %r15
jne 0x5734
leaq -0x420(%rbp), %rdi
movl %r14d, %esi
movq -0x40(%rbp), %rdx
movsd -0xb0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x674d
movq -0x138(%rbp), %rax
movq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x15, %edx
leaq -0x380(%rbp), %rdi
leaq 0x3d12(%rip), %rsi      # 0x94a4
movsd %xmm0, -0x48(%rbp)
callq 0x2230
movsd -0x48(%rbp), %xmm0
leaq -0x380(%rbp), %rdi
callq 0x22c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x400(%rbp), %rdi
callq 0x21f0
movq -0x410(%rbp), %rdi
callq 0x21f0
movq -0x408(%rbp), %rdi
callq 0x21f0
movq -0x600(%rbp), %rdi
callq 0x21f0
movq -0x610(%rbp), %rdi
callq 0x21f0
movq -0x608(%rbp), %rdi
callq 0x21f0
movq -0x810(%rbp), %rdx
movq -0x808(%rbp), %rcx
leaq -0x8c0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2738
movq -0x148(%rbp), %rax
movq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x7, %edx
leaq -0x380(%rbp), %rdi
leaq 0x3c5a(%rip), %rsi      # 0x94ba
movsd %xmm0, -0x48(%rbp)
callq 0x2230
movsd -0x48(%rbp), %xmm0
leaq -0x380(%rbp), %rdi
callq 0x22c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x800(%rbp), %rdi
callq 0x21f0
movq -0x810(%rbp), %rdi
callq 0x21f0
movq -0x808(%rbp), %rdi
callq 0x21f0
testq %r13, %r13
je 0x58d6
movq %r13, %rdi
callq 0x2260
addl %ebx, %ebx
leal (%rbx,%rbx,4), %ebx
incq -0x60(%rbp)
cvtsi2sd %ebx, %xmm1
movsd -0x90(%rbp), %xmm0
movsd %xmm1, -0x48(%rbp)
ucomisd %xmm1, %xmm0
movq -0xe0(%rbp), %r13
jae 0x5485
incl -0x98(%rbp)
movq -0x130(%rbp), %rcx
movq %rcx, -0x70(%rbp)
cmpq -0x68(%rbp), %rcx
jne 0x5373
leaq -0x380(%rbp), %rdi
callq 0x2280
leaq -0x960(%rbp), %rbx
movq %rbx, %rdi
movq -0xb8(%rbp), %rsi
movl $0x1, %edx
callq 0x6520
leaq -0x380(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x820(%rbp), %rdi
callq 0x2320
leaq -0x420(%rbp), %rbx
movq %rbx, %rdi
movq -0xb8(%rbp), %rsi
movl $0x5, %edx
callq 0x6520
leaq -0x820(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x620(%rbp), %rdi
callq 0x2320
leaq -0x8c0(%rbp), %rbx
movq %rbx, %rdi
movq -0xb8(%rbp), %rsi
movl $0x3, %edx
callq 0x6520
leaq -0x620(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
xorl %eax, %eax
cmpb $0x45, -0x29(%rbp)
sete %cl
cmpq $0x0, -0x38(%rbp)
je 0x5f6c
movb %cl, %al
movl -0x104(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x40(%rbp), %rdx
leal -0x3(%rax,%rdx), %r12d
movl %ecx, -0x108(%rbp)
fildl -0x108(%rbp)
fstpt -0x118(%rbp)
movq -0x38(%rbp), %rax
leaq (,%rax,8), %r15
xorl %ecx, %ecx
movq -0xc0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xd0(%rbp), %rax
movq %r15, -0x70(%rbp)
movl %r12d, -0x90(%rbp)
movq %rax, -0x78(%rbp)
movq %r13, -0x80(%rbp)
movq -0x120(%rbp), %rax
movq %rcx, -0xf8(%rbp)
movl (%rax,%rcx,4), %ebx
leaq -0x380(%rbp), %rdi
movl %ebx, %esi
callq 0x2340
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3a43(%rip), %rsi      # 0x94c2
callq 0x2230
leaq -0x820(%rbp), %rdi
movl %ebx, %esi
callq 0x2340
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3a21(%rip), %rsi      # 0x94c2
callq 0x2230
movl %ebx, -0x100(%rbp)
xorpd %xmm1, %xmm1
movq -0x68(%rbp), %rbx
xorl %r14d, %r14d
movq -0x78(%rbp), %r15
movq -0x70(%rbp), %r12
movl -0x90(%rbp), %r13d
movsd %xmm1, -0x40(%rbp)
movq -0x60(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movaps %xmm0, -0xb0(%rbp)
movsd (%r15,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movsd -0x40(%rbp), %xmm1
movapd -0xb0(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x3695(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq %r12, %r14
decq %rbx
jne 0x5ac6
divsd -0x98(%rbp), %xmm1
leaq -0x380(%rbp), %r14
movq %r14, %rdi
movapd %xmm1, %xmm0
callq 0x22c0
movq -0xf0(%rbp), %rdx
movq -0xe8(%rbp), %rsi
movq -0x68(%rbp), %rax
xorl %ecx, %ecx
fldz
movsd 0x3620(%rip), %xmm2     # 0x9170
movq -0x70(%rbp), %rdi
xorps %xmm0, %xmm0
cvtsi2sdq (%rdx,%rcx), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq (%rsi,%rcx), %xmm1
divsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x150(%rbp)
faddl -0x150(%rbp)
addq %rdi, %rcx
decq %rax
jne 0x5b54
fldt -0x118(%rbp)
fdivrp %st, %st(1)
subq $0x10, %rsp
fstpt (%rsp)
leaq -0x820(%rbp), %rdi
callq 0x2120
addq $0x10, %rsp
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x84(%rbp)
je 0x5d14
xorpd %xmm1, %xmm1
movq -0x68(%rbp), %rbx
xorl %r14d, %r14d
movq -0x78(%rbp), %r15
movq -0x70(%rbp), %r12
movl -0x90(%rbp), %r13d
movsd %xmm1, -0x40(%rbp)
movq -0x48(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movaps %xmm0, -0xb0(%rbp)
movsd (%r15,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movsd -0x40(%rbp), %xmm1
movapd -0xb0(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x3567(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq %r12, %r14
decq %rbx
jne 0x5bf4
movsd %xmm1, -0x40(%rbp)
movl $0x1, %edx
leaq -0x380(%rbp), %rbx
movq %rbx, %rdi
leaq 0x3862(%rip), %rsi      # 0x94c2
callq 0x2230
movsd -0x40(%rbp), %xmm0
divsd -0x98(%rbp), %xmm0
movq %rbx, %rdi
callq 0x22c0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3839(%rip), %rsi      # 0x94c2
callq 0x2230
xorpd %xmm1, %xmm1
movq -0x68(%rbp), %rbx
xorl %r14d, %r14d
movq -0x78(%rbp), %r15
movq -0x70(%rbp), %r12
movl -0x90(%rbp), %r13d
movsd %xmm1, -0x40(%rbp)
movq -0x80(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movaps %xmm0, -0xb0(%rbp)
movsd (%r15,%r14), %xmm0
movl %r13d, %edi
callq 0x407f
movsd -0x40(%rbp), %xmm1
movapd -0xb0(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x34b3(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq %r12, %r14
decq %rbx
jne 0x5ca8
divsd -0x98(%rbp), %xmm1
leaq -0x380(%rbp), %r14
movq %r14, %rdi
movapd %xmm1, %xmm0
callq 0x22c0
movq -0x380(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movl $0xd, %edx
leaq -0x620(%rbp), %rdi
leaq 0x3772(%rip), %rsi      # 0x94c4
callq 0x2230
leaq -0x620(%rbp), %rdi
movl -0x100(%rbp), %esi
callq 0x2340
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x68(%rbp), %r13
xorl %r14d, %r14d
movq -0x70(%rbp), %r15
movl -0x90(%rbp), %r12d
movq -0x78(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r12d, %edi
callq 0x407f
leaq -0x620(%rbp), %rdi
callq 0x22c0
movq %rax, %rbx
movl $0x7, %edx
movq %rax, %rdi
leaq 0x36fd(%rip), %rsi      # 0x94d2
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x60(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r12d, %edi
callq 0x407f
leaq -0x620(%rbp), %rdi
callq 0x22c0
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x36a9(%rip), %rsi      # 0x94da
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x84(%rbp)
je 0x5f22
movq -0x48(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r12d, %edi
callq 0x407f
leaq -0x620(%rbp), %rdi
callq 0x22c0
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x3644(%rip), %rsi      # 0x94de
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x80(%rbp), %rax
movsd (%rax,%r14), %xmm0
movl %r12d, %edi
callq 0x407f
leaq -0x620(%rbp), %rdi
callq 0x22c0
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x35ec(%rip), %rsi      # 0x94e2
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
addq %r15, %r14
decq %r13
jne 0x5da5
movq -0xf8(%rbp), %rcx
incq %rcx
movq -0x78(%rbp), %rax
addq $0x8, %rax
addq $0x8, -0x60(%rbp)
addq $0x8, -0xe8(%rbp)
addq $0x8, -0xf0(%rbp)
addq $0x8, -0x48(%rbp)
movq -0x80(%rbp), %r13
addq $0x8, %r13
cmpq -0x38(%rbp), %rcx
jne 0x5a49
leaq -0x620(%rbp), %rdi
callq 0x2280
leaq -0x380(%rbp), %rdi
callq 0x2280
leaq -0x820(%rbp), %rdi
callq 0x2280
leaq -0x960(%rbp), %r12
movq %r12, %rdi
movq -0xb8(%rbp), %rsi
movl $0x2, %edx
callq 0x6520
leaq -0x380(%rbp), %rdi
movq %r12, %rsi
movl $0x10, %edx
callq 0x2060
cmpl $0x0, -0x38(%rbp)
movq -0xd0(%rbp), %r14
je 0x6034
movq -0x38(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x380(%rbp), %r12
leaq 0x34da(%rip), %r13      # 0x94c2
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %r15
movq %r14, -0xd0(%rbp)
movsd (%r14), %xmm0
movq %r12, %rdi
callq 0x22c0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
addq %rbx, %r14
decq %r15
jne 0x5ff7
movq -0x60(%rbp), %rax
incq %rax
movq -0xd0(%rbp), %r14
addq $0x8, %r14
cmpq -0x38(%rbp), %rax
jne 0x5fe8
movq -0x380(%rbp), %rax
leaq -0x380(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
leaq -0x380(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x38(%rbp)
movq -0xc8(%rbp), %r14
je 0x60dc
movq -0x38(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x380(%rbp), %r12
leaq 0x3432(%rip), %r13      # 0x94c2
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %r15
movq %r14, -0xc8(%rbp)
movsd (%r14), %xmm0
movq %r12, %rdi
callq 0x22c0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
addq %rbx, %r14
decq %r15
jne 0x609f
movq -0x60(%rbp), %rax
incq %rax
movq -0xc8(%rbp), %r14
addq $0x8, %r14
cmpq -0x38(%rbp), %rax
jne 0x6090
movq -0x380(%rbp), %rax
leaq -0x380(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
leaq -0x380(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x84(%rbp)
je 0x626c
cmpl $0x0, -0x38(%rbp)
movq -0xc0(%rbp), %r14
je 0x6191
movq -0x38(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x380(%rbp), %r12
leaq 0x337d(%rip), %r13      # 0x94c2
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %r15
movq %r14, -0xc0(%rbp)
movsd (%r14), %xmm0
movq %r12, %rdi
callq 0x22c0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
addq %rbx, %r14
decq %r15
jne 0x6154
movq -0x60(%rbp), %rax
incq %rax
movq -0xc0(%rbp), %r14
addq $0x8, %r14
cmpq -0x38(%rbp), %rax
jne 0x6145
movq -0x380(%rbp), %rax
leaq -0x380(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
leaq -0x380(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x38(%rbp)
movq -0xe0(%rbp), %r14
je 0x6239
movq -0x38(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x380(%rbp), %r12
leaq 0x32d5(%rip), %r13      # 0x94c2
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %r15
movq %r14, -0xe0(%rbp)
movsd (%r14), %xmm0
movq %r12, %rdi
callq 0x22c0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
addq %rbx, %r14
decq %r15
jne 0x61fc
movq -0x60(%rbp), %rax
incq %rax
movq -0xe0(%rbp), %r14
addq $0x8, %r14
cmpq -0x38(%rbp), %rax
jne 0x61ed
movq -0x380(%rbp), %rax
leaq -0x380(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
leaq -0x380(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
leaq -0x380(%rbp), %r15
movq %r15, %rdi
callq 0x2280
movq 0x6d46(%rip), %rax      # 0xcfc8
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq -0x618(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x620(%rbp,%rax)
callq 0x21c0
movl $0xf8, %r12d
leaq -0x620(%rbp), %rdi
addq %r12, %rdi
callq 0x20b0
leaq -0x818(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x820(%rbp,%rax)
callq 0x21c0
leaq -0x820(%rbp), %rdi
addq %r12, %rdi
callq 0x20b0
leaq -0x378(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x380(%rbp,%rax)
callq 0x21c0
addq %r12, %r15
movq %r15, %rdi
callq 0x20b0
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6cac(%rip), %rdi      # 0xcfd0
leaq 0x2fd6(%rip), %rsi      # 0x9301
jmp 0x6380
movq 0x6c9c(%rip), %rdi      # 0xcfd0
leaq 0x3036(%rip), %rsi      # 0x9371
jmp 0x6380
movq 0x6c8c(%rip), %rdi      # 0xcfd0
leaq 0x3081(%rip), %rsi      # 0x93cc
jmp 0x6380
movq 0x6c7c(%rip), %rdi      # 0xcfd0
leaq 0x309f(%rip), %rsi      # 0x93fa
jmp 0x636b
movq 0x6c6c(%rip), %rdi      # 0xcfd0
leaq 0x30bb(%rip), %rsi      # 0x9426
callq 0x2210
jmp 0x638d
movq 0x6c57(%rip), %rdi      # 0xcfd0
leaq 0x3022(%rip), %rsi      # 0x93a2
callq 0x2210
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2100
leaq 0x68da(%rip), %rsi      # 0xcc78
movq %rax, %rdi
xorl %edx, %edx
callq 0x2330
jmp 0x6473
jmp 0x63af
movq %rax, %rbx
jmp 0x64ac
jmp 0x63f7
jmp 0x63f7
jmp 0x6473
jmp 0x6473
jmp 0x6473
jmp 0x63f7
jmp 0x6473
jmp 0x643d
jmp 0x6414
jmp 0x63f7
movq %rax, %rbx
jmp 0x6464
jmp 0x6473
jmp 0x6473
jmp 0x6473
jmp 0x6473
jmp 0x6403
jmp 0x6414
movq %rax, %rbx
jmp 0x64e2
jmp 0x643d
jmp 0x643d
movq %rax, %rbx
leaq -0x420(%rbp), %rdi
callq 0x46a4
jmp 0x6417
movq %rax, %rbx
movq -0x600(%rbp), %rdi
callq 0x21f0
movq -0x610(%rbp), %rdi
callq 0x21f0
movq -0x608(%rbp), %rdi
callq 0x21f0
jmp 0x6440
movq %rax, %rbx
movq -0x800(%rbp), %rdi
callq 0x21f0
movq -0x810(%rbp), %rdi
callq 0x21f0
movq -0x808(%rbp), %rdi
callq 0x21f0
testq %r13, %r13
je 0x64e2
movq %r13, %rdi
callq 0x2260
jmp 0x64e2
movq %rax, %rbx
movq 0x6b4b(%rip), %rax      # 0xcfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x618(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x620(%rbp,%rcx)
callq 0x21c0
leaq -0x528(%rbp), %rdi
callq 0x20b0
movq 0x6b15(%rip), %rax      # 0xcfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x818(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x820(%rbp,%rcx)
callq 0x21c0
leaq -0x728(%rbp), %rdi
callq 0x20b0
movq 0x6adf(%rip), %rax      # 0xcfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x378(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x380(%rbp,%rcx)
callq 0x21c0
leaq -0x288(%rbp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2360