// File: /workspace/github_cpp_makefile_star2_O3/ashlall[P]StreamStats/ChiSquareExperiments/VaryMemoryReal.cpp
// Function: main
int main(int argc, char* argv[])
{
  if (argc < 6)
  {
    cout << "usage: VaryMemoryReal lower-memory upper-memory filename1 filename2 num_bins\n";
    exit(1);
  }

  double lower = atof(argv[1]), upper = atof(argv[2]);
  char *filename1 = argv[3], *filename2 = argv[4];
  int num_buckets = atoi(argv[5]);

  if (lower <=0 || upper <= 0)
  {
    cout << "The memory must be greater than 0.\n";
    exit(1);
  }
  if (num_buckets <= 0)
  {
    cout << "The number of buckets must be greater than 0.\n";
    exit(1);
  }

  // finds the number of times the experiment will run
  double memory_percent;
  int repeats = 0;
  double mem = lower;
  while (mem <= (upper + 0.0000001)) // accounts for rounding error
  {
    repeats++;
    mem *= sqrt(10);
  }

  double actual_values[repeats];
  double GK_values[repeats];
  double QD_values[repeats];
  double RS_values[repeats];
  double percents[repeats];
  std::vector<double> data1, data2;

  // creates and initializes the log file
  ofstream data_file;
  char str[100];
  name_file(str, argv, 0);
  data_file.open(str);
  ifstream input_file;
  char output[100];
  int stream_size1 = 0, stream_size2 = 0;

  std::default_random_engine generator(1);
  std::uniform_real_distribution<double> distribution(0.0, 1.0);

  input_file.open(filename1);
  while (!input_file.eof())
  {
    input_file >> output;
    data1.push_back(atof(output) + (distribution(generator) * 0.000000001));
    stream_size1++;
  }
  input_file.close();

  input_file.open(filename2);
  while (!input_file.eof())
  {
    input_file >> output;
    data2.push_back(atof(output) + (distribution(generator) * 0.000000001));
    stream_size2++;
  }
  input_file.close();

  data_file << filename1 << endl << filename2 << endl;
  data_file << "num_buckets: " << num_buckets << endl;
  data_file << "stream 1 size: " << stream_size1 << endl;
  data_file << "stream 2 size: " << stream_size2 << endl;
  memory_percent = lower;
  int i = 0;
  while (memory_percent <= (upper + 0.00000001)) //accounts for rounding
  {
    data_file << "memory percent: " << memory_percent << endl;
    percents[i] = memory_percent;
    int sample_size1 = memory_percent * stream_size1;
    int sample_size2 = memory_percent * stream_size2;

    // calculates GK statistic
    ChiSquareContinuous GK_sketch1(sample_size1,1);
    for (std::vector<double>::iterator j = data1.begin(); j != data1.end();j++)
      GK_sketch1.insert(*j);
    ChiSquareContinuous GK_sketch2(sample_size2,1);
    for (std::vector<double>::iterator j = data2.begin(); j != data2.end();j++)
      GK_sketch2.insert(*j);
    
    double GK_stat = GK_sketch1.two_sample_statistic(GK_sketch2, num_buckets);
    GK_values[i] = GK_stat;
    data_file << "GK = " << GK_stat << endl;

    // calculates real statistic
    double *upper_intervals = GK_sketch1.get_upper();
    double *lower_intervals = GK_sketch1.get_lower();
    double constant_1 = sqrt((double)stream_size2/stream_size1);
    double constant_2 = sqrt((double)stream_size1/stream_size2);
    double chi_squared = 0;

    for (int i = 0; i < num_buckets; i++)
    {
      double frequency1 = 0, frequency2 = 0;
      for (std::vector<double>::iterator j = data1.begin(); j!=data1.end();j++)
	{
        if (*j <= upper_intervals[i+1] && *j > lower_intervals[i+1])
          frequency1++;
      }
      for (std::vector<double>::iterator j = data2.begin(); j!=data2.end();j++)
      {
        if (*j <= upper_intervals[i+1] && *j > lower_intervals[i+1])
	  frequency2++;
      }

      double lambda = frequency1 * constant_1 - frequency2 * constant_2;
      chi_squared += (lambda * lambda) / (frequency1 + frequency2);
    }

    actual_values[i] = chi_squared;
    data_file << "actual = " << chi_squared << endl;

    memory_percent *= sqrt(10);
    i++;
  }
  data_file.close();

  // creates pvalue file
  name_file(str, argv, 3);
  data_file.open(str);
  
  // creates table file
  ofstream data2_file;
  name_file(str, argv, 1);
  data2_file.open(str);

  // creates extra file
  ofstream data3_file;
  name_file(str, argv, 2);
  data3_file.open(str);

  int deg_freedom = num_buckets;
  if (stream_size1 != stream_size2)
    deg_freedom--;
  for (int i = 0; i < repeats; i++)
  {
    // adds values to the table
    data2_file << percents[i] * 100 << "\t";
    double error = abs(pochisq(GK_values[i], deg_freedom) - pochisq(actual_values[i], deg_freedom));
    data2_file << error << endl;

    // adds values to pvalue file
    data_file << pochisq(actual_values[i], deg_freedom) << " actual" << endl;
    data_file << pochisq(GK_values[i], deg_freedom) << " GK" << endl;

    // adds values to extra file
    data3_file << percents[i] * 100 << "\t";
    error = abs(GK_values[i] - actual_values[i]) / actual_values[i]; 
    data3_file << error << endl;
  }
  data3_file.close();
  data2_file.close();
  data_file.close();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x9a8, %rsp            # imm = 0x9A8
cmpl $0x5, %edi
jle 0x5a0c
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x2280
movsd %xmm0, -0x50(%rbp)
movq 0x10(%rbx), %rdi
callq 0x2280
movsd %xmm0, -0x58(%rbp)
movq 0x18(%rbx), %r15
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %rdi
callq 0x22f0
movsd -0x58(%rbp), %xmm1
movl %eax, -0x2c(%rbp)
xorpd %xmm0, %xmm0
ucomisd -0x50(%rbp), %xmm0
jae 0x5a1c
ucomisd %xmm1, %xmm0
jae 0x5a1c
cmpl $0x0, -0x2c(%rbp)
jle 0x5a2c
movsd 0x33fa(%rip), %xmm0     # 0x8168
addsd -0x58(%rbp), %xmm0
xorl %eax, %eax
ucomisd -0x50(%rbp), %xmm0
jb 0x4d97
xorl %eax, %eax
movsd 0x33ea(%rip), %xmm1     # 0x8170
movsd -0x50(%rbp), %xmm2
incl %eax
mulsd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jae 0x4d8b
movq %rbx, -0x68(%rbp)
movl %eax, %eax
movq %rsp, %rcx
movq %rax, -0xb8(%rbp)
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xc0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xc8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xd0(%rbp)
movq %rcx, %rsp
xorl %eax, %eax
movq %rax, -0x90(%rbp)
xorpd %xmm0, %xmm0
movapd %xmm0, -0xa0(%rbp)
movq %rax, -0x70(%rbp)
movapd %xmm0, -0x80(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x2360
leaq -0x560(%rbp), %rbx
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0x5af9
leaq -0x4f0(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x2f0(%rbp), %rdi
callq 0x2250
movq $0x1, -0xd8(%rbp)
leaq -0x2f0(%rbp), %rdi
movq %r15, -0x40(%rbp)
movq %r15, %rsi
movl $0x8, %edx
callq 0x2160
movq %r14, -0xb0(%rbp)
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
movl $0x0, -0x30(%rbp)
testb $0x2, -0x2d0(%rbp,%rax)
jne 0x4fae
movl $0x0, -0x30(%rbp)
leaq -0x2f0(%rbp), %rbx
leaq -0x9d0(%rbp), %r12
leaq -0xd8(%rbp), %r14
leaq -0x760(%rbp), %r13
movq -0x2e0(%rbp,%rax), %r15
movl $0x64, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2380
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2d0(%rbp,%rax)
jne 0x4ef9
addq $-0x65, %r15
cmpq $-0x65, %r15
ja 0x4ef9
movq -0x208(%rbp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x4f79
movq %r12, %rdi
callq 0x2280
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
callq 0x751b
addsd 0x327a(%rip), %xmm0     # 0x8190
mulsd 0x325a(%rip), %xmm0     # 0x8178
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x760(%rbp)
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
je 0x4f4c
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, -0x98(%rbp)
jmp 0x4f5b
leaq -0xa0(%rbp), %rdi
movq %r13, %rdx
callq 0x765e
incl -0x30(%rbp)
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x2d0(%rbp,%rax)
je 0x4eac
jmp 0x4fae
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x4ef9
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x2f0, %rdi           # imm = 0xFD10
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x2350
jmp 0x4ef9
leaq -0x2f0(%rbp), %rdi
callq 0x2090
movq -0xb0(%rbp), %rsi
leaq -0x2f0(%rbp), %rdi
movl $0x8, %edx
callq 0x2160
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
xorl %r12d, %r12d
testb $0x2, -0x2d0(%rbp,%rax)
jne 0x50fc
xorl %r12d, %r12d
leaq -0x2f0(%rbp), %rbx
leaq -0x9d0(%rbp), %r14
leaq -0xd8(%rbp), %r13
movq -0x2e0(%rbp,%rax), %r15
movl $0x64, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2380
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2d0(%rbp,%rax)
jne 0x504f
addq $-0x65, %r15
cmpq $-0x65, %r15
ja 0x504f
movq -0x208(%rbp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x50c7
movq %r14, %rdi
callq 0x2280
movsd %xmm0, -0x38(%rbp)
movq %r13, %rdi
callq 0x751b
addsd 0x3124(%rip), %xmm0     # 0x8190
mulsd 0x3104(%rip), %xmm0     # 0x8178
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x760(%rbp)
movq -0x78(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x5099
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, -0x78(%rbp)
jmp 0x50a9
leaq -0x80(%rbp), %rdi
leaq -0x760(%rbp), %rdx
callq 0x765e
incl %r12d
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x2d0(%rbp,%rax)
je 0x5006
jmp 0x50fc
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x504f
movq -0x2f0(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x2f0, %rdi           # imm = 0xFD10
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x2350
jmp 0x504f
leaq -0x2f0(%rbp), %rdi
callq 0x2090
movq -0xb0(%rbp), %r14
movq -0x40(%rbp), %rbx
testq %rbx, %rbx
je 0x5134
movq %rbx, %rdi
callq 0x2100
leaq -0x4f0(%rbp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2260
jmp 0x5155
movq -0x4f0(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x4f0, %rdi           # imm = 0xFB10
movl 0x20(%rdi), %esi
orl $0x1, %esi
callq 0x2350
movq -0x4f0(%rbp), %rax
leaq -0x4f0(%rbp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
leaq -0x4f0(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %rbx
testq %r14, %r14
je 0x51a8
movq %r14, %rdi
callq 0x2100
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2260
jmp 0x51c1
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2350
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x314e(%rip), %rsi      # 0x833d
leaq -0x4f0(%rbp), %rdi
movl $0xd, %edx
callq 0x2260
leaq -0x4f0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2390
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x310b(%rip), %rsi      # 0x834b
leaq -0x4f0(%rbp), %rdi
movl $0xf, %edx
callq 0x2260
leaq -0x4f0(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x2390
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x30ca(%rip), %rsi      # 0x835b
leaq -0x4f0(%rbp), %rdi
movl $0xf, %edx
callq 0x2260
leaq -0x4f0(%rbp), %rdi
movl %r12d, %esi
callq 0x2390
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl %r12d, -0x5c(%rbp)
movsd -0x58(%rbp), %xmm0
addsd 0x2e94(%rip), %xmm0     # 0x8180
movsd %xmm0, -0x58(%rbp)
ucomisd -0x50(%rbp), %xmm0
jb 0x565f
cvtsi2sdl -0x30(%rbp), %xmm1
cvtsi2sdl -0x5c(%rbp), %xmm2
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0xe8(%rbp)
movapd %xmm1, %xmm0
movsd %xmm2, -0xe0(%rbp)
divsd %xmm2, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
movl -0x2c(%rbp), %r12d
xorl %r14d, %r14d
leaq -0x4f0(%rbp), %r13
movl $0x10, %edx
movq %r13, %rdi
leaq 0x3013(%rip), %rsi      # 0x836b
callq 0x2260
movq %r13, %rdi
movsd -0x50(%rbp), %xmm0
callq 0x2300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq -0xd0(%rbp), %rax
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax,%r14,8)
mulsd -0xe8(%rbp), %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
leaq -0x760(%rbp), %rdi
movl $0x1, %esi
callq 0x4158
movq -0xa0(%rbp), %r15
cmpq -0x98(%rbp), %r15
je 0x53f8
movq -0x740(%rbp), %rbx
movsd (%r15), %xmm0
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
addq $0x8, %r15
cmpq -0x98(%rbp), %r15
jne 0x53de
movsd -0x50(%rbp), %xmm0
mulsd -0xe0(%rbp), %xmm0
cvttsd2si %xmm0, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq -0x960(%rbp), %rdi
movl $0x1, %esi
callq 0x4158
movq -0x80(%rbp), %r15
cmpq -0x78(%rbp), %r15
je 0x5449
movq -0x940(%rbp), %rbx
movsd (%r15), %xmm0
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
addq $0x8, %r15
cmpq -0x78(%rbp), %r15
jne 0x5432
leaq -0x760(%rbp), %rdi
leaq -0x960(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x4a1a
movq -0xc8(%rbp), %rax
movsd %xmm0, (%rax,%r14,8)
movl $0x5, %edx
movq %r13, %rdi
leaq 0x2f01(%rip), %rsi      # 0x837c
movsd %xmm0, -0x40(%rbp)
callq 0x2260
movsd -0x40(%rbp), %xmm0
movq %r13, %rdi
callq 0x2300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq -0x750(%rbp), %rbx
movq -0x748(%rbp), %r13
movq -0xa0(%rbp), %rax
movq -0x98(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rsi
xorpd %xmm4, %xmm4
xorl %edi, %edi
xorpd %xmm0, %xmm0
cmpq %rcx, %rax
je 0x551d
movsd 0x8(%rbx,%rdi,8), %xmm1
movq %rax, %r8
movsd (%r8), %xmm2
ucomisd %xmm2, %xmm1
jb 0x5514
ucomisd 0x8(%r13,%rdi,8), %xmm2
jbe 0x5514
addsd 0x2afc(%rip), %xmm0     # 0x8010
addq $0x8, %r8
cmpq %rcx, %r8
jne 0x54f8
incq %rdi
cmpq %rsi, %rdx
je 0x5558
movsd (%rbx,%rdi,8), %xmm2
xorpd %xmm1, %xmm1
movq %rdx, %r8
movsd (%r8), %xmm3
ucomisd %xmm3, %xmm2
jb 0x554d
ucomisd (%r13,%rdi,8), %xmm3
jbe 0x554d
addsd 0x2ac3(%rip), %xmm1     # 0x8010
addq $0x8, %r8
cmpq %rsi, %r8
jne 0x5531
jmp 0x555c
xorpd %xmm1, %xmm1
movsd -0xb0(%rbp), %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
mulsd -0x38(%rbp), %xmm3
subsd %xmm2, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm1, %xmm0
divsd %xmm0, %xmm3
addsd %xmm3, %xmm4
cmpq %r12, %rdi
jne 0x54e6
movq -0xc0(%rbp), %rax
movsd %xmm4, (%rax,%r14,8)
movl $0x9, %edx
leaq -0x4f0(%rbp), %rdi
leaq 0x2dd4(%rip), %rsi      # 0x8382
movsd %xmm4, -0x40(%rbp)
callq 0x2260
leaq -0x4f0(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
callq 0x2300
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movsd -0x50(%rbp), %xmm0
mulsd 0x2b70(%rip), %xmm0     # 0x8170
movsd %xmm0, -0x50(%rbp)
incq %r14
movq -0x940(%rbp), %rdi
callq 0x2210
movq -0x950(%rbp), %rdi
callq 0x2210
movq -0x948(%rbp), %rdi
callq 0x2210
movq -0x740(%rbp), %rdi
callq 0x2210
movq %rbx, %rdi
callq 0x2210
movq %r13, %rdi
callq 0x2210
movsd -0x58(%rbp), %xmm0
ucomisd -0x50(%rbp), %xmm0
leaq -0x4f0(%rbp), %r13
jae 0x5349
leaq -0x4f0(%rbp), %rdi
callq 0x22b0
leaq -0x560(%rbp), %rbx
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movl $0x3, %edx
callq 0x5af9
leaq -0x4f0(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x760(%rbp), %rdi
callq 0x2360
movl -0x5c(%rbp), %r14d
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movl $0x1, %edx
callq 0x5af9
leaq -0x760(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x960(%rbp), %rdi
callq 0x2360
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movl $0x2, %edx
callq 0x5af9
leaq -0x960(%rbp), %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2060
xorl %eax, %eax
cmpl %r14d, -0x30(%rbp)
setne %cl
cmpq $0x0, -0xb8(%rbp)
je 0x5912
movb %cl, %al
subl %eax, -0x2c(%rbp)
xorl %r14d, %r14d
leaq 0x2c69(%rip), %r15      # 0x838c
leaq -0x4f0(%rbp), %r12
leaq -0x960(%rbp), %r13
movq -0xd0(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
mulsd 0x2a42(%rip), %xmm0     # 0x8188
leaq -0x760(%rbp), %rdi
movsd %xmm0, -0x40(%rbp)
callq 0x2300
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2260
movq -0xc8(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
movaps %xmm0, -0xb0(%rbp)
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
callq 0x3cd1
movaps %xmm0, -0x50(%rbp)
movq -0xc0(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movl %ebx, %edi
callq 0x3cd1
movapd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
andpd 0x2a0d(%rip), %xmm1     # 0x81c0
movapd %xmm1, %xmm0
leaq -0x760(%rbp), %rdi
callq 0x2300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movsd -0x38(%rbp), %xmm0
movl -0x2c(%rbp), %edi
callq 0x3cd1
movq %r12, %rdi
callq 0x2300
movq %rax, %rbx
movl $0x7, %edx
movq %rax, %rdi
leaq 0x2b7a(%rip), %rsi      # 0x838e
callq 0x2260
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movapd -0xb0(%rbp), %xmm0
movl -0x2c(%rbp), %edi
callq 0x3cd1
movq %r12, %rdi
callq 0x2300
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2b2c(%rip), %rsi      # 0x8396
callq 0x2260
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %r13, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x2300
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2260
movapd -0xb0(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm1, %xmm0
andpd 0x28f4(%rip), %xmm0     # 0x81c0
divsd %xmm1, %xmm0
movq %r13, %rdi
callq 0x2300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
incq %r14
cmpq %r14, -0xb8(%rbp)
jne 0x5731
leaq -0x960(%rbp), %r15
movq %r15, %rdi
callq 0x22b0
leaq -0x760(%rbp), %r14
movq %r14, %rdi
callq 0x22b0
leaq -0x4f0(%rbp), %rbx
movq %rbx, %rdi
callq 0x22b0
movq 0x6682(%rip), %rax      # 0xbfc8
movq (%rax), %r12
movq 0x18(%rax), %r13
leaq -0x958(%rbp), %rdi
movq %r12, -0x8(%rdi)
movq -0x18(%r12), %rax
movq %r13, -0x960(%rbp,%rax)
callq 0x21e0
movl $0xf8, %eax
addq %rax, %r15
movq %r15, %rdi
callq 0x20d0
leaq -0x758(%rbp), %rdi
movq %r12, -0x8(%rdi)
movq -0x18(%r12), %rax
movq %r13, -0x760(%rbp,%rax)
callq 0x21e0
movl $0xf8, %r15d
addq %r15, %r14
movq %r14, %rdi
callq 0x20d0
leaq -0x2f0(%rbp), %rdi
callq 0x20a0
leaq -0x4e8(%rbp), %rdi
movq %r12, -0x8(%rdi)
movq -0x18(%r12), %rax
movq %r13, -0x4f0(%rbp,%rax)
callq 0x21e0
addq %r15, %rbx
movq %rbx, %rdi
callq 0x20d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x59ea
callq 0x2210
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x59fb
callq 0x2210
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x65bd(%rip), %rdi      # 0xbfd0
leaq 0x2882(%rip), %rsi      # 0x829c
jmp 0x5a3a
movq 0x65ad(%rip), %rdi      # 0xbfd0
leaq 0x28c0(%rip), %rsi      # 0x82ea
jmp 0x5a3a
movq 0x659d(%rip), %rdi      # 0xbfd0
leaq 0x28d4(%rip), %rsi      # 0x830e
callq 0x2230
movl $0x1, %edi
callq 0x2270
jmp 0x5a9f
jmp 0x5a4d
movq %rax, %rbx
jmp 0x5aae
jmp 0x5a76
jmp 0x5a56
movq %rax, %rbx
jmp 0x5ac6
movq %rax, %rbx
jmp 0x5ad2
jmp 0x5a76
jmp 0x5a9f
jmp 0x5a8e
jmp 0x5a76
jmp 0x5a76
jmp 0x5a76
jmp 0x5a76
jmp 0x5a76
jmp 0x5a76
jmp 0x5a9f
jmp 0x5a7d
movq %rax, %rbx
jmp 0x5aba
jmp 0x5a7d
movq %rax, %rbx
leaq -0x960(%rbp), %rdi
callq 0x42f6
jmp 0x5a91
movq %rax, %rbx
leaq -0x760(%rbp), %rdi
callq 0x42f6
jmp 0x5aba
movq %rax, %rbx
leaq -0x960(%rbp), %rdi
callq 0x22d0
leaq -0x760(%rbp), %rdi
callq 0x22d0
leaq -0x2f0(%rbp), %rdi
callq 0x20a0
leaq -0x4f0(%rbp), %rdi
callq 0x22d0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x5ae0
callq 0x2210
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x5af1
callq 0x2210
movq %rbx, %rdi
callq 0x23b0