// File: /workspace/github_cpp_makefile_star2_O2/ashlall[P]StreamStats/ChiSquareExperiments/VaryMemoryTwoSample.cpp
// Function: main
int main(int argc, char* argv[])
{
  if (argc < 12)
  {
    cout << "usage: VaryMemoryTwoSample lower-memory upper-memory num-stream(>0) [N|U|P|E] location1 scale1 location2 scale2 [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 location1 = atof (argv[5]);
  double scale1 = atof (argv[6]);
  double location2 = atof (argv[7]);
  double scale2 = atof (argv[8]);
  int all_quantiles = atoi (argv[9]);
  int stream_size = atoi (argv[10]);
  int num_buckets = atoi (argv[11]);
  int seed1 = 1;
  int seed2 = 2;

  // ensures that the parameters will not create error
  if (data_repeats <= 0)
  {
    cout << "The number of streams must be greater than zero.\n";
    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.\n";
    throw ParameterError();
  }
  if (lower <= 0)
  {
    cout << "The lower percent of memory must be greater than 0.\n";
    throw ParameterError();
  }
  if (num_buckets <= 0)
  {
    cout << "The number of buckets must be greater than 0.\n";
    throw ParameterError();
  }
  if (stream_size <= 0)
  {
    cout << "The stream size must be greater than 0.\n";
    throw ParameterError();
  }

  // finds the number of different bins the experiment will run on
  double memory_percent;
  int num_mems = 0;
  double mem = lower;
  while (mem <= (upper + 0.0000001))
  {
    num_mems++;
    mem *= sqrt(10);
  }

  // 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];

  // creates and intializes the log file
  ofstream data_file;
  char str[150];
  name_file(str, argv, 0);
  data_file.open(str);
  data_file << "Distribution: " << distribution_type << endl;
  data_file << "location_1 = " << location1 << " scale_1 = " << scale1 << endl;
  data_file << "location_2 = " << location2 << " scale_2 = " << scale2 << endl;
  data_file << "stream_size = " << stream_size << endl;
  data_file << "num_buckets = " << num_buckets << endl;

  for (int i = 0; i < data_repeats; i++) // runs all test data_repeats times
  {
    memory_percent = lower;
    int j = 0;
    data_file << "Pass " << i+1 << ":" << endl;

    // generates the data based on parameters                                                
    DataGenerator data1(distribution_type, stream_size, seed1, location1, scale1);
    double *stream1 = data1.get_stream();
    DataGenerator data2(distribution_type, stream_size, seed2, location2, scale2);
    double *stream2 = data2.get_stream();

    while (memory_percent <= (upper + 0.00000001))  // runs tests for every memory percent
    { 
      int sample_size = memory_percent * stream_size;
      if (!i)
	percents[j] = memory_percent;

      // computes GK estimate
      ChiSquareContinuous *GK_sketch1 = new ChiSquareContinuous(sample_size, 1);
      for (int k = 0; k < stream_size; k++)
        GK_sketch1->insert(stream1[k]);
      ChiSquareContinuous *GK_sketch2 = new ChiSquareContinuous(sample_size, 1);
      for (int k = 0; k < stream_size; k++)
        GK_sketch2->insert(stream2[k]);
      double GK_stat = GK_sketch1->two_sample_statistic(*GK_sketch2, num_buckets);
      GK_values[i][j] = GK_stat;
      data_file << "GK = " << GK_stat << endl;

      if (all_quantiles)
      {
        // computes QDigest estimate
        ChiSquareContinuous QD_sketch1(sample_size, 2);
        for (int k = 0; k < stream_size; k++)
          QD_sketch1.insert(stream1[k]);
        ChiSquareContinuous QD_sketch2(sample_size, 2);
        for (int k = 0; k < stream_size; k++)
          QD_sketch2.insert(stream2[k]);
        double QD_stat = QD_sketch1.two_sample_statistic(QD_sketch2, num_buckets);
        QD_values[i][j] = QD_stat;
        data_file << "QD = " << QD_stat << endl;

        // computes Reservoir Sampling estimate
        ChiSquareContinuous RS_sketch1(sample_size, 3);
        for (int k = 0; k < stream_size; k++)
          RS_sketch1.insert(stream1[k]);
        ChiSquareContinuous RS_sketch2(sample_size, 3);
        for (int k = 0; k < stream_size; k++)
          RS_sketch2.insert(stream2[k]);
        double RS_stat = RS_sketch1.two_sample_statistic(RS_sketch2, num_buckets);
        RS_values[i][j]= RS_stat;
        data_file << "RS = " << RS_stat<< endl;
      }
       
      // computes actual statistic
      double *upper_interval = GK_sketch1->get_upper();
      double *lower_interval = GK_sketch1->get_lower();
      double actual = data2.get_stat_two_sample(data1, num_buckets, upper_interval, lower_interval);
      actual_values[i][j] = actual;
      data_file << "Real = " << actual << endl;

      memory_percent *= sqrt(10);
      j++;
    }     
    seed1++;
    seed2++;
  }
  data_file.close();

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

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

  int deg_freedom = num_buckets;
  for (int i = 0; i < num_mems; i++)
  {
    data_file << percents[i] * 100 << "\t";
    double error = 0;

    // adds pvalue error from the GK sketch to the table file
    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;

    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();

  // 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 statistics 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 << endl;
  data_file.close();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6a8, %rsp            # imm = 0x6A8
cmpl $0xb, %edi
jle 0x5839
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x21f0
movsd %xmm0, -0xa8(%rbp)
movq 0x10(%rbx), %rdi
callq 0x21f0
movsd %xmm0, -0x98(%rbp)
movq 0x18(%rbx), %rdi
callq 0x2260
movl %eax, %r14d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rdi
movzbl (%rax), %r15d
callq 0x21f0
movsd %xmm0, -0xf0(%rbp)
movq 0x30(%rbx), %rdi
callq 0x21f0
movsd %xmm0, -0xe8(%rbp)
movq 0x38(%rbx), %rdi
callq 0x21f0
movsd %xmm0, -0xe0(%rbp)
movq 0x40(%rbx), %rdi
callq 0x21f0
movsd %xmm0, -0xd8(%rbp)
movq 0x48(%rbx), %rdi
callq 0x2260
movl %eax, -0x4c(%rbp)
movq 0x50(%rbx), %rdi
callq 0x2260
movl %eax, %r12d
movq 0x58(%rbx), %rdi
callq 0x2260
movl %eax, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x5856
leal -0x45(%r15), %eax
cmpl $0x10, %eax
ja 0x5896
movl $0x10a01, %ecx          # imm = 0x10A01
btl %eax, %ecx
jae 0x5896
xorpd %xmm0, %xmm0
ucomisd -0xa8(%rbp), %xmm0
jae 0x5866
cmpl $0x0, -0x2c(%rbp)
jle 0x5876
testl %r12d, %r12d
jle 0x5886
movsd 0x35d5(%rip), %xmm0     # 0x8168
addsd -0x98(%rbp), %xmm0
movl %r14d, %eax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
movq $0x0, -0x40(%rbp)
movsd -0xa8(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x4bcc
mulsd 0x35ae(%rip), %xmm1     # 0x8170
incq -0x40(%rbp)
addq -0x48(%rbp), %rax
jmp 0x4bb4
movl %r14d, -0xbc(%rbp)
movq %rsp, %rcx
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xb8(%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, -0x90(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
movq -0x40(%rbp), %rax
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xf8(%rbp)
movq %rcx, %rsp
movq %r15, -0xd0(%rbp)
movq %rbx, %r15
leaq -0x398(%rbp), %rbx
movq %rbx, %rdi
callq 0x22c0
leaq -0x6d0(%rbp), %r14
movq %r14, %rdi
movq %r15, -0xc8(%rbp)
movq %r15, %rsi
movq -0xd0(%rbp), %r15
xorl %edx, %edx
callq 0x5991
pushq $0x10
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2050
movl -0x2c(%rbp), %ebx
leaq 0x37f7(%rip), %rsi      # 0x8489
leaq -0x398(%rbp), %rdi
callq 0x21b0
movsbl %r15b, %esi
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20d0
leaq 0x37df(%rip), %rsi      # 0x8498
leaq -0x398(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0xf0(%rbp), %xmm0
callq 0x2270
leaq 0x37ca(%rip), %rsi      # 0x84a6
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0xe8(%rbp), %xmm0
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq 0x37af(%rip), %rsi      # 0x84b2
leaq -0x398(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0xe0(%rbp), %xmm0
callq 0x2270
leaq 0x379a(%rip), %rsi      # 0x84c0
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0xd8(%rbp), %xmm0
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq 0x377f(%rip), %rsi      # 0x84cc
leaq -0x398(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
movl %r12d, %esi
callq 0x22e0
movq %rax, %rdi
callq 0x20d0
leaq 0x3768(%rip), %rsi      # 0x84db
leaq -0x398(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x22e0
movq %rax, %rdi
callq 0x20d0
movsd -0x98(%rbp), %xmm0
addsd 0x33d7(%rip), %xmm0     # 0x8178
movsd %xmm0, -0x98(%rbp)
cvtsi2sd %r12d, %xmm0
movsd %xmm0, -0x138(%rbp)
movl %r12d, %r14d
pushq $0x1
popq %rbx
pushq $0x2
popq %rax
xorl %r13d, %r13d
movl %eax, -0x7c(%rbp)
movl %ebx, -0x80(%rbp)
movl %r12d, -0xc0(%rbp)
cmpq -0x48(%rbp), %r13
je 0x5254
leaq -0x398(%rbp), %rdi
leaq 0x3703(%rip), %rsi      # 0x84ea
callq 0x21b0
leaq 0x1(%r13), %rsi
movq %rax, %rdi
movq %rsi, -0x120(%rbp)
callq 0x22e0
movq %rax, %rdi
leaq 0x36e7(%rip), %rsi      # 0x84f0
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movq %r13, -0xa0(%rbp)
movsbl %r15b, %esi
leaq -0x118(%rbp), %rdi
movl %r12d, %edx
movl -0x80(%rbp), %ecx
movsd -0xf0(%rbp), %xmm0
movsd -0xe8(%rbp), %xmm1
callq 0x248c
movq -0x118(%rbp), %r13
movsbl %r15b, %esi
leaq -0x108(%rbp), %rdi
movl %r12d, %edx
movl -0x7c(%rbp), %ecx
movsd -0xe0(%rbp), %xmm0
movsd -0xd8(%rbp), %xmm1
callq 0x248c
movq -0x108(%rbp), %r15
movq -0xa0(%rbp), %rax
imulq -0x40(%rbp), %rax
movq -0xb0(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x148(%rbp)
movq -0x90(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x130(%rbp)
movq -0x88(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0x128(%rbp)
movq -0xb8(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0x140(%rbp)
movq $0x0, -0x38(%rbp)
movsd -0xa8(%rbp), %xmm1
movsd -0x98(%rbp), %xmm0
movsd %xmm1, -0x58(%rbp)
ucomisd %xmm1, %xmm0
jb 0x521c
cmpq $0x0, -0xa0(%rbp)
jne 0x4f11
movq -0xf8(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd -0x58(%rbp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
pushq $0x28
popq %rdi
callq 0x21c0
movq %rax, %r12
movsd -0x58(%rbp), %xmm0
mulsd -0x138(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movq %r12, %rdi
movsd %xmm0, -0x70(%rbp)
movl %ebx, %esi
callq 0x4074
movq %r12, -0x60(%rbp)
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x4f65
movsd (%r13,%r12,8), %xmm0
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
jmp 0x4f47
pushq $0x28
popq %rdi
callq 0x21c0
movq %rax, %r12
movq %rax, %rdi
movsd -0x70(%rbp), %xmm0
movl %ebx, %esi
callq 0x4074
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x4f9b
movsd (%r15,%rbx,8), %xmm0
movq 0x20(%r12), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %rbx
jmp 0x4f81
movq -0x60(%rbp), %rdi
movq %r12, %rsi
movl -0x2c(%rbp), %ebx
movl %ebx, %edx
callq 0x47ee
movq -0x148(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x398(%rbp), %rdi
leaq 0x3528(%rip), %rsi      # 0x84f2
movsd %xmm0, -0x78(%rbp)
callq 0x21b0
movsd -0x78(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x4c(%rbp)
je 0x51a5
leaq -0x630(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
pushq $0x2
popq %rsi
callq 0x4074
movq -0x610(%rbp), %r12
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x502a
movsd (%r13,%rbx,8), %xmm0
movq (%r12), %rax
movq %r12, %rdi
callq *(%rax)
incq %rbx
jmp 0x5010
leaq -0x430(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
pushq $0x2
popq %rsi
callq 0x4074
movq -0x410(%rbp), %r12
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x5060
movsd (%r15,%rbx,8), %xmm0
movq (%r12), %rax
movq %r12, %rdi
callq *(%rax)
incq %rbx
jmp 0x5047
leaq -0x630(%rbp), %rdi
leaq -0x430(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x47ee
movq -0x130(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x398(%rbp), %rdi
leaq 0x3464(%rip), %rsi      # 0x84f8
movsd %xmm0, -0x78(%rbp)
callq 0x21b0
movsd -0x78(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq -0x198(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
pushq $0x3
popq %rsi
callq 0x4074
movq -0x178(%rbp), %r12
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x50ea
movsd (%r13,%rbx,8), %xmm0
movq (%r12), %rax
movq %r12, %rdi
callq *(%rax)
incq %rbx
jmp 0x50d0
leaq -0x170(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
pushq $0x3
popq %rsi
callq 0x4074
movq -0x150(%rbp), %r12
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x5120
movsd (%r15,%rbx,8), %xmm0
movq (%r12), %rax
movq %r12, %rdi
callq *(%rax)
incq %rbx
jmp 0x5107
leaq -0x198(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl -0x2c(%rbp), %ebx
movl %ebx, %edx
callq 0x47ee
movq -0x128(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x398(%rbp), %rdi
leaq 0x33a8(%rip), %rsi      # 0x84fe
movsd %xmm0, -0x70(%rbp)
callq 0x21b0
movsd -0x70(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq -0x170(%rbp), %rdi
callq 0x416a
leaq -0x198(%rbp), %rdi
callq 0x416a
leaq -0x430(%rbp), %rdi
callq 0x416a
leaq -0x630(%rbp), %rdi
callq 0x416a
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
leaq -0x108(%rbp), %rdi
leaq -0x118(%rbp), %rsi
movl %ebx, %edx
callq 0x2748
movq -0x140(%rbp), %rax
movq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x398(%rbp), %rdi
leaq 0x3320(%rip), %rsi      # 0x8504
movsd %xmm0, -0x60(%rbp)
callq 0x21b0
movsd -0x60(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
movsd -0x58(%rbp), %xmm1
mulsd 0x2f60(%rip), %xmm1     # 0x8170
incq -0x38(%rbp)
pushq $0x1
popq %rbx
jmp 0x4edb
incl -0x80(%rbp)
incl -0x7c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x5d92
leaq -0x118(%rbp), %rdi
callq 0x5d92
movq -0x120(%rbp), %r13
movq -0xd0(%rbp), %r15
movl -0xc0(%rbp), %r12d
jmp 0x4dcf
leaq -0x398(%rbp), %rdi
callq 0x2220
leaq -0x630(%rbp), %rdi
callq 0x22c0
leaq -0x430(%rbp), %rbx
pushq $0x3
popq %rdx
movq %rbx, %rdi
movq -0xc8(%rbp), %r14
movq %r14, %rsi
callq 0x5991
leaq -0x630(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
leaq -0x6d0(%rbp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5991
leaq -0x398(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
cvtsi2sdl -0xbc(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
xorl %r14d, %r14d
leaq -0x630(%rbp), %r13
movl -0x2c(%rbp), %ebx
cmpq %r14, -0x40(%rbp)
je 0x5623
movq -0xf8(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0xa0(%rbp)
mulsd 0x2e7e(%rip), %xmm0     # 0x8180
leaq -0x398(%rbp), %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x31f4(%rip), %rsi      # 0x850c
callq 0x21b0
movq -0xb0(%rbp), %rax
leaq (%rax,%r14,8), %rax
movq %rax, -0x60(%rbp)
movq -0xb8(%rbp), %rax
movq %r14, -0x58(%rbp)
leaq (%rax,%r14,8), %r15
xorpd %xmm0, %xmm0
xorl %r14d, %r14d
cmpq -0x48(%rbp), %r14
je 0x5396
movq %r14, %r12
imulq -0x40(%rbp), %r12
movq -0x60(%rbp), %rax
movsd %xmm0, -0x38(%rbp)
movsd (%rax,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r15,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
andpd 0x2e33(%rip), %xmm1     # 0x81c0
addsd %xmm1, %xmm0
incq %r14
jmp 0x5342
divsd -0x78(%rbp), %xmm0
leaq -0x398(%rbp), %rdi
callq 0x2270
cmpl $0x0, -0x4c(%rbp)
je 0x54e3
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,8), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %ebx, %ebx
cmpq -0x48(%rbp), %rbx
je 0x5428
movq %rbx, %r12
imulq -0x40(%rbp), %r12
movsd (%r14,%r12,8), %xmm0
movl -0x2c(%rbp), %r13d
movl %r13d, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r15,%r12,8), %xmm0
movl %r13d, %edi
leaq -0x630(%rbp), %r13
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x2dab(%rip), %xmm1     # 0x81c0
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
incq %rbx
jmp 0x53cb
leaq -0x398(%rbp), %rdi
leaq 0x30d6(%rip), %rsi      # 0x850c
callq 0x21b0
movsd -0x38(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x30b5(%rip), %rsi      # 0x850c
callq 0x21b0
movq -0x88(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,8), %r14
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
cmpq -0x48(%rbp), %r12
je 0x54cf
movq %r12, %rbx
imulq -0x40(%rbp), %rbx
movsd %xmm0, -0x38(%rbp)
movsd (%r14,%rbx,8), %xmm0
movl -0x2c(%rbp), %r13d
movl %r13d, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r15,%rbx,8), %xmm0
movl %r13d, %edi
leaq -0x630(%rbp), %r13
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
andpd 0x2cfa(%rip), %xmm1     # 0x81c0
addsd %xmm1, %xmm0
incq %r12
jmp 0x5472
divsd -0x78(%rbp), %xmm0
leaq -0x398(%rbp), %rdi
callq 0x2270
movl -0x2c(%rbp), %ebx
leaq -0x398(%rbp), %rdi
callq 0x20d0
movq %r13, %rdi
leaq 0x3015(%rip), %rsi      # 0x850e
callq 0x21b0
movq %rax, %rdi
movsd -0xa0(%rbp), %xmm0
callq 0x2270
movq %rax, %rdi
callq 0x20d0
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x88(%rbp), %rax
leaq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
xorl %r14d, %r14d
cmpq -0x48(%rbp), %r14
je 0x5617
movq %r14, %r12
imulq -0x40(%rbp), %r12
movsd (%r15,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movq %r13, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x2fb4(%rip), %rsi      # 0x8520
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movq -0x60(%rbp), %rax
movsd (%rax,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movq %r13, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x2f8c(%rip), %rsi      # 0x8528
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x4c(%rbp)
je 0x560f
movq -0x38(%rbp), %rax
movsd (%rax,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movq %r13, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x2f5a(%rip), %rsi      # 0x852c
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movq -0x70(%rbp), %rax
movsd (%rax,%r12,8), %xmm0
movl %ebx, %edi
callq 0x3c58
movq %r13, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x2f2e(%rip), %rsi      # 0x8530
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
incq %r14
jmp 0x553b
movq -0x58(%rbp), %r14
incq %r14
jmp 0x52db
leaq -0x630(%rbp), %rdi
callq 0x2220
leaq -0x398(%rbp), %rdi
callq 0x2220
leaq -0x6d0(%rbp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq -0xc8(%rbp), %rsi
callq 0x5991
leaq -0x398(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
xorl %r15d, %r15d
leaq -0x398(%rbp), %rbx
leaq 0x2e95(%rip), %r14      # 0x850c
cmpq %r15, -0x40(%rbp)
je 0x56bc
movq -0xb8(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x56b7
movq %r13, %rax
imulq -0x40(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x568b
incq %r15
jmp 0x5677
leaq -0x398(%rbp), %rdi
callq 0x20d0
xorl %r15d, %r15d
leaq -0x398(%rbp), %rbx
leaq 0x2e33(%rip), %r14      # 0x850c
cmpq %r15, -0x40(%rbp)
je 0x571e
movq -0xb0(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x5719
movq %r13, %rax
imulq -0x40(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x56ed
incq %r15
jmp 0x56d9
leaq -0x398(%rbp), %rdi
callq 0x20d0
cmpl $0x0, -0x4c(%rbp)
je 0x57f8
xorl %r15d, %r15d
leaq -0x398(%rbp), %rbx
leaq 0x2dc7(%rip), %r14      # 0x850c
cmpq %r15, -0x40(%rbp)
je 0x578a
movq -0x90(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x5785
movq %r13, %rax
imulq -0x40(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x5759
incq %r15
jmp 0x5745
leaq -0x398(%rbp), %rdi
callq 0x20d0
xorl %r15d, %r15d
leaq -0x398(%rbp), %rbx
leaq 0x2d65(%rip), %r14      # 0x850c
cmpq %r15, -0x40(%rbp)
je 0x57ec
movq -0x88(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x57e7
movq %r13, %rax
imulq -0x40(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x57bb
incq %r15
jmp 0x57a7
leaq -0x398(%rbp), %rdi
callq 0x20d0
leaq -0x398(%rbp), %rdi
callq 0x20d0
leaq -0x398(%rbp), %rdi
callq 0x2220
leaq -0x630(%rbp), %rdi
callq 0x2240
leaq -0x398(%rbp), %rdi
callq 0x2240
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7790(%rip), %rdi      # 0xcfd0
leaq 0x2aca(%rip), %rsi      # 0x8311
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
jmp 0x58a9
movq 0x7773(%rip), %rdi      # 0xcfd0
leaq 0x2b3b(%rip), %rsi      # 0x839f
jmp 0x58a4
movq 0x7763(%rip), %rdi      # 0xcfd0
leaq 0x2b88(%rip), %rsi      # 0x83fc
jmp 0x58a4
movq 0x7753(%rip), %rdi      # 0xcfd0
leaq 0x2bad(%rip), %rsi      # 0x8431
jmp 0x58a4
movq 0x7743(%rip), %rdi      # 0xcfd0
leaq 0x2bcc(%rip), %rsi      # 0x8460
jmp 0x58a4
movq 0x7733(%rip), %rdi      # 0xcfd0
leaq 0x2b2d(%rip), %rsi      # 0x83d1
callq 0x21b0
pushq $0x1
popq %rdi
callq 0x20e0
leaq 0x73c8(%rip), %rsi      # 0xcc80
movq %rax, %rdi
xorl %edx, %edx
callq 0x22d0
jmp 0x58d6
jmp 0x590b
jmp 0x590b
jmp 0x58d6
movq %rax, %r14
jmp 0x5971
jmp 0x58d6
jmp 0x590b
movq %rax, %r14
jmp 0x597d
jmp 0x590b
jmp 0x592d
jmp 0x593e
jmp 0x594f
jmp 0x5962
jmp 0x5962
jmp 0x58ee
jmp 0x5962
movq %rax, %r14
movq %r12, %rdi
callq 0x21a0
jmp 0x5965
jmp 0x590b
jmp 0x590b
jmp 0x590b
jmp 0x590b
jmp 0x591c
jmp 0x593e
jmp 0x5962
jmp 0x5962
movq %rax, %r14
leaq -0x630(%rbp), %rdi
callq 0x2240
jmp 0x597d
movq %rax, %r14
leaq -0x170(%rbp), %rdi
callq 0x416a
jmp 0x5930
movq %rax, %r14
leaq -0x198(%rbp), %rdi
callq 0x416a
jmp 0x5941
movq %rax, %r14
leaq -0x430(%rbp), %rdi
callq 0x416a
jmp 0x5952
movq %rax, %r14
leaq -0x630(%rbp), %rdi
callq 0x416a
jmp 0x5965
jmp 0x5962
movq %rax, %r14
leaq -0x108(%rbp), %rdi
callq 0x5d92
leaq -0x118(%rbp), %rdi
callq 0x5d92
leaq -0x398(%rbp), %rdi
callq 0x2240
movq %r14, %rdi
callq 0x2300