// File: /workspace/github_cpp_makefile_star2_O2/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 $0x638, %rsp            # imm = 0x638
cmpl $0x9, %edi
jle 0x5656
movq %rsi, %r15
movq 0x8(%rsi), %rdi
callq 0x21f0
movsd %xmm0, -0x48(%rbp)
movq 0x10(%r15), %rdi
callq 0x21f0
movsd %xmm0, -0x88(%rbp)
movq 0x18(%r15), %rdi
callq 0x2260
movl %eax, %r14d
movq 0x20(%r15), %rax
movq 0x28(%r15), %rdi
movzbl (%rax), %r12d
callq 0x21f0
movsd %xmm0, -0x38(%rbp)
movq 0x30(%r15), %rdi
callq 0x21f0
movsd %xmm0, -0x70(%rbp)
movq 0x38(%r15), %rdi
callq 0x2260
movl %eax, -0x58(%rbp)
movq 0x40(%r15), %rdi
callq 0x21f0
movsd %xmm0, -0x40(%rbp)
movq 0x48(%r15), %rdi
callq 0x2260
movl %eax, -0x54(%rbp)
testl %r14d, %r14d
jle 0x5666
leal -0x45(%r12), %eax
cmpl $0x10, %eax
ja 0x56ab
movl $0x10a01, %ecx          # imm = 0x10A01
btl %eax, %ecx
jae 0x56ab
xorpd %xmm0, %xmm0
movsd -0x48(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x5676
ucomisd -0x40(%rbp), %xmm0
jae 0x5686
cmpl $0x0, -0x54(%rbp)
jle 0x5696
cvttsd2si %xmm1, %ecx
movl %r14d, %eax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
movq $0x0, -0x30(%rbp)
movl %ecx, -0xb0(%rbp)
movsd -0x88(%rbp), %xmm1
cvtsi2sd %ecx, %xmm0
ucomisd %xmm0, %xmm1
jb 0x4ba0
addl $0x14, %ecx
incq -0x30(%rbp)
addq -0x48(%rbp), %rax
jmp 0x4b89
movl %r14d, -0xac(%rbp)
movq %rsp, %rcx
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
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, -0x80(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
movq -0x30(%rbp), %rax
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xc0(%rbp)
movq %rcx, %rsp
leaq -0x320(%rbp), %rbx
movq %rbx, %rdi
callq 0x22c0
leaq -0x660(%rbp), %r14
movq %r14, %rdi
movq %r15, -0x90(%rbp)
movq %r15, %rsi
xorl %edx, %edx
callq 0x576f
pushq $0x10
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2050
leaq 0x37ff(%rip), %rsi      # 0x844b
leaq -0x320(%rbp), %rdi
callq 0x21b0
movsbl %r12b, %esi
movq %rax, %rdi
callq 0x21d0
leaq 0x37ef(%rip), %rsi      # 0x845a
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x2270
leaq 0x37e1(%rip), %rsi      # 0x8468
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movsd -0x70(%rbp), %xmm0
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq 0x37c8(%rip), %rsi      # 0x8473
leaq -0x320(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
movl -0x54(%rbp), %esi
callq 0x22e0
movq %rax, %rdi
callq 0x20d0
movl -0x54(%rbp), %ecx
cvtsi2sd %ecx, %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x60(%rbp)
movl %ecx, %r13d
pushq $0x1
popq %r14
xorl %ebx, %ebx
cmpq -0x48(%rbp), %rbx
je 0x507b
leaq -0x320(%rbp), %rdi
leaq 0x377a(%rip), %rsi      # 0x8482
callq 0x21b0
leaq 0x1(%rbx), %rsi
movq %rax, %rdi
movq %rsi, -0xd8(%rbp)
callq 0x22e0
movq %rax, %rdi
leaq 0x375e(%rip), %rsi      # 0x8488
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movsbl %r12b, %esi
leaq -0xd0(%rbp), %rdi
movl -0x54(%rbp), %edx
movl %r14d, -0xb4(%rbp)
movl %r14d, %ecx
movsd -0x38(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x248c
movq -0xd0(%rbp), %r14
movq %rbx, -0xa8(%rbp)
movq %rbx, %rax
imulq -0x30(%rbp), %rax
movq -0x98(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xf8(%rbp)
movq -0x80(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xe8(%rbp)
movq -0x78(%rbp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, -0xe0(%rbp)
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0x40(%rbp)
movl -0xb0(%rbp), %ebx
cvtsi2sd %ebx, %xmm0
movsd -0x88(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x5059
cmpq $0x0, -0xa8(%rbp)
jne 0x4df2
movq -0xc0(%rbp), %rax
movq -0x40(%rbp), %rcx
movl %ebx, (%rax,%rcx,4)
leaq -0x320(%rbp), %rdi
leaq 0x368a(%rip), %rsi      # 0x848a
callq 0x21b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x22e0
movq %rax, %rdi
callq 0x20d0
leaq -0x5c0(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
pushq $0x1
popq %rsi
callq 0x4074
movq %r12, %r15
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x4e4d
movsd (%r14,%r12,8), %xmm0
movq -0x5a0(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
jmp 0x4e31
movq %r15, %r12
movsbl %r12b, %esi
leaq -0x5c0(%rbp), %rdi
movl %ebx, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x598e
movq -0xf8(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x320(%rbp), %rdi
leaq 0x360f(%rip), %rsi      # 0x8499
movsd %xmm0, -0x50(%rbp)
callq 0x21b0
movsd -0x50(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x58(%rbp)
je 0x4fe8
leaq -0x3c0(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
pushq $0x2
popq %rsi
callq 0x4074
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x4ee6
movsd (%r14,%r12,8), %xmm0
movq -0x3a0(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
jmp 0x4eca
movq %r15, %rax
movsbl %al, %esi
leaq -0x3c0(%rbp), %rdi
movl %ebx, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x598e
movq -0xe8(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x320(%rbp), %rdi
leaq 0x357d(%rip), %rsi      # 0x849f
movsd %xmm0, -0x50(%rbp)
callq 0x21b0
movsd -0x50(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq -0x120(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
pushq $0x3
popq %rsi
callq 0x4074
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x4f74
movsd (%r14,%r12,8), %xmm0
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
incq %r12
jmp 0x4f58
movq %r15, %r12
movsbl %r12b, %esi
leaq -0x120(%rbp), %rdi
movl %ebx, %edx
movsd -0x38(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x598e
movq -0xe0(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x320(%rbp), %rdi
leaq 0x34f9(%rip), %rsi      # 0x84aa
movsd %xmm0, -0x50(%rbp)
callq 0x21b0
movsd -0x50(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq -0x120(%rbp), %rdi
callq 0x416a
leaq -0x3c0(%rbp), %rdi
callq 0x416a
movq -0x5b0(%rbp), %rdx
movq -0x5a8(%rbp), %rcx
leaq -0xd0(%rbp), %rdi
movl %ebx, %esi
callq 0x26ae
movq -0xf0(%rbp), %rax
movq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0x320(%rbp), %rdi
leaq 0x349e(%rip), %rsi      # 0x84c0
movsd %xmm0, -0x50(%rbp)
callq 0x21b0
movsd -0x50(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
addl $0x14, %ebx
incq -0x40(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x416a
jmp 0x4dc4
movl -0xb4(%rbp), %r14d
incl %r14d
leaq -0xd0(%rbp), %rdi
callq 0x5b6a
movq -0xd8(%rbp), %rbx
jmp 0x4cf0
leaq -0x320(%rbp), %rdi
callq 0x2220
leaq -0x660(%rbp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq -0x90(%rbp), %rsi
callq 0x576f
leaq -0x320(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
leaq -0x5c0(%rbp), %rdi
callq 0x22c0
movl -0xac(%rbp), %r14d
leaq -0x3c0(%rbp), %rbx
pushq $0x3
popq %rdx
movq %rbx, %rdi
movq -0x90(%rbp), %rsi
callq 0x576f
leaq -0x5c0(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
xorl %eax, %eax
cmpl $0x45, %r12d
sete %al
addl $-0x3, %eax
movq %rax, -0xa8(%rbp)
cvtsi2sd %r14d, %xmm0
movsd %xmm0, -0x50(%rbp)
xorl %ebx, %ebx
cmpq %rbx, -0x30(%rbp)
je 0x5452
movq -0xc0(%rbp), %rax
movl (%rax,%rbx,4), %r14d
leaq -0x320(%rbp), %rdi
movl %r14d, %esi
callq 0x22e0
movq %rax, %rdi
leaq 0x338b(%rip), %rsi      # 0x84c8
callq 0x21b0
movq -0xa8(%rbp), %rax
movq %r14, -0x88(%rbp)
addl %eax, %r14d
movq -0x98(%rbp), %rax
leaq (%rax,%rbx,8), %rax
movq %rax, -0x40(%rbp)
movq -0xa0(%rbp), %rax
movq %rbx, -0x60(%rbp)
leaq (%rax,%rbx,8), %r13
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
leaq -0x5c0(%rbp), %rbx
cmpq -0x48(%rbp), %r15
je 0x51d6
movq %r15, %r12
imulq -0x30(%rbp), %r12
movq -0x40(%rbp), %rax
movsd %xmm0, -0x38(%rbp)
movsd (%rax,%r12,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r13,%r12,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
andpd 0x2fd3(%rip), %xmm1     # 0x81a0
addsd %xmm1, %xmm0
incq %r15
jmp 0x517f
divsd -0x50(%rbp), %xmm0
leaq -0x320(%rbp), %rdi
callq 0x2270
cmpl $0x0, -0x58(%rbp)
je 0x5314
movq -0x80(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq (%rax,%rcx,8), %r15
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %ebx, %ebx
cmpq -0x48(%rbp), %rbx
je 0x525b
movq %rbx, %r12
imulq -0x30(%rbp), %r12
movsd (%r15,%r12,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r13,%r12,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x2f58(%rip), %xmm1     # 0x81a0
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
incq %rbx
jmp 0x5208
leaq -0x320(%rbp), %rdi
leaq 0x325f(%rip), %rsi      # 0x84c8
callq 0x21b0
leaq -0x5c0(%rbp), %rbx
movsd -0x38(%rbp), %xmm0
divsd -0x50(%rbp), %xmm0
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x3237(%rip), %rsi      # 0x84c8
callq 0x21b0
movq -0x78(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq (%rax,%rcx,8), %r15
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
cmpq -0x48(%rbp), %r12
je 0x5303
movq %r12, %rbx
imulq -0x30(%rbp), %rbx
movsd %xmm0, -0x38(%rbp)
movsd (%r15,%rbx,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movaps %xmm0, -0x70(%rbp)
movsd (%r13,%rbx,8), %xmm0
leaq -0x5c0(%rbp), %rbx
movl %r14d, %edi
callq 0x3c58
movapd -0x70(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
andpd 0x2ea6(%rip), %xmm1     # 0x81a0
addsd %xmm1, %xmm0
incq %r12
jmp 0x52a9
divsd -0x50(%rbp), %xmm0
leaq -0x320(%rbp), %rdi
callq 0x2270
leaq -0x320(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
leaq 0x3160(%rip), %rsi      # 0x848a
callq 0x21b0
movq %rax, %rdi
movq -0x88(%rbp), %rsi
callq 0x22e0
movq %rax, %rdi
callq 0x20d0
movq -0x80(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x78(%rbp), %rax
leaq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
xorl %r12d, %r12d
cmpq -0x48(%rbp), %r12
je 0x5446
movq %r12, %r15
imulq -0x30(%rbp), %r15
movsd (%r13,%r15,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x3132(%rip), %rsi      # 0x84ca
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movq -0x40(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x3109(%rip), %rsi      # 0x84d2
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
cmpl $0x0, -0x58(%rbp)
je 0x543e
movq -0x38(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x30d6(%rip), %rsi      # 0x84d6
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movq -0x70(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
movl %r14d, %edi
callq 0x3c58
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x30a9(%rip), %rsi      # 0x84da
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
incq %r12
jmp 0x5365
movq -0x60(%rbp), %rbx
incq %rbx
jmp 0x510f
leaq -0x5c0(%rbp), %rdi
callq 0x2220
leaq -0x320(%rbp), %rdi
callq 0x2220
leaq -0x660(%rbp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq -0x90(%rbp), %rsi
callq 0x576f
leaq -0x320(%rbp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2050
xorl %r15d, %r15d
leaq -0x320(%rbp), %rbx
leaq 0x3022(%rip), %r14      # 0x84c8
cmpq %r15, -0x30(%rbp)
je 0x54eb
movq -0xa0(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x54e6
movq %r13, %rax
imulq -0x30(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x54ba
incq %r15
jmp 0x54a6
leaq -0x320(%rbp), %rdi
callq 0x20d0
xorl %r15d, %r15d
leaq -0x320(%rbp), %rbx
leaq 0x2fc0(%rip), %r14      # 0x84c8
cmpq %r15, -0x30(%rbp)
je 0x554d
movq -0x98(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x5548
movq %r13, %rax
imulq -0x30(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x551c
incq %r15
jmp 0x5508
leaq -0x320(%rbp), %rdi
callq 0x20d0
cmpl $0x0, -0x58(%rbp)
je 0x5621
xorl %r15d, %r15d
leaq -0x320(%rbp), %rbx
leaq 0x2f54(%rip), %r14      # 0x84c8
cmpq %r15, -0x30(%rbp)
je 0x55b6
movq -0x80(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x55b1
movq %r13, %rax
imulq -0x30(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x5585
incq %r15
jmp 0x5574
leaq -0x320(%rbp), %rdi
callq 0x20d0
xorl %r15d, %r15d
leaq -0x320(%rbp), %rbx
leaq 0x2ef5(%rip), %r14      # 0x84c8
cmpq %r15, -0x30(%rbp)
je 0x5615
movq -0x78(%rbp), %rax
leaq (%rax,%r15,8), %r12
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x5610
movq %r13, %rax
imulq -0x30(%rbp), %rax
movsd (%r12,%rax,8), %xmm0
movq %rbx, %rdi
callq 0x2270
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x55e4
incq %r15
jmp 0x55d3
leaq -0x320(%rbp), %rdi
callq 0x20d0
leaq -0x320(%rbp), %rdi
callq 0x2220
leaq -0x5c0(%rbp), %rdi
callq 0x2240
leaq -0x320(%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 0x7973(%rip), %rdi      # 0xcfd0
leaq 0x2c8d(%rip), %rsi      # 0x82f1
jmp 0x56b9
movq 0x7963(%rip), %rdi      # 0xcfd0
leaq 0x2cf6(%rip), %rsi      # 0x836a
jmp 0x56b9
movq 0x7953(%rip), %rdi      # 0xcfd0
leaq 0x2d41(%rip), %rsi      # 0x83c5
jmp 0x56b9
movq 0x7943(%rip), %rdi      # 0xcfd0
leaq 0x2d62(%rip), %rsi      # 0x83f6
jmp 0x56a4
movq 0x7933(%rip), %rdi      # 0xcfd0
leaq 0x2d7e(%rip), %rsi      # 0x8422
callq 0x21b0
jmp 0x56c6
movq 0x791e(%rip), %rdi      # 0xcfd0
leaq 0x2ce2(%rip), %rsi      # 0x839b
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
pushq $0x1
popq %rdi
callq 0x20e0
leaq 0x75ab(%rip), %rsi      # 0xcc80
movq %rax, %rdi
xorl %edx, %edx
callq 0x22d0
jmp 0x570d
jmp 0x56eb
jmp 0x570d
jmp 0x56eb
jmp 0x56eb
jmp 0x570d
movq %rax, %rbx
jmp 0x575b
jmp 0x570d
jmp 0x572f
jmp 0x5740
jmp 0x5704
jmp 0x570d
jmp 0x570d
jmp 0x570d
jmp 0x570d
jmp 0x571e
jmp 0x572f
movq %rax, %rbx
jmp 0x574f
jmp 0x5740
jmp 0x5740
movq %rax, %rbx
leaq -0x5c0(%rbp), %rdi
callq 0x2240
jmp 0x575b
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x416a
jmp 0x5732
movq %rax, %rbx
leaq -0x3c0(%rbp), %rdi
callq 0x416a
jmp 0x5743
movq %rax, %rbx
leaq -0x5c0(%rbp), %rdi
callq 0x416a
leaq -0xd0(%rbp), %rdi
callq 0x5b6a
leaq -0x320(%rbp), %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x2300