// File: /workspace/github_cpp_makefile_star2_O2/ashlall[P]StreamStats/ChiSquareExperiments/VaryMemoryOneSample.cpp
// Function: main
int main(int argc, char* argv[])
{
  if (argc < 10)
  {
    cout << "usage: VaryMemory lower-memory upper-memory num-streams(>0) [N|U|P|E] location scale [0|1] stream-size 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]);
  int stream_size = atoi (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 memory percent must be greater than 0." << endl;
    throw ParameterError();
  }
  if (stream_size <= 0)
  {
    cout << "The stream_size 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
  double memory_percent;
  int num_mems = 0;
  double mem = lower;
  while (mem <= (upper + 0.0000001))
  {
    //cout << mem << endl;
    num_mems++;
    mem *= sqrt(10);
    //cout << mem << " " << upper << endl;
  }

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

  // 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
  {
    memory_percent = lower;
    int j = 0;
    data_file << "Stream " << i+1 << ":" << endl;

    // generates the data based on inputed parameters                                       
    DataGenerator data(distribution_type, stream_size, seed, location, scale);
    double *stream = data.get_stream();

    while (memory_percent <= (upper+0.0000001))  // runs tests for every memory percent
    {
      int sample_size = memory_percent * stream_size;
      if (i == 0)
        percents[j] = memory_percent;
      data_file << "memory_percent = " << memory_percent << endl;
      
      // 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;

      memory_percent *= sqrt(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_mems; i++)
  {
    data_file << percents[i] * 100 << "\t";
	time_file << percents[i] * 100 << "\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 << "memory_percent = " << percents[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_mems; 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_mems; 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_mems; 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_mems; 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 $0x918, %rsp            # imm = 0x918
cmpl $0x9, %edi
jle 0x585b
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x2200
movsd %xmm0, -0xb8(%rbp)
movq 0x10(%rbx), %rdi
callq 0x2200
movsd %xmm0, -0x98(%rbp)
movq 0x18(%rbx), %rdi
callq 0x2270
movl %eax, %r14d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rdi
movzbl (%rax), %r15d
callq 0x2200
movsd %xmm0, -0x40(%rbp)
movq 0x30(%rbx), %rdi
callq 0x2200
movsd %xmm0, -0x80(%rbp)
movq 0x38(%rbx), %rdi
callq 0x2270
movl %eax, -0x54(%rbp)
movq 0x40(%rbx), %rdi
callq 0x2270
movl %eax, -0x64(%rbp)
movq 0x48(%rbx), %rdi
callq 0x2270
movq %rax, -0x50(%rbp)
testl %r14d, %r14d
jle 0x586b
leal -0x45(%r15), %eax
cmpl $0x10, %eax
ja 0x58b0
movl $0x10a01, %ecx          # imm = 0x10A01
btl %eax, %ecx
jae 0x58b0
xorpd %xmm0, %xmm0
ucomisd -0xb8(%rbp), %xmm0
jae 0x587b
cmpl $0x0, -0x64(%rbp)
jle 0x588b
cmpl $0x0, -0x50(%rbp)
jle 0x589b
movsd -0x98(%rbp), %xmm0
addsd 0x35d3(%rip), %xmm0     # 0x8168
movsd %xmm0, -0x98(%rbp)
movl %r14d, -0xcc(%rbp)
movl %r14d, %r13d
xorl %eax, %eax
movq $0x0, -0x38(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd -0x98(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x4bd8
mulsd 0x35a1(%rip), %xmm0     # 0x8170
incq -0x38(%rbp)
addq %r13, %rax
jmp 0x4bc1
movq %rsp, %rcx
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
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, %rcx
subq %rax, %rcx
movq %rcx, -0xb0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xa8(%rbp)
movq %rcx, %rsp
movq %rsp, %rdx
movq -0x38(%rbp), %rcx
leaq 0xf(,%rcx,8), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0xf0(%rbp)
movq %rdx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xe8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xe0(%rbp)
movq %rcx, %rsp
movq %r15, -0x60(%rbp)
movq %rbx, %r15
leaq -0x360(%rbp), %rbx
movq %rbx, %rdi
callq 0x22e0
leaq -0x940(%rbp), %r14
movq %r14, %rdi
movq %r15, -0xa0(%rbp)
movq %r15, %rsi
movq -0x60(%rbp), %r15
xorl %edx, %edx
callq 0x5989
pushq $0x10
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2050
leaq 0x37c7(%rip), %rsi      # 0x8475
leaq -0x360(%rbp), %rdi
callq 0x21c0
movsbl %r15b, %esi
movq %rax, %rdi
callq 0x21e0
leaq 0x37b7(%rip), %rsi      # 0x8484
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x2280
leaq 0x37a9(%rip), %rsi      # 0x8492
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movsd -0x80(%rbp), %xmm0
callq 0x2280
movq %rax, %rdi
callq 0x20d0
movl -0x64(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x110(%rbp)
movl %eax, %r14d
pushq $0x1
popq %r12
xorl %ebx, %ebx
cmpq %r13, %rbx
je 0x514c
leaq -0x360(%rbp), %rdi
leaq 0x3768(%rip), %rsi      # 0x849d
callq 0x21c0
leaq 0x1(%rbx), %rsi
movq %rax, %rdi
movq %rsi, -0xf8(%rbp)
callq 0x2300
movq %rax, %rdi
leaq 0x374e(%rip), %rsi      # 0x84a5
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
movsbl %r15b, %esi
leaq -0x400(%rbp), %rdi
movl -0x64(%rbp), %edx
movl %r12d, -0xd0(%rbp)
movl %r12d, %ecx
movsd -0x40(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x24ac
movq -0x400(%rbp), %r12
movq %rbx, -0x138(%rbp)
movq %rbx, %rax
imulq -0x38(%rbp), %rax
movq -0xe8(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x130(%rbp)
movq -0xe0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x128(%rbp)
movq -0xc0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x120(%rbp)
movq -0xb0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x108(%rbp)
movq -0xa8(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x100(%rbp)
movq -0xc8(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0x118(%rbp)
xorl %ebx, %ebx
movsd -0xb8(%rbp), %xmm1
movsd -0x98(%rbp), %xmm0
movsd %xmm1, -0x30(%rbp)
ucomisd %xmm1, %xmm0
jb 0x512a
cmpq $0x0, -0x138(%rbp)
jne 0x4e49
movq -0xf0(%rbp), %rax
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax,%rbx,8)
leaq -0x360(%rbp), %rdi
leaq 0x3650(%rip), %rsi      # 0x84a7
callq 0x21c0
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x2280
movq %rax, %rdi
callq 0x20d0
movsd -0x30(%rbp), %xmm0
mulsd -0x110(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
leaq -0x8a0(%rbp), %rdi
movsd %xmm0, -0x48(%rbp)
pushq $0x1
popq %rsi
callq 0x4094
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
callq 0x2290
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x4ec7
movsd (%r12,%r15,8), %xmm0
movq -0x880(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r15
jmp 0x4eab
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
callq 0x2290
movq -0x150(%rbp), %rax
movq -0x148(%rbp), %rcx
subq -0x160(%rbp), %rax
subq -0x158(%rbp), %rcx
movq -0x130(%rbp), %rdx
movq %rax, (%rdx,%rbx,8)
movq -0x128(%rbp), %rax
movq %rcx, (%rax,%rbx,8)
movq -0x60(%rbp), %r15
movsbl %r15b, %esi
leaq -0x8a0(%rbp), %rdi
movq -0x50(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x5bb4
movq -0x120(%rbp), %rax
movsd %xmm0, (%rax,%rbx,8)
leaq -0x360(%rbp), %rdi
leaq 0x3576(%rip), %rsi      # 0x84b9
movsd %xmm0, -0x88(%rbp)
callq 0x21c0
movsd -0x88(%rbp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x54(%rbp)
je 0x50a8
leaq -0x6a0(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
pushq $0x2
popq %rsi
callq 0x4094
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x4fa5
movsd (%r12,%r15,8), %xmm0
movq -0x680(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r15
jmp 0x4f89
movsbl -0x60(%rbp), %esi
leaq -0x6a0(%rbp), %rdi
movq -0x50(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x5bb4
movq -0x108(%rbp), %rax
movsd %xmm0, (%rax,%rbx,8)
leaq -0x360(%rbp), %rdi
leaq 0x34e2(%rip), %rsi      # 0x84bf
movsd %xmm0, -0x88(%rbp)
callq 0x21c0
movsd -0x88(%rbp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
callq 0x20d0
leaq -0x4a0(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
pushq $0x3
popq %rsi
callq 0x4094
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x5035
movsd (%r12,%r15,8), %xmm0
movq -0x480(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r15
jmp 0x5019
movq -0x60(%rbp), %r15
movsbl %r15b, %esi
leaq -0x4a0(%rbp), %rdi
movq -0x50(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x5bb4
movq -0x100(%rbp), %rax
movsd %xmm0, (%rax,%rbx,8)
leaq -0x360(%rbp), %rdi
leaq 0x3459(%rip), %rsi      # 0x84ca
movsd %xmm0, -0x48(%rbp)
callq 0x21c0
movsd -0x48(%rbp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
callq 0x20d0
leaq -0x4a0(%rbp), %rdi
callq 0x418a
leaq -0x6a0(%rbp), %rdi
callq 0x418a
movq -0x890(%rbp), %rdx
movq -0x888(%rbp), %rcx
leaq -0x400(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x26ce
movq -0x118(%rbp), %rax
movsd %xmm0, (%rax,%rbx,8)
leaq -0x360(%rbp), %rdi
leaq 0x3400(%rip), %rsi      # 0x84e0
movsd %xmm0, -0x48(%rbp)
callq 0x21c0
movsd -0x48(%rbp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
callq 0x20d0
movsd -0x30(%rbp), %xmm0
mulsd 0x3064(%rip), %xmm0     # 0x8170
movsd %xmm0, -0x30(%rbp)
incq %rbx
leaq -0x8a0(%rbp), %rdi
callq 0x418a
movsd -0x30(%rbp), %xmm1
jmp 0x4e17
movl -0xd0(%rbp), %r12d
incl %r12d
leaq -0x400(%rbp), %rdi
callq 0x5d90
movq -0xf8(%rbp), %rbx
jmp 0x4d1e
leaq -0x360(%rbp), %rdi
callq 0x2230
leaq -0x940(%rbp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq -0xa0(%rbp), %rsi
callq 0x5989
leaq -0x360(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
leaq -0x8a0(%rbp), %rdi
callq 0x22e0
leaq -0x4a0(%rbp), %rbx
pushq $0x5
popq %rdx
movq %rbx, %rdi
movq -0xa0(%rbp), %rsi
callq 0x5989
leaq -0x8a0(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
leaq -0x6a0(%rbp), %rdi
callq 0x22e0
leaq -0x400(%rbp), %rbx
pushq $0x3
popq %rdx
movq %rbx, %rdi
movq -0xa0(%rbp), %rsi
callq 0x5989
leaq -0x6a0(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
xorl %eax, %eax
cmpl $0x45, %r15d
sete %al
movq -0x50(%rbp), %rcx
leal -0x3(%rax,%rcx), %r12d
movl -0xcc(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x48(%rbp)
movl %eax, -0xd4(%rbp)
xorl %r14d, %r14d
fildl -0xd4(%rbp)
fstpt -0x98(%rbp)
cmpq %r14, -0x38(%rbp)
je 0x5621
movq -0xf0(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x88(%rbp)
mulsd 0x2f2a(%rip), %xmm0     # 0x8178
leaq -0x360(%rbp), %rdi
movsd %xmm0, -0x30(%rbp)
callq 0x2280
movq %rax, %rdi
leaq 0x327f(%rip), %rsi      # 0x84e8
callq 0x21c0
leaq -0x8a0(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
callq 0x2280
movq %rax, %rdi
leaq 0x325f(%rip), %rsi      # 0x84e8
callq 0x21c0
movq -0xc0(%rbp), %rax
leaq (%rax,%r14,8), %rax
movq %rax, -0x50(%rbp)
movq -0xc8(%rbp), %rax
leaq (%rax,%r14,8), %rax
movq %rax, -0x30(%rbp)
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
cmpq %r13, %rbx
je 0x530b
movq %rbx, %r15
imulq -0x38(%rbp), %r15
movq -0x50(%rbp), %rax
movsd %xmm0, -0x40(%rbp)
movsd (%rax,%r15,8), %xmm0
movl %r12d, %edi
callq 0x3c78
movaps %xmm0, -0x80(%rbp)
movq -0x30(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
movl %r12d, %edi
callq 0x3c78
movapd -0x80(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
andpd 0x2ebe(%rip), %xmm1     # 0x81c0
addsd %xmm1, %xmm0
incq %rbx
jmp 0x52b2
divsd -0x48(%rbp), %xmm0
leaq -0x360(%rbp), %rdi
callq 0x2280
movq -0xe8(%rbp), %rax
leaq (%rax,%r14,8), %rax
movq -0xe0(%rbp), %rcx
leaq (%rcx,%r14,8), %rcx
xorl %edx, %edx
fldz
movsd 0x2e42(%rip), %xmm2     # 0x8180
cmpq %r13, %rdx
je 0x5372
movq %rdx, %rsi
imulq -0x38(%rbp), %rsi
cvtsi2sdq (%rax,%rsi,8), %xmm0
cvtsi2sdq (%rcx,%rsi,8), %xmm1
divsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x140(%rbp)
faddl -0x140(%rbp)
incq %rdx
jmp 0x533e
movq %r14, -0x60(%rbp)
fldt -0x98(%rbp)
fdivrp %st, %st(1)
subq $0x10, %rsp
fstpt (%rsp)
leaq -0x8a0(%rbp), %rdi
callq 0x2100
popq %rcx
popq %rdx
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x54(%rbp)
je 0x54ce
movq %r13, %r14
movq -0xb0(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq (%rax,%rcx,8), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorl %r13d, %r13d
cmpq %r14, %r13
je 0x5418
movq %r13, %r15
imulq -0x38(%rbp), %r15
movsd (%rbx,%r15,8), %xmm0
movl %r12d, %edi
callq 0x3c78
movaps %xmm0, -0x80(%rbp)
movq -0x30(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
movl %r12d, %edi
callq 0x3c78
movapd -0x80(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x2dbb(%rip), %xmm1     # 0x81c0
movsd -0x40(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
incq %r13
jmp 0x53c3
leaq -0x360(%rbp), %rdi
leaq 0x30c2(%rip), %rsi      # 0x84e8
callq 0x21c0
movq %r14, %r13
movsd -0x40(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
leaq 0x309e(%rip), %rsi      # 0x84e8
callq 0x21c0
movq -0xa8(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq (%rax,%rcx,8), %rbx
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x54bd
movq %r15, %r13
imulq -0x38(%rbp), %r13
movsd %xmm0, -0x40(%rbp)
movsd (%rbx,%r13,8), %xmm0
movl %r12d, %edi
callq 0x3c78
movaps %xmm0, -0x80(%rbp)
movq -0x30(%rbp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r14, %r13
movl %r12d, %edi
callq 0x3c78
movapd -0x80(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
andpd 0x2d0c(%rip), %xmm1     # 0x81c0
addsd %xmm1, %xmm0
incq %r15
jmp 0x5465
divsd -0x48(%rbp), %xmm0
leaq -0x360(%rbp), %rdi
callq 0x2280
leaq -0x360(%rbp), %rdi
callq 0x20d0
leaq -0x6a0(%rbp), %rdi
leaq 0x2fbf(%rip), %rsi      # 0x84a7
callq 0x21c0
movq %rax, %rdi
movsd -0x88(%rbp), %xmm0
callq 0x2280
movq %rax, %rdi
callq 0x20d0
movq -0xb0(%rbp), %rax
movq -0x60(%rbp), %r14
leaq (%rax,%r14,8), %rax
movq %rax, -0x40(%rbp)
movq -0xa8(%rbp), %rax
leaq (%rax,%r14,8), %rax
movq %rax, -0x80(%rbp)
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x5619
movq %r15, %rbx
imulq -0x38(%rbp), %rbx
movq -0x30(%rbp), %rax
movsd (%rax,%rbx,8), %xmm0
movl %r12d, %edi
callq 0x3c78
leaq -0x6a0(%rbp), %rdi
callq 0x2280
movq %rax, %rdi
leaq 0x2f88(%rip), %rsi      # 0x84ea
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
movq -0x50(%rbp), %rax
movsd (%rax,%rbx,8), %xmm0
movl %r12d, %edi
callq 0x3c78
leaq -0x6a0(%rbp), %rdi
callq 0x2280
movq %rax, %rdi
leaq 0x2f5c(%rip), %rsi      # 0x84f2
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x54(%rbp)
je 0x5611
movq -0x40(%rbp), %rax
movsd (%rax,%rbx,8), %xmm0
movl %r12d, %edi
callq 0x3c78
leaq -0x6a0(%rbp), %rdi
callq 0x2280
movq %rax, %rdi
leaq 0x2f26(%rip), %rsi      # 0x84f6
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
movq -0x80(%rbp), %rax
movsd (%rax,%rbx,8), %xmm0
movl %r12d, %edi
callq 0x3c78
leaq -0x6a0(%rbp), %rdi
callq 0x2280
movq %rax, %rdi
leaq 0x2ef6(%rip), %rsi      # 0x84fa
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
incq %r15
jmp 0x552a
incq %r14
jmp 0x5227
leaq -0x6a0(%rbp), %rdi
callq 0x2230
leaq -0x360(%rbp), %rdi
callq 0x2230
leaq -0x8a0(%rbp), %rdi
callq 0x2230
leaq -0x940(%rbp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq -0xa0(%rbp), %rsi
callq 0x5989
leaq -0x360(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
xorl %ecx, %ecx
leaq -0x360(%rbp), %rbx
leaq 0x2e68(%rip), %r14      # 0x84e8
cmpq %rcx, -0x38(%rbp)
je 0x56cc
movq -0xc8(%rbp), %rax
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r12
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x56c3
movq %r15, %rax
imulq -0x38(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21c0
incq %r15
jmp 0x5698
movq -0x30(%rbp), %rcx
incq %rcx
jmp 0x5680
leaq -0x360(%rbp), %rdi
callq 0x20d0
xorl %ecx, %ecx
leaq -0x360(%rbp), %rbx
leaq 0x2e00(%rip), %r14      # 0x84e8
cmpq %rcx, -0x38(%rbp)
je 0x5734
movq -0xc0(%rbp), %rax
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r12
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x572b
movq %r15, %rax
imulq -0x38(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21c0
incq %r15
jmp 0x5700
movq -0x30(%rbp), %rcx
incq %rcx
jmp 0x56e8
leaq -0x360(%rbp), %rdi
callq 0x20d0
cmpl $0x0, -0x54(%rbp)
je 0x581a
xorl %ecx, %ecx
leaq -0x360(%rbp), %rbx
leaq 0x2d8e(%rip), %r14      # 0x84e8
cmpq %rcx, -0x38(%rbp)
je 0x57a6
movq -0xb0(%rbp), %rax
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r12
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x579d
movq %r15, %rax
imulq -0x38(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21c0
incq %r15
jmp 0x5772
movq -0x30(%rbp), %rcx
incq %rcx
jmp 0x575a
leaq -0x360(%rbp), %rdi
callq 0x20d0
xorl %ecx, %ecx
leaq -0x360(%rbp), %rbx
leaq 0x2d26(%rip), %r14      # 0x84e8
cmpq %rcx, -0x38(%rbp)
je 0x580e
movq -0xa8(%rbp), %rax
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r12
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x5805
movq %r15, %rax
imulq -0x38(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21c0
incq %r15
jmp 0x57da
movq -0x30(%rbp), %rcx
incq %rcx
jmp 0x57c2
leaq -0x360(%rbp), %rdi
callq 0x20d0
leaq -0x360(%rbp), %rdi
callq 0x2230
leaq -0x6a0(%rbp), %rdi
callq 0x2250
leaq -0x8a0(%rbp), %rdi
callq 0x2250
leaq -0x360(%rbp), %rdi
callq 0x2250
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x776e(%rip), %rdi      # 0xcfd0
leaq 0x2ab8(%rip), %rsi      # 0x8321
jmp 0x58be
movq 0x775e(%rip), %rdi      # 0xcfd0
leaq 0x2b1b(%rip), %rsi      # 0x8394
jmp 0x58be
movq 0x774e(%rip), %rdi      # 0xcfd0
leaq 0x2b66(%rip), %rsi      # 0x83ef
jmp 0x58be
movq 0x773e(%rip), %rdi      # 0xcfd0
leaq 0x2b87(%rip), %rsi      # 0x8420
jmp 0x58a9
movq 0x772e(%rip), %rdi      # 0xcfd0
leaq 0x2ba0(%rip), %rsi      # 0x8449
callq 0x21c0
jmp 0x58cb
movq 0x7719(%rip), %rdi      # 0xcfd0
leaq 0x2b07(%rip), %rsi      # 0x83c5
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
pushq $0x1
popq %rdi
callq 0x20e0
leaq 0x73a6(%rip), %rsi      # 0xcc80
movq %rax, %rdi
xorl %edx, %edx
callq 0x22f0
jmp 0x591b
jmp 0x58e8
movq %rax, %rbx
jmp 0x592a
jmp 0x58f9
jmp 0x591b
jmp 0x58f9
jmp 0x591b
jmp 0x58f9
jmp 0x591b
movq %rax, %rbx
jmp 0x5975
jmp 0x591b
jmp 0x5949
jmp 0x595a
jmp 0x5912
jmp 0x591b
jmp 0x591b
jmp 0x591b
jmp 0x591b
jmp 0x5938
jmp 0x5949
movq %rax, %rbx
jmp 0x5969
jmp 0x595a
jmp 0x595a
movq %rax, %rbx
leaq -0x6a0(%rbp), %rdi
callq 0x2250
leaq -0x8a0(%rbp), %rdi
callq 0x2250
jmp 0x5975
movq %rax, %rbx
leaq -0x4a0(%rbp), %rdi
callq 0x418a
jmp 0x594c
movq %rax, %rbx
leaq -0x6a0(%rbp), %rdi
callq 0x418a
jmp 0x595d
movq %rax, %rbx
leaq -0x8a0(%rbp), %rdi
callq 0x418a
leaq -0x400(%rbp), %rdi
callq 0x5d90
leaq -0x360(%rbp), %rdi
callq 0x2250
movq %rbx, %rdi
callq 0x2320