// File: /workspace/github_cpp_makefile_star2_O1/ashlall[P]StreamStats/ChiSquareExperiments/VaryBinsOneSample.cpp
// Function: main
int main(int argc, char* argv[])
{
  if (argc < 10)
  {
    cout << "usage: VaryBinsOneSample lower-bins upper-bins num-streams(>0) [N|U|P|E] location scale [0|1] memory-percent stream-size" << 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 stream_size = 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 number of bins 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 (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
  int num_buckets;
  int num_sizes = 0, size = lower;
  while (size <= upper)
  {
    num_sizes++;
    size += 20;
  }

  // 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 bins[num_sizes];
  int sample_size = memory_percent * stream_size;

  // 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;
  data_file << "stream_size = " << stream_size << endl;

  for (int i = 0; i < data_repeats; i++) // runs all tests data_repeats times
  {
    num_buckets = lower;
    int j = 0;
    data_file << "Pass " << 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 (num_buckets <= upper)  // runs tests for every number of buckets
    {
      if (i == 0)
        bins[j] = num_buckets;
      data_file << "num_buckets = " << num_buckets << endl;
      
      // computes GK estimate
      ChiSquareContinuous sketch1(sample_size, 1); 
      for (int i = 0; i < stream_size; i++)
        sketch1.insert(stream[i]);
      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;

      num_buckets += 20;
      j++;
    }
    seed++; // changes seed for next repeat
  }
  data_file.close();

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

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

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

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

    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 << "num_buckets = " << bins[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_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 $0x658, %rsp            # imm = 0x658
cmpl $0x9, %edi
jle 0x631a
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x2240
movapd %xmm0, -0xc0(%rbp)
movq 0x10(%rbx), %rdi
callq 0x2240
movsd %xmm0, -0x68(%rbp)
movq 0x18(%rbx), %rdi
callq 0x22a0
movq %rbx, %r14
movl %eax, %ebx
movq 0x20(%r14), %rax
movq 0x28(%r14), %rdi
movb (%rax), %r15b
callq 0x2240
movsd %xmm0, -0x38(%rbp)
movq 0x30(%r14), %rdi
callq 0x2240
movsd %xmm0, -0x40(%rbp)
movq 0x38(%r14), %rdi
callq 0x22a0
movl %eax, -0x60(%rbp)
movq 0x40(%r14), %rdi
callq 0x2240
movsd %xmm0, -0x80(%rbp)
movq %r14, -0xc8(%rbp)
movq 0x48(%r14), %rdi
callq 0x22a0
movl %eax, -0x5c(%rbp)
movl %ebx, -0x4c(%rbp)
testl %ebx, %ebx
jle 0x632a
movzbl %r15b, %eax
addl $-0x45, %eax
cmpl $0x10, %eax
ja 0x636f
movl $0x10a01, %ecx          # imm = 0x10A01
btl %eax, %ecx
jae 0x636f
xorpd %xmm0, %xmm0
movapd -0xc0(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x633a
ucomisd -0x80(%rbp), %xmm0
jae 0x634a
cmpl $0x0, -0x5c(%rbp)
jle 0x635a
movb %r15b, -0x29(%rbp)
cvttsd2si %xmm1, %eax
movq %rax, -0xd8(%rbp)
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
xorl %eax, %eax
movsd -0x68(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x5379
movq -0xd8(%rbp), %rax
leal 0x14(%rax), %ecx
xorl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
incl %eax
addl $0x14, %ecx
ucomisd %xmm0, %xmm1
jae 0x5367
movl -0x4c(%rbp), %ecx
movl %eax, %edx
imulq %rdx, %rcx
leaq 0xf(,%rcx,8), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x98(%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 %rdx, -0x48(%rbp)
leaq 0xf(,%rdx,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xf8(%rbp)
movq %rcx, %rsp
leaq -0x340(%rbp), %rbx
movq %rbx, %rdi
callq 0x2300
leaq -0x680(%rbp), %r14
movq %r14, %rdi
movq -0xc8(%rbp), %rsi
xorl %edx, %edx
callq 0x6491
movq %rbx, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2060
leaq 0x401f(%rip), %rsi      # 0x944b
leaq -0x340(%rbp), %rdi
movl $0xe, %edx
callq 0x2220
leaq -0x540(%rbp), %rsi
movb -0x29(%rbp), %al
movb %al, (%rsi)
leaq -0x340(%rbp), %rdi
movl $0x1, %edx
callq 0x2220
movq %rax, %rbx
leaq 0x3ff6(%rip), %rsi      # 0x945a
movl $0xd, %edx
movq %rax, %rdi
callq 0x2220
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x22b0
movq %rax, %rbx
leaq 0x3fe0(%rip), %rsi      # 0x9468
movl $0xa, %edx
movq %rax, %rdi
callq 0x2220
movq %rbx, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x22b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x3fa0(%rip), %rsi      # 0x9473
leaq -0x340(%rbp), %rdi
movl $0xe, %edx
callq 0x2220
leaq -0x340(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x2320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movl -0x5c(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd -0x80(%rbp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
xorps %xmm0, %xmm0
cvtsi2sdl -0xd8(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xc0(%rbp)
cmpl $0x2, %ecx
movl $0x1, %r15d
movl %ecx, %ebx
cmovll %r15d, %ebx
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0xa8(%rbp)
movq $0x0, -0x70(%rbp)
movsbl -0x29(%rbp), %eax
movl %eax, -0x80(%rbp)
movl $0x5, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3ee6(%rip), %rsi      # 0x9482
callq 0x2220
movq -0x70(%rbp), %rax
leaq 0x1(%rax), %r12
leaq -0x340(%rbp), %rdi
movl %r12d, %esi
callq 0x2320
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3ebe(%rip), %rsi      # 0x9488
callq 0x2220
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq %r12, -0x108(%rbp)
leaq -0x118(%rbp), %rdi
movl -0x80(%rbp), %esi
movl -0x5c(%rbp), %edx
movl %r15d, -0xe0(%rbp)
movl %r15d, %ecx
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x24fc
movsd -0x68(%rbp), %xmm0
ucomisd -0x100(%rbp), %xmm0
movq -0x118(%rbp), %r12
jb 0x59f1
movq -0x70(%rbp), %rax
imulq -0x48(%rbp), %rax
movq -0x98(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xd0(%rbp)
movq -0x90(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xf0(%rbp)
movq -0x88(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xe8(%rbp)
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0xb0(%rbp)
xorl %r15d, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
cmpq $0x0, -0x70(%rbp)
jne 0x56ad
movq -0xf8(%rbp), %rax
movl %r14d, (%rax,%r15,4)
movl $0xe, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3dca(%rip), %rsi      # 0x948a
callq 0x2220
leaq -0x340(%rbp), %rdi
movl %r14d, %esi
callq 0x2320
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq -0x540(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
movl $0x1, %esi
callq 0x4694
xorl %r13d, %r13d
movsd (%r12,%r13,8), %xmm0
movq -0x520(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r13
cmpq %r13, %rbx
jne 0x571a
leaq -0x540(%rbp), %rdi
movl -0x80(%rbp), %esi
movl %r14d, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x66b2
movq -0xd0(%rbp), %rax
movsd %xmm0, (%rax,%r15,8)
movl $0x5, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3d29(%rip), %rsi      # 0x9499
movsd %xmm0, -0x58(%rbp)
callq 0x2220
movsd -0x58(%rbp), %xmm0
leaq -0x340(%rbp), %rdi
callq 0x22b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
cmpl $0x0, -0x60(%rbp)
je 0x5945
leaq -0x5e0(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
movl $0x2, %esi
callq 0x4694
xorl %r13d, %r13d
movsd (%r12,%r13,8), %xmm0
movq -0x5c0(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r13
cmpq %r13, %rbx
jne 0x57db
leaq -0x5e0(%rbp), %rdi
movl -0x80(%rbp), %esi
movl %r14d, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x66b2
movq -0xf0(%rbp), %rax
movsd %xmm0, (%rax,%r15,8)
movl $0xa, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3c6e(%rip), %rsi      # 0x949f
movsd %xmm0, -0x58(%rbp)
callq 0x2220
movsd -0x58(%rbp), %xmm0
leaq -0x340(%rbp), %rdi
callq 0x22b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq -0x140(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
movl $0x3, %esi
callq 0x4694
xorl %r13d, %r13d
movsd (%r12,%r13,8), %xmm0
movq -0x120(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r13
cmpq %r13, %rbx
jne 0x5892
leaq -0x140(%rbp), %rdi
movl -0x80(%rbp), %esi
movl %r14d, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x66b2
movq -0xe8(%rbp), %rax
movsd %xmm0, (%rax,%r15,8)
movl $0x15, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3bc2(%rip), %rsi      # 0x94aa
movsd %xmm0, -0x58(%rbp)
callq 0x2220
movsd -0x58(%rbp), %xmm0
leaq -0x340(%rbp), %rdi
callq 0x22b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq -0x140(%rbp), %rdi
callq 0x4834
leaq -0x5e0(%rbp), %rdi
callq 0x4834
movq -0x530(%rbp), %rdx
movq -0x528(%rbp), %rcx
leaq -0x118(%rbp), %rdi
movl %r14d, %esi
callq 0x2742
movq -0xb0(%rbp), %rax
movsd %xmm0, (%rax,%r15,8)
movl $0x7, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3b3e(%rip), %rsi      # 0x94c0
movsd %xmm0, -0x58(%rbp)
callq 0x2220
movsd -0x58(%rbp), %xmm0
leaq -0x340(%rbp), %rdi
callq 0x22b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
addl $0x14, %r14d
incq %r15
leaq -0x540(%rbp), %rdi
callq 0x4834
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd -0x68(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x569b
testq %r12, %r12
je 0x59fe
movq %r12, %rdi
callq 0x2250
movl -0xe0(%rbp), %r15d
incl %r15d
movq -0x108(%rbp), %rcx
movq %rcx, -0x70(%rbp)
cmpq -0xa8(%rbp), %rcx
jne 0x5589
leaq -0x340(%rbp), %rdi
callq 0x2270
leaq -0x680(%rbp), %rbx
movq %rbx, %rdi
movq -0xc8(%rbp), %rsi
movl $0x1, %edx
callq 0x6491
leaq -0x340(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x540(%rbp), %rdi
callq 0x2300
leaq -0x5e0(%rbp), %rbx
movq %rbx, %rdi
movq -0xc8(%rbp), %rsi
movl $0x3, %edx
callq 0x6491
leaq -0x540(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
cmpq $0x0, -0x48(%rbp)
movb -0x29(%rbp), %al
je 0x5f57
xorl %ecx, %ecx
cmpb $0x45, %al
sete %cl
addl $-0x3, %ecx
movq %rcx, -0xe0(%rbp)
xorps %xmm0, %xmm0
cvtsi2sdl -0x4c(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rax
movq %rax, -0x40(%rbp)
xorl %ecx, %ecx
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rbx
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %r13
movq %rbx, -0xd0(%rbp)
movq %r13, -0x68(%rbp)
movq %rdx, -0x58(%rbp)
movq %rax, -0x70(%rbp)
movq -0xf8(%rbp), %rax
movq %rcx, -0xe8(%rbp)
movl (%rax,%rcx,4), %ebx
leaq -0x340(%rbp), %rdi
movl %ebx, %esi
callq 0x2320
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3994(%rip), %rsi      # 0x94c8
callq 0x2220
movq -0xe0(%rbp), %rax
movq %rbx, -0xf0(%rbp)
leal (%rbx,%rax), %r12d
xorpd %xmm1, %xmm1
movq -0xa8(%rbp), %r14
xorl %r15d, %r15d
movq -0x58(%rbp), %r13
movq -0x68(%rbp), %rbx
movsd %xmm1, -0x38(%rbp)
movsd (%r13,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movaps %xmm0, -0x80(%rbp)
movsd (%rbx,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movsd -0x38(%rbp), %xmm1
movapd -0x80(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x3603(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq -0x40(%rbp), %r15
decq %r14
jne 0x5b61
movl %r12d, -0x38(%rbp)
divsd -0xb0(%rbp), %xmm1
leaq -0x340(%rbp), %rdi
movapd %xmm1, %xmm0
callq 0x22b0
cmpl $0x0, -0x60(%rbp)
je 0x5d07
xorpd %xmm1, %xmm1
movq -0xa8(%rbp), %r14
xorl %r15d, %r15d
movq -0x68(%rbp), %rbx
movq -0xd0(%rbp), %r13
movl -0x38(%rbp), %r12d
movsd %xmm1, -0x80(%rbp)
movsd (%r13,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movaps %xmm0, -0xc0(%rbp)
movsd (%rbx,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movsd -0x80(%rbp), %xmm1
movapd -0xc0(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x3571(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq -0x40(%rbp), %r15
decq %r14
jne 0x5bed
movsd %xmm1, -0x80(%rbp)
movl $0x1, %edx
leaq -0x340(%rbp), %rdi
leaq 0x3874(%rip), %rsi      # 0x94c8
callq 0x2220
movsd -0x80(%rbp), %xmm0
divsd -0xb0(%rbp), %xmm0
leaq -0x340(%rbp), %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3847(%rip), %rsi      # 0x94c8
callq 0x2220
xorpd %xmm1, %xmm1
movq -0xa8(%rbp), %r14
xorl %r15d, %r15d
movq -0x70(%rbp), %r13
movq -0x68(%rbp), %rbx
movl -0x38(%rbp), %r12d
movsd %xmm1, -0x80(%rbp)
movsd (%r13,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movaps %xmm0, -0xc0(%rbp)
movsd (%rbx,%r15), %xmm0
movl %r12d, %edi
callq 0x420e
movsd -0x80(%rbp), %xmm1
movapd -0xc0(%rbp), %xmm2
subsd %xmm0, %xmm2
andpd 0x34be(%rip), %xmm2     # 0x91a0
addsd %xmm2, %xmm1
addq -0x40(%rbp), %r15
decq %r14
jne 0x5ca0
divsd -0xb0(%rbp), %xmm1
leaq -0x340(%rbp), %rdi
movapd %xmm1, %xmm0
callq 0x22b0
movq -0x340(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x340(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
leaq -0x340(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movl $0xe, %edx
leaq -0x540(%rbp), %rdi
leaq 0x373a(%rip), %rsi      # 0x948a
callq 0x2220
leaq -0x540(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x2320
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq -0xa8(%rbp), %r14
xorl %r15d, %r15d
movq -0x68(%rbp), %r13
movq -0xd0(%rbp), %rbx
movsd (%r13,%r15), %xmm0
movl -0x38(%rbp), %edi
callq 0x420e
leaq -0x540(%rbp), %rdi
callq 0x22b0
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x36f6(%rip), %rsi      # 0x94ca
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq -0x58(%rbp), %rax
movsd (%rax,%r15), %xmm0
movl -0x38(%rbp), %edi
callq 0x420e
leaq -0x540(%rbp), %rdi
callq 0x22b0
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x36a1(%rip), %rsi      # 0x94d2
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
cmpl $0x0, -0x60(%rbp)
je 0x5f1e
movsd (%rbx,%r15), %xmm0
movl -0x38(%rbp), %edi
callq 0x420e
leaq -0x540(%rbp), %rdi
callq 0x22b0
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x3642(%rip), %rsi      # 0x94d6
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq -0x70(%rbp), %rax
movsd (%rax,%r15), %xmm0
movl -0x38(%rbp), %edi
callq 0x420e
leaq -0x540(%rbp), %rdi
callq 0x22b0
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x35e9(%rip), %rsi      # 0x94da
callq 0x2220
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
addq -0x40(%rbp), %r15
decq %r14
jne 0x5da7
movq -0xe8(%rbp), %rcx
incq %rcx
addq $0x8, %r13
movq -0x58(%rbp), %rdx
addq $0x8, %rdx
addq $0x8, %rbx
movq -0x70(%rbp), %rax
addq $0x8, %rax
cmpq -0x48(%rbp), %rcx
jne 0x5af3
leaq -0x540(%rbp), %rdi
callq 0x2270
leaq -0x340(%rbp), %rdi
callq 0x2270
leaq -0x680(%rbp), %r15
movq %r15, %rdi
movq -0xc8(%rbp), %rsi
movl $0x2, %edx
callq 0x6491
leaq -0x340(%rbp), %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x2060
cmpq $0x0, -0x48(%rbp)
movq -0xa0(%rbp), %r14
je 0x6026
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x340(%rbp), %r15
leaq 0x34ee(%rip), %r12      # 0x94c8
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %r13
movq %r14, -0xa0(%rbp)
movsd (%r14), %xmm0
movq %r15, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
addq %rbx, %r14
decq %r13
jne 0x5fe9
movq -0x38(%rbp), %rax
incq %rax
movq -0xa0(%rbp), %r14
addq $0x8, %r14
cmpq -0x48(%rbp), %rax
jne 0x5fda
movq -0x340(%rbp), %rax
leaq -0x340(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
leaq -0x340(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
cmpq $0x0, -0x48(%rbp)
movq -0x98(%rbp), %r14
je 0x60e1
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x340(%rbp), %r15
leaq 0x3433(%rip), %r12      # 0x94c8
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %r13
movq %r14, -0x98(%rbp)
movsd (%r14), %xmm0
movq %r15, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
addq %rbx, %r14
decq %r13
jne 0x60a4
movq -0x38(%rbp), %rax
incq %rax
movq -0x98(%rbp), %r14
addq $0x8, %r14
cmpq -0x48(%rbp), %rax
jne 0x6095
movq -0x340(%rbp), %rax
leaq -0x340(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
leaq -0x340(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
cmpl $0x0, -0x60(%rbp)
je 0x6294
cmpq $0x0, -0x48(%rbp)
movq -0x90(%rbp), %r14
je 0x61a6
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x340(%rbp), %r15
leaq 0x336e(%rip), %r12      # 0x94c8
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %r13
movq %r14, -0x90(%rbp)
movsd (%r14), %xmm0
movq %r15, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
addq %rbx, %r14
decq %r13
jne 0x6169
movq -0x38(%rbp), %rax
incq %rax
movq -0x90(%rbp), %r14
addq $0x8, %r14
cmpq -0x48(%rbp), %rax
jne 0x615a
movq -0x340(%rbp), %rax
leaq -0x340(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
leaq -0x340(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
cmpq $0x0, -0x48(%rbp)
movq -0x88(%rbp), %r14
je 0x6261
movl -0x4c(%rbp), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rbx
xorl %eax, %eax
leaq -0x340(%rbp), %r15
leaq 0x32b3(%rip), %r12      # 0x94c8
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %r13
movq %r14, -0x88(%rbp)
movsd (%r14), %xmm0
movq %r15, %rdi
callq 0x22b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
addq %rbx, %r14
decq %r13
jne 0x6224
movq -0x38(%rbp), %rax
incq %rax
movq -0x88(%rbp), %r14
addq $0x8, %r14
cmpq -0x48(%rbp), %rax
jne 0x6215
movq -0x340(%rbp), %rax
leaq -0x340(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
leaq -0x340(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq -0x340(%rbp), %r14
movq %r14, %rdi
callq 0x2270
movq 0x6d1e(%rip), %rax      # 0xcfc8
movq (%rax), %rbx
movq 0x18(%rax), %r15
leaq -0x538(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r15, -0x540(%rbp,%rax)
callq 0x21b0
movl $0xf8, %r12d
leaq -0x540(%rbp), %rdi
addq %r12, %rdi
callq 0x20b0
leaq -0x338(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r15, -0x340(%rbp,%rax)
callq 0x21b0
addq %r12, %r14
movq %r14, %rdi
callq 0x20b0
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6caf(%rip), %rdi      # 0xcfd0
leaq 0x2fc9(%rip), %rsi      # 0x92f1
jmp 0x637d
movq 0x6c9f(%rip), %rdi      # 0xcfd0
leaq 0x3032(%rip), %rsi      # 0x936a
jmp 0x637d
movq 0x6c8f(%rip), %rdi      # 0xcfd0
leaq 0x307d(%rip), %rsi      # 0x93c5
jmp 0x637d
movq 0x6c7f(%rip), %rdi      # 0xcfd0
leaq 0x309e(%rip), %rsi      # 0x93f6
jmp 0x6368
movq 0x6c6f(%rip), %rdi      # 0xcfd0
leaq 0x30ba(%rip), %rsi      # 0x9422
callq 0x2200
jmp 0x638a
movq 0x6c5a(%rip), %rdi      # 0xcfd0
leaq 0x301e(%rip), %rsi      # 0x939b
callq 0x2200
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2100
leaq 0x68dd(%rip), %rsi      # 0xcc78
movq %rax, %rdi
xorl %edx, %edx
callq 0x2310
jmp 0x63f8
jmp 0x63b1
jmp 0x63f8
jmp 0x63b1
jmp 0x63b1
jmp 0x63f8
movq %rax, %rbx
jmp 0x6453
jmp 0x63f8
jmp 0x63e7
jmp 0x6433
jmp 0x63cd
jmp 0x63f8
jmp 0x63f8
jmp 0x63f8
jmp 0x63f8
jmp 0x63d6
jmp 0x63e7
movq %rax, %rbx
jmp 0x6442
jmp 0x6433
jmp 0x6433
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x4834
jmp 0x63ea
movq %rax, %rbx
leaq -0x5e0(%rbp), %rdi
callq 0x4834
jmp 0x6436
movq %rax, %rbx
movq 0x6bc6(%rip), %rax      # 0xcfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x538(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x540(%rbp,%rcx)
callq 0x21b0
leaq -0x448(%rbp), %rdi
callq 0x20b0
jmp 0x6453
movq %rax, %rbx
leaq -0x540(%rbp), %rdi
callq 0x4834
movq -0x118(%rbp), %rdi
testq %rdi, %rdi
je 0x6453
callq 0x2250
movq 0x6b6e(%rip), %rax      # 0xcfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x338(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x340(%rbp,%rcx)
callq 0x21b0
leaq -0x248(%rbp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2340