// File: ingowald[P]closestSurfacePointQueries/examples/benchmark.cpp
// Function: main
int main(int ac, char **av)
{
  if (ac != 2)
    throw std::runtime_error("usage: ./distanceTest <directory_with_dumps>");
  const std::string dir = av[1];

  loadTriangles(dir+"/triang_input.txt");
  loadPoints(dir+"/point_input.txt");

  bool couldLoadReference = true;
  try {
//     loadReference(dir+"/dennis.dist.txt");
    loadReference(dir+"/tim.xyzs.txt");
    loadDennis(dir+"/dennis.dist.txt");
  } catch (std::runtime_error e) {
    couldLoadReference = false;
    printf("********************** could NOT load reference results **********************\n");
  }

  
  auto begin = std::chrono::system_clock::now();
  std::cout << "creating embree query object" << std::endl;
  distance_query_scene scene
    = rtdqNewTriangleMeshdi(vertex_x.data(),vertex_y.data(),vertex_z.data(),1,
                            index_x.data(),index_y.data(),index_z.data(),1,
                            index_x.size());
  auto done_build = std::chrono::system_clock::now();

  result_dist.resize(point_x.size());
  result_x.resize(point_x.size());
  result_y.resize(point_x.size());
  result_z.resize(point_x.size());

  std::cout << "calling query (scalar)" << std::endl;
  rtdqComputeClosestPointsdi(scene,
                             // closest point:
                             result_x.data(),
                             result_y.data(),
                             result_z.data(),
                             1,
                             // distance:
                             result_dist.data(),1,
                             // no prim IDs
                             NULL,0,
                             // input: the query points
                             point_x.data(),point_y.data(),point_z.data(),1,
                             // num points:
                             point_x.size());
  auto done_all = std::chrono::system_clock::now();
  
  size_t numPoints = point_x.size();
  size_t numTriangles = index_x.size();

  std::chrono::duration<double> buildTime = done_build - begin;
  std::chrono::duration<double> queryTime = done_all   - done_build;
  std::cout << "time to build tree " << (1000.f*buildTime.count()) << "ms" << std::endl;
  std::cout << "time to query " << numPoints << " points: " << queryTime.count() << "s" << std::endl;
  std::cout << "(this is " << (1000000.f * queryTime.count()/numPoints) << " micro seconds/query)" << std::endl;

  if (couldLoadReference) {
  double most_further_tim_mag = 0.f;
  double most_further_tim_myDist;
  double most_further_tim_hisDist;
  double most_further_tim_input[3];
  double most_further_tim_result[3];

  double most_closer_tim_mag = 0.f;
  double most_closer_tim_myDist;
  double most_closer_tim_hisDist;
  double most_closer_tim_input[3];
  double most_closer_tim_result[3];


  double most_further_dennis_mag = 0.f;
  double most_further_dennis_myDist;
  double most_further_dennis_hisDist;
  double most_further_dennis_input[3];
  double most_further_dennis_result[3];

  double most_closer_dennis_mag = 0.f;
  double most_closer_dennis_myDist;
  double most_closer_dennis_hisDist;
  double most_closer_dennis_input[3];
  double most_closer_dennis_result[3];


  std::cout << "echcking ..." << std::endl;
  for (int i=0;i<point_x.size();i++) {

    printf("results for %8i: mine %18.16f    tim %18.16f    dennis %18.16f\n",i,result_dist[i],reference_dist[i],dennis_dist[i]);
    

    float closer_dennis = dennis_dist[i] - result_dist[i];
    if (closer_dennis > most_closer_dennis_mag) {
      most_closer_dennis_mag = closer_dennis;
      most_closer_dennis_input[0] = point_x[i];
      most_closer_dennis_input[1] = point_y[i];
      most_closer_dennis_input[2] = point_z[i];
      most_closer_dennis_result[0] = result_x[i];
      most_closer_dennis_result[1] = result_y[i];
      most_closer_dennis_result[2] = result_z[i];
      most_closer_dennis_myDist    = result_dist[i];
      most_closer_dennis_hisDist    = dennis_dist[i];
    }

    float further_dennis = result_dist[i] - dennis_dist[i];
    if (further_dennis > most_further_dennis_mag) {
      most_further_dennis_mag = further_dennis;
      most_further_dennis_input[0] = point_x[i];
      most_further_dennis_input[1] = point_y[i];
      most_further_dennis_input[2] = point_z[i];
      most_further_dennis_result[0] = result_x[i];
      most_further_dennis_result[1] = result_y[i];
      most_further_dennis_result[2] = result_z[i];
      most_further_dennis_myDist    = result_dist[i];
      most_further_dennis_hisDist    = dennis_dist[i];
    }

    float closer_tim = reference_dist[i] - result_dist[i];
    if (closer_tim > most_closer_tim_mag) {
      most_closer_tim_mag = closer_tim;
      most_closer_tim_input[0] = point_x[i];
      most_closer_tim_input[1] = point_y[i];
      most_closer_tim_input[2] = point_z[i];
      most_closer_tim_result[0] = result_x[i];
      most_closer_tim_result[1] = result_y[i];
      most_closer_tim_result[2] = result_z[i];
      most_closer_tim_myDist    = result_dist[i];
      most_closer_tim_hisDist    = reference_dist[i];
    }

    float further_tim = result_dist[i] - reference_dist[i];
    if (further_tim > most_further_tim_mag) {
      most_further_tim_mag = further_tim;
      most_further_tim_input[0] = point_x[i];
      most_further_tim_input[1] = point_y[i];
      most_further_tim_input[2] = point_z[i];
      most_further_tim_result[0] = result_x[i];
      most_further_tim_result[1] = result_y[i];
      most_further_tim_result[2] = result_z[i];
      most_further_tim_myDist    = result_dist[i];
      most_further_tim_hisDist    = reference_dist[i];
    }


  }
  printf("biggest dist (to tim) where we're closer: input %g %g %g ours %g %g %g dist %g his-dist %g\n",
         most_closer_tim_input[0],
         most_closer_tim_input[1],
         most_closer_tim_input[2],
         most_closer_tim_result[0],
         most_closer_tim_result[1],
         most_closer_tim_result[2],
         most_closer_tim_myDist,
         most_closer_tim_hisDist);
  printf("biggest dist (to tim) where we're further: input %g %g %g ours %g %g %g dist %g his-dist %g\n",
         most_further_tim_input[0],
         most_further_tim_input[1],
         most_further_tim_input[2],
         most_further_tim_result[0],
         most_further_tim_result[1],
         most_further_tim_result[2],
         most_further_tim_myDist,
         most_further_tim_hisDist);
         
  printf("biggest dist (to dennis) where we're closer: input %g %g %g ours %g %g %g dist %g his-dist %g\n",
         most_closer_dennis_input[0],
         most_closer_dennis_input[1],
         most_closer_dennis_input[2],
         most_closer_dennis_result[0],
         most_closer_dennis_result[1],
         most_closer_dennis_result[2],
         most_closer_dennis_myDist,
         most_closer_dennis_hisDist);
  printf("biggest dist (to dennis) where we're further: input %g %g %g ours %g %g %g dist %g his-dist %g\n",
         most_further_dennis_input[0],
         most_further_dennis_input[1],
         most_further_dennis_input[2],
         most_further_dennis_result[0],
         most_further_dennis_result[1],
         most_further_dennis_result[2],
         most_further_dennis_myDist,
         most_further_dennis_hisDist);
         
  }
  rtdqDestroy(scene);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movl $0x0, -0xc(%rbp)
movl %edi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpl $0x2, -0x10(%rbp)
je 0x4a0c
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2a0(%rbp)
leaq 0xc832(%rip), %rsi      # 0x11200
callq 0x30d0
jmp 0x49d5
movq -0x2a0(%rbp), %rdi
movq 0x1360d(%rip), %rsi     # 0x17ff0
movq 0x135de(%rip), %rdx     # 0x17fc8
callq 0x33c0
movq -0x2a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x31d0
jmp 0x5a5c
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x33f0
movq -0x2b0(%rbp), %rsi
movq -0x2a8(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x5f70
jmp 0x4a44
leaq -0x49(%rbp), %rdi
callq 0x32c0
leaq 0xc7d9(%rip), %rdx      # 0x1122d
leaq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6020
jmp 0x4a63
leaq -0x70(%rbp), %rdi
callq 0x3a00
jmp 0x4a6e
leaq -0x70(%rbp), %rdi
callq 0x3180
leaq 0xc7c1(%rip), %rdx      # 0x1123f
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6020
jmp 0x4a90
leaq -0x90(%rbp), %rdi
callq 0x4750
jmp 0x4a9e
leaq -0x90(%rbp), %rdi
callq 0x3180
movb $0x1, -0x91(%rbp)
leaq 0xc798(%rip), %rdx      # 0x11250
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6020
jmp 0x4aca
leaq -0xb8(%rbp), %rdi
callq 0x4270
jmp 0x4ad8
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq 0xc773(%rip), %rdx      # 0x1125e
leaq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6020
jmp 0x4afd
leaq -0xd8(%rbp), %rdi
callq 0x4510
jmp 0x4b0b
leaq -0xd8(%rbp), %rdi
callq 0x3180
jmp 0x4c25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x32c0
jmp 0x5a5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x5a53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3180
jmp 0x5a53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3180
jmp 0x5a53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x4bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3180
jmp 0x4bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3180
movl -0x24(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5a53
movq -0x20(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x3320
movq %rax, %rsi
leaq -0xe8(%rbp), %rdi
callq 0x3100
movq -0x2b8(%rbp), %rdi
callq 0x30e0
movb $0x0, -0x91(%rbp)
leaq 0xc668(%rip), %rdi      # 0x1126f
xorl %eax, %eax
callq 0x3030
jmp 0x4c10
leaq -0xe8(%rbp), %rdi
callq 0x3488
callq 0x33b0
jmp 0x4c23
jmp 0x4c25
callq 0x3040
movq %rax, -0xf0(%rbp)
movq 0x13398(%rip), %rdi     # 0x17fd0
leaq 0xc680(%rip), %rsi      # 0x112bf
callq 0x3260
movq %rax, -0x2c0(%rbp)
jmp 0x4c4d
movq -0x2c0(%rbp), %rdi
movq 0x1335d(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x4c62
leaq 0x1364f(%rip), %rdi     # 0x182b8
callq 0x60b0
movq %rax, -0x2f0(%rbp)
leaq 0x13654(%rip), %rdi     # 0x182d0
callq 0x60b0
movq %rax, -0x2e8(%rbp)
leaq 0x13659(%rip), %rdi     # 0x182e8
callq 0x60b0
movq %rax, -0x2e0(%rbp)
leaq 0x1365e(%rip), %rdi     # 0x18300
movq %rdi, -0x300(%rbp)
callq 0x60d0
movq %rax, -0x2d8(%rbp)
leaq 0x1365c(%rip), %rdi     # 0x18318
callq 0x60d0
movq %rax, -0x2d0(%rbp)
leaq 0x13661(%rip), %rdi     # 0x18330
callq 0x60d0
movq -0x300(%rbp), %rdi
movq %rax, -0x2f8(%rbp)
callq 0x5f50
movq -0x2f8(%rbp), %rcx
movq -0x2f0(%rbp), %rdi
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
movq -0x2d8(%rbp), %r8
movq -0x2d0(%rbp), %r9
movq %rax, %r10
movq %rsp, %rax
movq %r10, 0x10(%rax)
movq %rcx, (%rax)
movq $0x1, 0x8(%rax)
movl $0x1, %ecx
callq 0x82d0
movq %rax, -0x2c8(%rbp)
jmp 0x4d39
movq -0x2c8(%rbp), %rax
movq %rax, -0xf8(%rbp)
callq 0x3040
movq %rax, -0x100(%rbp)
leaq 0x13516(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, %rsi
leaq 0x13627(%rip), %rdi     # 0x18390
callq 0x60f0
jmp 0x4d70
leaq 0x134f9(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, %rsi
leaq 0x135c2(%rip), %rdi     # 0x18348
callq 0x60f0
jmp 0x4d8d
leaq 0x134dc(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, %rsi
leaq 0x135bd(%rip), %rdi     # 0x18360
callq 0x60f0
jmp 0x4daa
leaq 0x134bf(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, %rsi
leaq 0x135b8(%rip), %rdi     # 0x18378
callq 0x60f0
jmp 0x4dc7
movq 0x13202(%rip), %rdi     # 0x17fd0
leaq 0xc507(%rip), %rsi      # 0x112dc
callq 0x3260
movq %rax, -0x308(%rbp)
jmp 0x4de3
movq -0x308(%rbp), %rdi
movq 0x131c7(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x4df8
movq -0xf8(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq 0x1353b(%rip), %rdi     # 0x18348
callq 0x60b0
movq %rax, -0x330(%rbp)
leaq 0x13540(%rip), %rdi     # 0x18360
callq 0x60b0
movq %rax, -0x328(%rbp)
leaq 0x13545(%rip), %rdi     # 0x18378
callq 0x60b0
movq %rax, -0x320(%rbp)
leaq 0x1354a(%rip), %rdi     # 0x18390
callq 0x60b0
movq %rax, -0x318(%rbp)
leaq 0x13417(%rip), %rdi     # 0x18270
movq %rdi, -0x358(%rbp)
callq 0x60b0
movq %rax, -0x340(%rbp)
leaq 0x13415(%rip), %rdi     # 0x18288
callq 0x60b0
movq %rax, -0x348(%rbp)
leaq 0x1341a(%rip), %rdi     # 0x182a0
callq 0x60b0
movq -0x358(%rbp), %rdi
movq %rax, -0x350(%rbp)
callq 0x5e60
movq -0x350(%rbp), %r11
movq -0x348(%rbp), %r10
movq -0x340(%rbp), %r8
movq -0x338(%rbp), %rdi
movq -0x330(%rbp), %rsi
movq -0x328(%rbp), %rdx
movq -0x320(%rbp), %rcx
movq -0x318(%rbp), %r9
movq %rax, %rbx
movq %rsp, %rax
movq %rax, -0x310(%rbp)
movq %rbx, 0x38(%rax)
movq %r11, 0x28(%rax)
movq %r10, 0x20(%rax)
movq %r8, 0x18(%rax)
movq $0x1, 0x30(%rax)
movq $0x0, 0x10(%rax)
movq $0x0, 0x8(%rax)
movq $0x1, (%rax)
movl $0x1, %r8d
callq 0x8b40
jmp 0x4f1f
callq 0x3040
movq %rax, -0x108(%rbp)
leaq 0x1333e(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, -0x110(%rbp)
leaq 0x133bb(%rip), %rdi     # 0x18300
callq 0x5f50
movq %rax, -0x118(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x6180
movq %rax, -0x360(%rbp)
jmp 0x4f6d
movq -0x360(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x61d0
jmp 0x4f90
leaq -0x108(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6180
movq %rax, -0x368(%rbp)
jmp 0x4fac
movq -0x368(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x61d0
jmp 0x4fcf
movq 0x12ffa(%rip), %rdi     # 0x17fd0
leaq 0xc316(%rip), %rsi      # 0x112f3
callq 0x3260
movq %rax, -0x370(%rbp)
jmp 0x4feb
leaq -0x120(%rbp), %rdi
callq 0x6210
movsd %xmm0, -0x378(%rbp)
jmp 0x5001
movq -0x370(%rbp), %rdi
movsd -0x378(%rbp), %xmm0
movsd 0xbff0(%rip), %xmm1     # 0x11008
mulsd %xmm1, %xmm0
callq 0x3430
movq %rax, -0x380(%rbp)
jmp 0x502a
movq -0x380(%rbp), %rdi
leaq 0xc2cf(%rip), %rsi      # 0x11307
callq 0x3260
movq %rax, -0x388(%rbp)
jmp 0x5046
movq -0x388(%rbp), %rdi
movq 0x12f64(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x505b
movq 0x12f6e(%rip), %rdi     # 0x17fd0
leaq 0xc2a1(%rip), %rsi      # 0x1130a
callq 0x3260
movq %rax, -0x390(%rbp)
jmp 0x5077
movq -0x390(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x3080
movq %rax, -0x398(%rbp)
jmp 0x5093
movq -0x398(%rbp), %rdi
leaq 0xc278(%rip), %rsi      # 0x11319
callq 0x3260
movq %rax, -0x3a0(%rbp)
jmp 0x50af
leaq -0x130(%rbp), %rdi
callq 0x6210
movsd %xmm0, -0x3a8(%rbp)
jmp 0x50c5
movsd -0x3a8(%rbp), %xmm0
movq -0x3a0(%rbp), %rdi
callq 0x3430
movq %rax, -0x3b0(%rbp)
jmp 0x50e2
movq -0x3b0(%rbp), %rdi
leaq 0xc019(%rip), %rsi      # 0x11109
callq 0x3260
movq %rax, -0x3b8(%rbp)
jmp 0x50fe
movq -0x3b8(%rbp), %rdi
movq 0x12eac(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x5113
movq 0x12eb6(%rip), %rdi     # 0x17fd0
leaq 0xc202(%rip), %rsi      # 0x11323
callq 0x3260
movq %rax, -0x3c0(%rbp)
jmp 0x512f
leaq -0x130(%rbp), %rdi
callq 0x6210
movsd %xmm0, -0x3c8(%rbp)
jmp 0x5145
movq -0x3c0(%rbp), %rdi
movsd -0x3c8(%rbp), %xmm0
movsd 0xbeb4(%rip), %xmm1     # 0x11010
mulsd %xmm1, %xmm0
movaps 0xbeb9(%rip), %xmm2     # 0x11020
movq -0x110(%rbp), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xbeb5(%rip), %xmm2     # 0x11030
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x3430
movq %rax, -0x3d0(%rbp)
jmp 0x519c
movq -0x3d0(%rbp), %rdi
leaq 0xc183(%rip), %rsi      # 0x1132d
callq 0x3260
movq %rax, -0x3d8(%rbp)
jmp 0x51b8
movq -0x3d8(%rbp), %rdi
movq 0x12df2(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x51cd
testb $0x1, -0x91(%rbp)
je 0x5a2f
movq $0x0, -0x140(%rbp)
movq $0x0, -0x198(%rbp)
movq $0x0, -0x1e8(%rbp)
movq $0x0, -0x238(%rbp)
movq 0x12dc3(%rip), %rdi     # 0x17fd0
leaq 0xc12f(%rip), %rsi      # 0x11343
callq 0x3260
movq %rax, -0x3e0(%rbp)
jmp 0x5222
movq -0x3e0(%rbp), %rdi
movq 0x12d88(%rip), %rsi     # 0x17fb8
callq 0x32a0
jmp 0x5237
movl $0x0, -0x284(%rbp)
movslq -0x284(%rbp), %rax
movq %rax, -0x3e8(%rbp)
leaq 0x1301a(%rip), %rdi     # 0x18270
callq 0x5e60
movq %rax, %rcx
movq -0x3e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x58ed
movl -0x284(%rbp), %eax
movl %eax, -0x3fc(%rbp)
movslq %eax, %rsi
leaq 0x1310c(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x3f8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x13105(%rip), %rdi     # 0x183a8
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x3f0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x13146(%rip), %rdi     # 0x18408
callq 0x6230
movl -0x3fc(%rbp), %esi
movsd -0x3f8(%rbp), %xmm0
movsd -0x3f0(%rbp), %xmm1
movsd (%rax), %xmm2
leaq 0xc068(%rip), %rdi      # 0x11350
movb $0x3, %al
callq 0x3030
jmp 0x52f1
movslq -0x284(%rbp), %rsi
leaq 0x13109(%rip), %rdi     # 0x18408
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x408(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x13072(%rip), %rdi     # 0x18390
callq 0x6230
movsd -0x408(%rbp), %xmm0
subsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x288(%rbp)
movss -0x288(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd -0x238(%rbp), %xmm0
jbe 0x5487
movss -0x288(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x238(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12ef9(%rip), %rdi     # 0x18270
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x260(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12ef2(%rip), %rdi     # 0x18288
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x258(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12eeb(%rip), %rdi     # 0x182a0
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x250(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12f74(%rip), %rdi     # 0x18348
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x280(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12f6d(%rip), %rdi     # 0x18360
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x278(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12f66(%rip), %rdi     # 0x18378
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x270(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12f5f(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x240(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12fb8(%rip), %rdi     # 0x18408
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x248(%rbp)
jmp 0x5487
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x3488
callq 0x33b0
jmp 0x5482
jmp 0x5a53
movslq -0x284(%rbp), %rsi
leaq 0x12efb(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x410(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12f54(%rip), %rdi     # 0x18408
callq 0x6230
movsd -0x410(%rbp), %xmm0
subsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x28c(%rbp)
movss -0x28c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd -0x1e8(%rbp), %xmm0
jbe 0x55f7
movss -0x28c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x1e8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12d63(%rip), %rdi     # 0x18270
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x210(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12d5c(%rip), %rdi     # 0x18288
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x208(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12d55(%rip), %rdi     # 0x182a0
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x200(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12dde(%rip), %rdi     # 0x18348
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x230(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12dd7(%rip), %rdi     # 0x18360
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x228(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12dd0(%rip), %rdi     # 0x18378
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x220(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12dc9(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1f0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12e22(%rip), %rdi     # 0x18408
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12da3(%rip), %rdi     # 0x183a8
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x418(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12d6c(%rip), %rdi     # 0x18390
callq 0x6230
movsd -0x418(%rbp), %xmm0
subsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x290(%rbp)
movss -0x290(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd -0x198(%rbp), %xmm0
jbe 0x5767
movss -0x290(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x198(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12bf3(%rip), %rdi     # 0x18270
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1c0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12bec(%rip), %rdi     # 0x18288
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1b8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12be5(%rip), %rdi     # 0x182a0
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c6e(%rip), %rdi     # 0x18348
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1e0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c67(%rip), %rdi     # 0x18360
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1d8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c60(%rip), %rdi     # 0x18378
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1d0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c59(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1a0(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c52(%rip), %rdi     # 0x183a8
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x1a8(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c1b(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x420(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12c14(%rip), %rdi     # 0x183a8
callq 0x6230
movsd -0x420(%rbp), %xmm0
subsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x294(%rbp)
movss -0x294(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd -0x140(%rbp), %xmm0
jbe 0x58d7
movss -0x294(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x140(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12a83(%rip), %rdi     # 0x18270
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x170(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12a7c(%rip), %rdi     # 0x18288
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x168(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12a75(%rip), %rdi     # 0x182a0
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x160(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12afe(%rip), %rdi     # 0x18348
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x190(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12af7(%rip), %rdi     # 0x18360
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x188(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12af0(%rip), %rdi     # 0x18378
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x180(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12ae9(%rip), %rdi     # 0x18390
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x148(%rbp)
movslq -0x284(%rbp), %rsi
leaq 0x12ae2(%rip), %rdi     # 0x183a8
callq 0x6230
movsd (%rax), %xmm0
movsd %xmm0, -0x150(%rbp)
jmp 0x58d9
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0x5241
movsd -0x1c0(%rbp), %xmm0
movsd -0x1b8(%rbp), %xmm1
movsd -0x1b0(%rbp), %xmm2
movsd -0x1e0(%rbp), %xmm3
movsd -0x1d8(%rbp), %xmm4
movsd -0x1d0(%rbp), %xmm5
movsd -0x1a0(%rbp), %xmm6
movsd -0x1a8(%rbp), %xmm7
leaq 0xba5c(%rip), %rdi      # 0x11390
movb $0x8, %al
callq 0x3030
jmp 0x593d
movsd -0x170(%rbp), %xmm0
movsd -0x168(%rbp), %xmm1
movsd -0x160(%rbp), %xmm2
movsd -0x190(%rbp), %xmm3
movsd -0x188(%rbp), %xmm4
movsd -0x180(%rbp), %xmm5
movsd -0x148(%rbp), %xmm6
movsd -0x150(%rbp), %xmm7
leaq 0xba68(%rip), %rdi      # 0x113ec
movb $0x8, %al
callq 0x3030
jmp 0x598d
movsd -0x260(%rbp), %xmm0
movsd -0x258(%rbp), %xmm1
movsd -0x250(%rbp), %xmm2
movsd -0x280(%rbp), %xmm3
movsd -0x278(%rbp), %xmm4
movsd -0x270(%rbp), %xmm5
movsd -0x240(%rbp), %xmm6
movsd -0x248(%rbp), %xmm7
leaq 0xba75(%rip), %rdi      # 0x11449
movb $0x8, %al
callq 0x3030
jmp 0x59dd
movsd -0x210(%rbp), %xmm0
movsd -0x208(%rbp), %xmm1
movsd -0x200(%rbp), %xmm2
movsd -0x230(%rbp), %xmm3
movsd -0x228(%rbp), %xmm4
movsd -0x220(%rbp), %xmm5
movsd -0x1f0(%rbp), %xmm6
movsd -0x1f8(%rbp), %xmm7
leaq 0xba84(%rip), %rdi      # 0x114a8
movb $0x8, %al
callq 0x3030
jmp 0x5a2d
jmp 0x5a2f
movq -0xf8(%rbp), %rdi
callq 0x8ce0
jmp 0x5a3d
leaq -0x48(%rbp), %rdi
callq 0x3180
movl -0xc(%rbp), %eax
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x3180
movq -0x20(%rbp), %rdi
callq 0x33e0
movq %rax, %rdi
callq 0x60a0
nopl (%rax)