// File: /workspace/github_cpp_makefile_star2_O1/adamnovak[P]rlcsa/sampler_test.cpp
// Function: main
int main(int argc, char** argv)
{
  std::cout << "Sampler test" << std::endl;
  std::cout << std::endl;

  // Handle command line parameters.
  double multiplier = 1.0, greediness = 0.0;
  bool greedy = false, forward = true, write = false;
  char* base_name = 0;
  char* weights_name = 0;
  usint threads = 1;
  for(int i = 1; i < argc; i++)
  {
    if(argv[i][0] == '-')
    {
      switch(argv[i][1])
      {
        case 'b':
          forward = false; break;
        case 'g':
          greediness = atof(argv[i] + 2); greedy = true; break;
        case 'm':
          multiplier = atof(argv[i] + 2); break;
        case 't':
          threads = atoi(argv[i] + 2); break;
        case 'w':
          write = true; break;
        default:
          std::cout << "Invalid option: " << argv[i] << std::endl << std::endl;
          printUsage();
          return 1;
      }
    }
    else if(base_name == 0)
    {
      base_name = argv[i];
    }
    else if(weights_name == 0)
    {
      weights_name = argv[i];
    }
  }
  if(weights_name == 0) { printUsage(); return 2; }

  std::cout << "Options:";
  greediness = std::min(1.0, std::max(0.0, greediness));
  threads = std::max(threads, (usint)1); threads = std::min(threads, (usint)64);
  if(!forward) { std::cout << " backward"; }
  if(greedy) { std::cout << " greediness=" << greediness; }
  if(multiplier < 0) { multiplier = 1.0; }
  if(multiplier != 1.0) { std::cout << " multiplier=" << multiplier; }
  std::cout << " threads=" << threads;
  if(write) { std::cout << " write"; }
  std::cout << std::endl;
  std::cout << "Base name: " << base_name << std::endl;
  std::cout << "Weights: " << weights_name << std::endl;
  std::cout << std::endl;

  // Determine index parameters.
  std::string parameters_name = std::string(base_name) + PARAMETERS_EXTENSION;
  Parameters parameters;
  parameters.set(RLCSA_BLOCK_SIZE);
  parameters.set(SAMPLE_RATE);
  parameters.read(parameters_name);
  parameters.set(SUPPORT_LOCATE.first, 1);
  parameters.set(SUPPORT_DISPLAY.first, 1);
  parameters.set(WEIGHTED_SAMPLES.first, 1);
  // parameters.print();


  std::ifstream weights_file(weights_name, std::ios_base::binary);
  if(!weights_file)
  {
    std::cerr << "Error opening weights file!" << std::endl;
    return 3;
  }

  usint n = fileSize(weights_file) / sizeof(weight_type);
  weight_type* weights = new weight_type[n];
  weights_file.read((char*)weights, n * sizeof(weight_type));
  weights_file.close();
  for(usint i = 0; i < n; i++)
  {
    if(weights[i] >= 0)
    {
      weights[i] = ceil(weights[i] * multiplier);
    }
    else
    {
      std::cerr << "Negative value found: weights[" << i << "] == " << weights[i] << "!" << std::endl;
      delete[] weights;
      return 4;
    }
  }
  std::cout << "Input size:   " << n << std::endl;
  std::cout << "Sample rate:  " << parameters.get(SAMPLE_RATE) << std::endl;
  std::cout << std::endl;


  // Do the actual sampling.
  double start = readTimer();
  Sampler* sampler = 0;
  if(!greedy)
  {
    WeightedSampler* wsampler = new WeightedSampler(weights, n, forward);
    if(!(wsampler->buildSamples(parameters.get(SAMPLE_RATE), parameters.get(INITIAL_ADJUSTMENT), threads)))
    {
      delete wsampler; wsampler = 0;
      return 5;
    }
    sampler = wsampler; wsampler = 0;
  }
  else
  {
    SemiGreedySampler* gsampler = new SemiGreedySampler(weights, n);
    if(!(gsampler->buildSamples(parameters.get(SAMPLE_RATE), greediness)))
    {
      delete gsampler; gsampler = 0;
      return 5;
    }
    sampler = gsampler; gsampler = 0;
  }
  double sampled = readTimer();
  usint memory = memoryUsage();


  // Write the samples or build RLCSA.
  double stop;
  if(write)
  {
    stop = readTimer();
    sampler->writeTo(base_name);
  }
  else
  {
    std::ifstream input_file(base_name, std::ios_base::binary);
    if(!input_file)
    {
      std::cerr << "Error opening input file " << base_name << "!" << std::endl;
      return 5;
    }
    uchar* data = new uchar[n];
    input_file.read((char*)data, n);
    input_file.close();
    RLCSA rlcsa(data, n, parameters.get(RLCSA_BLOCK_SIZE), parameters.get(SAMPLE_RATE), threads, sampler, true);
    stop = readTimer();
    if(rlcsa.isOk())
    {
      rlcsa.printInfo();
      rlcsa.reportSize(true);
      rlcsa.writeTo(base_name);
    }
  }
  usint total_memory = memoryUsage();


  double sampling_time = sampled - start;
  double time = stop - start;
  double megabytes = n / (double)MEGABYTE;
  std::cout << "Total: " << time << " seconds (" << (megabytes / time) << " MB/s), " << total_memory << " kB" << std::endl;
  std::cout << "Sampling: " << sampling_time << " seconds (" << (megabytes / sampling_time) << " MB/s), " << memory << " kB" << std::endl;
  std::cout << std::endl;

  delete sampler; sampler = 0;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xcf8, %rsp            # imm = 0xCF8
movq %rsi, %r14
movl %edi, %ebx
movq 0x1a7fc(%rip), %r15     # 0x1efd0
leaq 0x12a2d(%rip), %rsi     # 0x17208
movl $0xc, %edx
movq %r15, %rdi
callq 0x32b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
cmpl $0x2, %ebx
setge %bpl
jl 0x4957
movl %ebx, %ebx
movl $0x1, %r12d
subq %rbx, %r12
movl $0x1, 0x4(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movb $0x1, %al
movl %eax, (%rsp)
movsd 0x1279c(%rip), %xmm0    # 0x17008
movapd %xmm0, 0x30(%rsp)
movl $0x2, %r13d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r15d, %r15d
movq -0x8(%r14,%r13,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x48c5
movzbl 0x1(%rdi), %eax
cmpl $0x6c, %eax
jle 0x48d6
cmpl $0x6d, %eax
je 0x491b
cmpl $0x74, %eax
je 0x4903
cmpl $0x77, %eax
jne 0x508c
movb $0x1, %al
movq %rax, 0x10(%rsp)
jmp 0x492a
cmpq $0x0, 0x20(%rsp)
je 0x48fc
testq %r15, %r15
cmoveq %rdi, %r15
jmp 0x492a
cmpl $0x62, %eax
je 0x4912
cmpl $0x67, %eax
jne 0x508c
addq $0x2, %rdi
callq 0x32d0
movsd %xmm0, 0x8(%rsp)
movb $0x1, %al
movq %rax, 0x18(%rsp)
jmp 0x492a
movq %rdi, 0x20(%rsp)
jmp 0x492a
addq $0x2, %rdi
callq 0x3390
movl %eax, 0x4(%rsp)
jmp 0x492a
movl $0x0, (%rsp)
jmp 0x492a
addq $0x2, %rdi
callq 0x32d0
movapd %xmm0, 0x30(%rsp)
cmpq %rbx, %r13
setb %bpl
leaq (%r12,%r13), %rax
incq %rax
incq %r13
cmpq $0x2, %rax
jne 0x4896
xorl %eax, %eax
movq 0x10(%rsp), %rbx
movl (%rsp), %r13d
movl 0x4(%rsp), %r14d
jmp 0x4991
xorl %r15d, %r15d
movsd 0x126a6(%rip), %xmm0    # 0x17008
movapd %xmm0, 0x30(%rsp)
movb $0x1, %r13b
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x1, %r14d
movq $0x0, 0x20(%rsp)
xorl %ebx, %ebx
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
testb $0x1, %bpl
jne 0x5511
testq %r15, %r15
je 0x4b57
movl %eax, 0x10(%rsp)
movq 0x1a621(%rip), %rdi     # 0x1efd0
leaq 0x12870(%rip), %rsi     # 0x17226
movl $0x8, %edx
callq 0x32b0
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
cmpl $0x1, %r14d
adcl $0x0, %r14d
cmpl $0x40, %r14d
movl $0x40, %eax
cmovbl %r14d, %eax
movl %eax, 0x4(%rsp)
testb $0x1, %r13b
jne 0x4a0b
movq 0x1a5d6(%rip), %rdi     # 0x1efd0
leaq 0x1282e(%rip), %rsi     # 0x1722f
movl $0x9, %edx
callq 0x32b0
movsd 0x8(%rsp), %xmm0
minsd 0x125ef(%rip), %xmm0    # 0x17008
movsd %xmm0, 0x8(%rsp)
testb $0x1, 0x18(%rsp)
movq 0x20(%rsp), %rbp
je 0x4a54
movq 0x1a59e(%rip), %r14     # 0x1efd0
leaq 0x12800(%rip), %rsi     # 0x17239
movl $0xc, %edx
movq %r14, %rdi
callq 0x32b0
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x33c0
xorpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm3
cmpltsd %xmm0, %xmm3
movsd 0x12599(%rip), %xmm0    # 0x17008
movapd %xmm3, %xmm1
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm3
orpd %xmm1, %xmm3
ucomisd %xmm0, %xmm3
movapd %xmm3, 0x30(%rsp)
jne 0x4a8d
jnp 0x4ab6
movq 0x1a53c(%rip), %r14     # 0x1efd0
leaq 0x127ab(%rip), %rsi     # 0x17246
movl $0xc, %edx
movq %r14, %rdi
callq 0x32b0
movq %r14, %rdi
movapd 0x30(%rsp), %xmm0
callq 0x33c0
movq 0x1a513(%rip), %r12     # 0x1efd0
leaq 0x1278f(%rip), %rsi     # 0x17253
movl $0x9, %edx
movq %r12, %rdi
callq 0x32b0
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x3180
testb $0x1, %bl
je 0x4afa
movq 0x1a4e7(%rip), %rdi     # 0x1efd0
leaq 0x1276d(%rip), %rsi     # 0x1725d
movl $0x6, %edx
callq 0x32b0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
leaq 0x1273b(%rip), %rsi     # 0x17264
movl $0xb, %edx
movq %r12, %rdi
callq 0x32b0
testq %rbp, %rbp
je 0x4b66
movq %rbp, %rdi
callq 0x3110
movq 0x1a486(%rip), %rdi     # 0x1efd0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x32b0
jmp 0x4b7f
callq 0x464c
movl $0x2, %eax
jmp 0x5511
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x3400
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
leaq 0x126c2(%rip), %rsi     # 0x17270
movl $0x9, %edx
movq %r12, %rdi
callq 0x32b0
movq %r15, %rdi
callq 0x3110
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32b0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
leaq 0x4c8(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
movq %rbp, %rsi
callq 0x5630
movq 0x1a6c0(%rip), %rsi     # 0x1f300
movq 0x1a6c1(%rip), %rdx     # 0x1f308
leaq 0x4c8(%rsp), %rdi
callq 0x30d0
leaq 0x58(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4c7b
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x4c83
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x4d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cbc
movq 0x4d8(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x70(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x1a6a0(%rip), %rsi     # 0x1f380
leaq 0x68(%rsp), %rdi
callq 0x14306
leaq 0x1a6b7(%rip), %rsi     # 0x1f3a8
leaq 0x68(%rsp), %rdi
callq 0x14306
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x14622
leaq 0x1a6bf(%rip), %rsi     # 0x1f3d0
leaq 0x68(%rsp), %rdi
movl $0x1, %edx
callq 0x142fa
leaq 0x1a6d1(%rip), %rsi     # 0x1f3f8
leaq 0x68(%rsp), %rdi
movl $0x1, %edx
callq 0x142fa
leaq 0x1a6e3(%rip), %rsi     # 0x1f420
leaq 0x68(%rsp), %rdi
movl $0x1, %edx
callq 0x142fa
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x3480
movq 0xb8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xd8(%rsp,%rax)
je 0x4dca
movq 0x1a272(%rip), %rbx     # 0x1eff0
leaq 0x124f5(%rip), %rsi     # 0x1727a
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x32b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x1a240(%rip), %rdi     # 0x1eff0
callq 0x3040
movl $0x3, 0x10(%rsp)
movq %rax, %rdi
callq 0x3190
jmp 0x54da
movl %r13d, (%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x14e80
movq %rax, %r15
movq %rbx, %r13
shrq $0x2, %r15
movl %r15d, %eax
movq %rax, 0x40(%rsp)
leaq (,%rax,4), %r14
movq %r14, %rdi
callq 0x3030
movq %rax, %r12
movq %r15, %rbx
leaq 0xb8(%rsp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x32e0
leaq 0xb8(%rsp), %rdi
callq 0x3090
movq %rbx, %r15
testl %ebx, %ebx
movapd 0x30(%rsp), %xmm1
je 0x4e62
movl %r15d, %ebx
xorl %r14d, %r14d
movl (%r12,%r14,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd %xmm1, %xmm0
callq 0x3080
movapd 0x30(%rsp), %xmm1
cvttsd2si %xmm0, %rax
movl %eax, (%r12,%r14,4)
incq %r14
cmpq %r14, %rbx
jne 0x4e36
movq 0x1a167(%rip), %rdi     # 0x1efd0
leaq 0x12426(%rip), %rsi     # 0x17296
movl $0xe, %edx
callq 0x32b0
movq %r15, %rbx
movl %ebx, %esi
movq 0x1a14a(%rip), %rdi     # 0x1efd0
callq 0x3180
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq 0x1a114(%rip), %rdi     # 0x1efd0
leaq 0x123e2(%rip), %rsi     # 0x172a5
movl $0xe, %edx
callq 0x32b0
leaq 0x1a4d4(%rip), %rsi     # 0x1f3a8
leaq 0x68(%rsp), %rdi
callq 0x142de
movl %eax, %esi
movq 0x1a0e9(%rip), %r15     # 0x1efd0
movq %r15, %rdi
callq 0x3180
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x1a099(%rip), %rdi     # 0x1efd0
callq 0x3040
movq %rax, %rdi
callq 0x3190
callq 0x1527b
movsd %xmm0, 0x30(%rsp)
testb $0x1, 0x18(%rsp)
je 0x4f93
movl $0x30, %edi
callq 0x3260
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0xe430
leaq 0x1a431(%rip), %rsi     # 0x1f3a8
leaq 0x68(%rsp), %rdi
callq 0x142de
movq %r15, %rdi
movl %eax, %esi
movsd 0x8(%rsp), %xmm0
callq 0xe584
jmp 0x4fea
movl $0x58, %edi
callq 0x3260
movq %rax, %r15
movzbl (%rsp), %ecx
andl $0x1, %ecx
movq %rax, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0xd15a
leaq 0x1a3ed(%rip), %rsi     # 0x1f3a8
leaq 0x68(%rsp), %rdi
callq 0x142de
movl %eax, %r14d
leaq 0x1a479(%rip), %rsi     # 0x1f448
leaq 0x68(%rsp), %rdi
callq 0x142de
movq %r15, %rdi
movl %r14d, %esi
movl %eax, %edx
movl 0x4(%rsp), %ecx
callq 0xd45a
movl %eax, %r12d
testb %al, %al
jne 0x5005
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movl $0x5, 0x10(%rsp)
xorl %r15d, %r15d
testb %r12b, %r12b
je 0x54da
callq 0x1527b
movsd %xmm0, 0x8(%rsp)
callq 0x15290
movl %eax, (%rsp)
leaq 0x4d8(%rsp), %r14
testb $0x1, %r13b
je 0x50d4
callq 0x1527b
movsd %xmm0, 0x18(%rsp)
leaq 0x4c8(%rsp), %rdi
leaq 0x2c0(%rsp), %rdx
movq %rbp, %rsi
callq 0x5630
leaq 0x4c8(%rsp), %rsi
movq %r15, %rdi
callq 0xcf96
movq 0x4c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x52fc
movq 0x4d8(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x52fc
movq 0x19f3d(%rip), %r12     # 0x1efd0
leaq 0x1217b(%rip), %rsi     # 0x17215
movl $0x10, %edx
movq %r12, %rdi
callq 0x32b0
movq -0x8(%r14,%r13,8), %r14
testq %r14, %r14
je 0x515b
movq %r14, %rdi
callq 0x3110
movq 0x19f0c(%rip), %rdi     # 0x1efd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x32b0
jmp 0x5174
leaq 0x2c0(%rsp), %rdi
movq %rbp, %rsi
movl $0x4, %edx
callq 0x3480
movq 0x2c0(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x2e0(%rsp,%rax), %ebp
testb $0x5, %bpl
je 0x51de
movq 0x19ee3(%rip), %rdi     # 0x1eff0
leaq 0x121a0(%rip), %rsi     # 0x172b4
movl $0x19, %edx
callq 0x32b0
movq 0x19ecb(%rip), %rdi     # 0x1eff0
movq 0x20(%rsp), %rsi
callq 0x3240
movq %rax, %rbx
leaq 0x126ec(%rip), %rsi     # 0x17825
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq %rbx, %rdi
callq 0x3120
movl $0x5, 0x10(%rsp)
jmp 0x52e5
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x3400
movq 0x10(%rsp), %rbx
movl (%rsp), %r13d
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
callq 0x464c
movl $0x1, %eax
jmp 0x4950
movq 0x40(%rsp), %rdi
callq 0x3030
movq %rax, %r14
leaq 0x2c0(%rsp), %rdi
movq %rax, %rsi
movq 0x40(%rsp), %rdx
callq 0x32e0
leaq 0x2c0(%rsp), %rdi
callq 0x3090
leaq 0x1a16c(%rip), %rsi     # 0x1f380
leaq 0x68(%rsp), %rdi
callq 0x142de
movl %eax, %r12d
leaq 0x1a180(%rip), %rsi     # 0x1f3a8
leaq 0x68(%rsp), %rdi
callq 0x142de
leaq 0x4c8(%rsp), %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r12d, %ecx
movl %eax, %r8d
movl 0x4(%rsp), %r9d
pushq $0x1
pushq %r15
callq 0x6510
addq $0x10, %rsp
callq 0x1527b
movsd %xmm0, 0x18(%rsp)
cmpb $0x1, 0x4c8(%rsp)
jne 0x52d8
leaq 0x4c8(%rsp), %rdi
callq 0x8d14
leaq 0x4c8(%rsp), %rdi
movl $0x1, %esi
callq 0x8a6c
leaq 0x98(%rsp), %rdi
leaq 0x2f(%rsp), %rdx
movq 0x20(%rsp), %rsi
callq 0x5630
leaq 0x4c8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x6d42
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x52d8
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x4c8(%rsp), %rdi
callq 0x6c84
leaq 0x2c0(%rsp), %rdi
callq 0x30a0
testb $0x5, %bpl
jne 0x54da
callq 0x15290
movl %eax, %ebx
movq 0x19cc6(%rip), %rdi     # 0x1efd0
leaq 0x11fbd(%rip), %rsi     # 0x172ce
movl $0x7, %edx
callq 0x32b0
movsd 0x18(%rsp), %xmm0
subsd 0x30(%rsp), %xmm0
movq 0x19ca2(%rip), %rdi     # 0x1efd0
movsd %xmm0, 0x18(%rsp)
callq 0x33c0
movq %rax, %r14
leaq 0x11f93(%rip), %rsi     # 0x172d6
movl $0xa, %edx
movq %rax, %rdi
callq 0x32b0
xorps %xmm0, %xmm0
cvtsi2sdq 0x40(%rsp), %xmm0
mulsd 0x11cae(%rip), %xmm0    # 0x17010
movsd %xmm0, 0x20(%rsp)
divsd 0x18(%rsp), %xmm0
movq %r14, %rdi
callq 0x33c0
movq %rax, %r14
leaq 0x11f61(%rip), %rsi     # 0x172e1
movl $0x8, %edx
movq %rax, %rdi
callq 0x32b0
movl %ebx, %esi
movq %r14, %rdi
callq 0x3180
movq %rax, %rbx
leaq 0x11f49(%rip), %rsi     # 0x172ea
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq 0x19bf4(%rip), %rdi     # 0x1efd0
leaq 0x11f0b(%rip), %rsi     # 0x172ee
movl $0xa, %edx
callq 0x32b0
movsd 0x8(%rsp), %xmm0
subsd 0x30(%rsp), %xmm0
movq 0x19bd0(%rip), %rbx     # 0x1efd0
movq %rbx, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x33c0
movq %rax, %r14
leaq 0x11ebe(%rip), %rsi     # 0x172d6
movl $0xa, %edx
movq %rax, %rdi
callq 0x32b0
movsd 0x20(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
movq %r14, %rdi
callq 0x33c0
movq %rax, %r14
leaq 0x11e9e(%rip), %rsi     # 0x172e1
movl $0x8, %edx
movq %rax, %rdi
callq 0x32b0
movl (%rsp), %esi
movq %r14, %rdi
callq 0x3180
movq %rax, %r14
leaq 0x11e85(%rip), %rsi     # 0x172ea
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq 0x19b19(%rip), %rdi     # 0x1efd0
callq 0x3040
movq %rax, %rdi
callq 0x3190
movl $0x0, 0x10(%rsp)
testq %r15, %r15
je 0x54da
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
leaq 0xb8(%rsp), %rdi
callq 0x30a0
leaq 0x68(%rsp), %rdi
callq 0x5694
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x550d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3270
movl 0x10(%rsp), %eax
addq $0xcf8, %rsp            # imm = 0xCF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x554e
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x554e
jmp 0x554b
movq %rax, %rbx
leaq 0x4c8(%rsp), %rdi
callq 0x6c84
jmp 0x55ad
movq %rax, %rbx
movq 0x4c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x55f5
movq 0x4d8(%rsp), %rsi
incq %rsi
jmp 0x55a3
jmp 0x55f2
jmp 0x55f2
jmp 0x55f2
jmp 0x55aa
jmp 0x55aa
jmp 0x55f2
jmp 0x55f2
jmp 0x55f2
movq %rax, %rbx
movl $0x58, %esi
jmp 0x55a0
movq %rax, %rbx
movl $0x30, %esi
movq %r15, %rdi
callq 0x3270
jmp 0x55f5
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x30a0
jmp 0x55f5
jmp 0x55f2
jmp 0x55f2
jmp 0x55f2
jmp 0x55f2
jmp 0x55ed
movq %rax, %rbx
leaq 0x4d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5628
movq 0x4d8(%rsp), %rsi
jmp 0x5620
movq %rax, %rbx
jmp 0x5628
jmp 0x55f2
jmp 0x55f2
movq %rax, %rbx
jmp 0x5602
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x30a0
leaq 0x68(%rsp), %rdi
callq 0x5694
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5628
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3460