// File: cdalitz[P]kdtree-cpp/demo_kdtree.cpp
// Function: main
int main(int argc, char** argv) {

  //
  // functionality tests
  //
  cout << "Functionality tests" << endl;
  cout << "-------------------" << endl;
  
  // 1.1) construction of kd-tree
  Kdtree::KdNodeVector nodes;
  double points[10][2] = {{1, 1}, {2, 1}, {1, 2}, {2, 4}, {3, 4},
                          {7, 2}, {8, 3}, {8, 5}, {7, 3}, {7, 3}};
  for (int i = 0; i < 10; ++i) {
    std::vector<double> point(2);
    point[0] = points[i][0];
    point[1] = points[i][1];
    nodes.push_back(Kdtree::KdNode(point));
  }
  Kdtree::KdTree tree(&nodes);
  cout << "Points in kd-tree:\n  ";
  print_nodes(tree.allnodes);

  // 1.2) kNN search
  Kdtree::KdNodeVector result;
  std::vector<double> test_point(2);
  test_point[0] = 8;
  test_point[1] = 3;
  tree.k_nearest_neighbors(test_point, 3, &result);
  cout << "3NNs of (" << test_point[0] << "," << test_point[1] << "):\n  ";
  print_nodes(result);

  // 1.3) kNN search with predicate
  struct Predicate : Kdtree::KdNodePredicate {
    std::vector<double> point;
    Predicate(std::vector<double> p) {
      this->point = p;
    }
    // only search for points with smaller y-coordinate
    bool operator()(const Kdtree::KdNode& kn) const {
      return this->point[1] > kn.point[1];
    }
  };
  Predicate pred(test_point);
  tree.k_nearest_neighbors(test_point, 3, &result, &pred);
  cout << "3NNs of (" << test_point[0] << "," << test_point[1] << ") with smaller y-coordinate:\n  ";
  print_nodes(result);

  // 1.4) range query
  test_point[0] = 8;
  test_point[1] = 2;
  tree.range_nearest_neighbors(test_point, 1.1, &result);
  cout << "Neighbors of (" << test_point[0] << "," << test_point[1] << ") with distance <= 1.1:\n  ";
  print_nodes(result);
  // same with maximum distance (distance_type=0)
  Kdtree::KdTree tree0(&nodes, 0);
  tree0.range_nearest_neighbors(test_point, 1.1, &result);
  cout << "Neighbors of (" << test_point[0] << "," << test_point[1] << ") with maximum distance <= 1.1:\n  ";
  print_nodes(result);

  //
  // speed tests
  //
  cout << "\nSpeed tests" << endl;
  cout << "-----------" << endl;

  double diff;
  size_t N = 500000;
  nodes.clear();
  for (size_t i = 0; i < N; ++i) {
    std::vector<double> point(2);
    point[0] = (double)rand() / RAND_MAX;
    point[1] = (double)rand() / RAND_MAX;
    nodes.push_back(Kdtree::KdNode(point));
  }
  
  // 2.1) build time
  clock_t begin = clock();
  Kdtree::KdTree tree2(&nodes);
  clock_t end = clock();
  diff = double(end - begin) / CLOCKS_PER_SEC;
  cout << "Creation time for " << N << " random points:\n  " << diff << "s" << endl;

  // 2.2) one kNN query
  test_point[0] = (double)rand() / RAND_MAX;
  test_point[1] = (double)rand() / RAND_MAX;
  begin = clock();
  tree.k_nearest_neighbors(test_point, 3, &result);
  end = clock();
  diff = double(end - begin) / CLOCKS_PER_SEC;
  cout << "3NN search time for one random point:\n  " << diff << "s" << endl;

  // 2.3) all NN query
  begin = clock();
  for (size_t i = 0; i < N; ++i) {
    std::vector<double> point(2);
    tree.k_nearest_neighbors(nodes[i].point, 2, &result);
  }
  end = clock();
  diff = double(end - begin) / CLOCKS_PER_SEC;
  cout << "Time for all nearest neighbor search:\n  " << diff << "s" << endl;

  // 2.4) range query
  double r = 0.3;
  begin = clock();
  tree.range_nearest_neighbors(test_point, r, &result);
  end = clock();
  diff = double(end - begin) / CLOCKS_PER_SEC;
  cout << "Range search time for one random point (r=" << r << "):\n  " << diff << endl;

  // 2.5) for comparison: loop version
  std::vector<Kdtree::CoordPoint> res;
  begin = clock();
  for (size_t i = 0; i < N; ++i) {
    if ((nodes[i].point[0] - test_point[0]) *
        (nodes[i].point[0] - test_point[0]) +
        (nodes[i].point[1] - test_point[1]) *
        (nodes[i].point[1] - test_point[1]) < r * r)
        res.push_back(nodes[i].point);
    }
    end = clock();
    diff = double(end - begin) / CLOCKS_PER_SEC;
    cout << "Loop version of a single range search for comparison:\n  " << diff << "s" << endl;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5b0, %rsp            # imm = 0x5B0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x12b78(%rip), %rdi     # 0x14fc8
leaq 0xbbcb(%rip), %rsi      # 0xe022
callq 0x2100
movq %rax, %rdi
movq 0x12b52(%rip), %rsi     # 0x14fb8
callq 0x2130
movq 0x12b56(%rip), %rdi     # 0x14fc8
leaq 0xbbbd(%rip), %rsi      # 0xe036
callq 0x2100
movq %rax, %rdi
movq 0x12b30(%rip), %rsi     # 0x14fb8
callq 0x2130
leaq -0x28(%rbp), %rdi
callq 0x3810
leaq -0xd0(%rbp), %rdi
leaq 0xbd7c(%rip), %rsi      # 0xe220
movl $0xa0, %edx
callq 0x20e0
movl $0x0, -0xd4(%rbp)
cmpl $0xa, -0xd4(%rbp)
jge 0x2642
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x3830
movq -0x3b8(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
movl $0x2, %esi
callq 0x3850
jmp 0x24f2
leaq -0xf1(%rbp), %rdi
callq 0x38c0
movslq -0xd4(%rbp), %rax
shlq $0x4, %rax
movsd -0xd0(%rbp,%rax), %xmm0
movsd %xmm0, -0x3d8(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x3c0(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x38e0
movsd -0x3d8(%rbp), %xmm0
movq -0x3c8(%rbp), %rdi
movsd %xmm0, (%rax)
movslq -0xd4(%rbp), %rax
shlq $0x4, %rax
movsd -0xc8(%rbp,%rax), %xmm0
movsd %xmm0, -0x3d0(%rbp)
movl $0x1, %esi
callq 0x38e0
movsd -0x3d0(%rbp), %xmm0
movq -0x3c8(%rbp), %rsi
movq -0x3c0(%rbp), %rdx
movsd %xmm0, (%rax)
leaq -0x130(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3930
jmp 0x259e
leaq -0x28(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3900
jmp 0x25b0
leaq -0x130(%rbp), %rdi
callq 0x39a0
leaq -0xf0(%rbp), %rdi
callq 0x39c0
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x24b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x38c0
jmp 0x361e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x2631
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x39a0
leaq -0xf0(%rbp), %rdi
callq 0x39c0
jmp 0x361e
leaq -0x1a0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x2, %edx
callq 0x69d0
jmp 0x2659
movq 0x12968(%rip), %rdi     # 0x14fc8
leaq 0xb9e3(%rip), %rsi      # 0xe04a
callq 0x2100
jmp 0x266e
leaq -0x158(%rbp), %rdi
callq 0x2300
jmp 0x267c
leaq -0x1b8(%rbp), %rdi
callq 0x3810
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x3830
movq -0x3e0(%rbp), %rdx
leaq -0x1d0(%rbp), %rdi
movl $0x2, %esi
callq 0x3850
jmp 0x26b5
leaq -0x1d1(%rbp), %rdi
callq 0x38c0
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x3e8(%rbp)
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x38e0
movq -0x3f0(%rbp), %rdi
movabsq $0x4020000000000000, %rcx # imm = 0x4020000000000000
movq %rcx, (%rax)
movl $0x1, %esi
callq 0x38e0
movq -0x3f0(%rbp), %rsi
movq -0x3e8(%rbp), %r8
movabsq $0x4008000000000000, %rcx # imm = 0x4008000000000000
movq %rcx, (%rax)
leaq -0x1a0(%rbp), %rdi
movl $0x3, %edx
leaq -0x1b8(%rbp), %rcx
callq 0x7200
jmp 0x2732
movq 0x1288f(%rip), %rdi     # 0x14fc8
leaq 0xb920(%rip), %rsi      # 0xe060
callq 0x2100
movq %rax, -0x3f8(%rbp)
jmp 0x274e
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x38e0
movq -0x3f8(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x400(%rbp)
jmp 0x2777
movq -0x400(%rbp), %rdi
leaq 0xb89b(%rip), %rsi      # 0xe020
callq 0x2100
movq %rax, -0x408(%rbp)
jmp 0x2793
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movq -0x408(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x410(%rbp)
jmp 0x27bd
movq -0x410(%rbp), %rdi
leaq 0xb89f(%rip), %rsi      # 0xe06a
callq 0x2100
jmp 0x27d2
leaq -0x1b8(%rbp), %rdi
callq 0x2300
jmp 0x27e0
leaq -0x210(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3a20
jmp 0x27f5
leaq -0x1f8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x3640
jmp 0x280a
leaq -0x210(%rbp), %rdi
callq 0x39c0
leaq -0x1a0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movl $0x3, %edx
leaq -0x1b8(%rbp), %rcx
leaq -0x1f8(%rbp), %r8
callq 0x7200
jmp 0x283e
movq 0x12783(%rip), %rdi     # 0x14fc8
leaq 0xb814(%rip), %rsi      # 0xe060
callq 0x2100
movq %rax, -0x418(%rbp)
jmp 0x285a
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x38e0
movq -0x418(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x420(%rbp)
jmp 0x2883
movq -0x420(%rbp), %rdi
leaq 0xb78f(%rip), %rsi      # 0xe020
callq 0x2100
movq %rax, -0x428(%rbp)
jmp 0x289f
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movq -0x428(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x430(%rbp)
jmp 0x28c9
movq -0x430(%rbp), %rdi
leaq 0xb799(%rip), %rsi      # 0xe070
callq 0x2100
jmp 0x28de
leaq -0x1b8(%rbp), %rdi
callq 0x2300
jmp 0x28ec
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x38e0
movq -0x438(%rbp), %rdi
movabsq $0x4020000000000000, %rcx # imm = 0x4020000000000000
movq %rcx, (%rax)
movl $0x1, %esi
callq 0x38e0
movq -0x438(%rbp), %rsi
movabsq $0x4000000000000000, %rcx # imm = 0x4000000000000000
movq %rcx, (%rax)
leaq -0x1a0(%rbp), %rdi
movsd 0xb6c4(%rip), %xmm0     # 0xe008
leaq -0x1b8(%rbp), %rdx
callq 0x7980
jmp 0x2952
movq 0x1266f(%rip), %rdi     # 0x14fc8
leaq 0xb730(%rip), %rsi      # 0xe090
callq 0x2100
movq %rax, -0x440(%rbp)
jmp 0x296e
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x38e0
movq -0x440(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x448(%rbp)
jmp 0x2997
movq -0x448(%rbp), %rdi
leaq 0xb67b(%rip), %rsi      # 0xe020
callq 0x2100
movq %rax, -0x450(%rbp)
jmp 0x29b3
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movq -0x450(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x458(%rbp)
jmp 0x29dd
movq -0x458(%rbp), %rdi
leaq 0xb6b4(%rip), %rsi      # 0xe09f
callq 0x2100
jmp 0x29f2
leaq -0x1b8(%rbp), %rdi
callq 0x2300
jmp 0x2a00
leaq -0x280(%rbp), %rdi
leaq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x69d0
jmp 0x2a14
leaq -0x280(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movsd 0xb5de(%rip), %xmm0     # 0xe008
leaq -0x1b8(%rbp), %rdx
callq 0x7980
jmp 0x2a38
movq 0x12589(%rip), %rdi     # 0x14fc8
leaq 0xb64a(%rip), %rsi      # 0xe090
callq 0x2100
movq %rax, -0x460(%rbp)
jmp 0x2a54
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x38e0
movq -0x460(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x468(%rbp)
jmp 0x2a7d
movq -0x468(%rbp), %rdi
leaq 0xb595(%rip), %rsi      # 0xe020
callq 0x2100
movq %rax, -0x470(%rbp)
jmp 0x2a99
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movq -0x470(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x21b0
movq %rax, -0x478(%rbp)
jmp 0x2ac3
movq -0x478(%rbp), %rdi
leaq 0xb5e9(%rip), %rsi      # 0xe0ba
callq 0x2100
jmp 0x2ad8
leaq -0x1b8(%rbp), %rdi
callq 0x2300
jmp 0x2ae6
movq 0x124db(%rip), %rdi     # 0x14fc8
leaq 0xb5e9(%rip), %rsi      # 0xe0dd
callq 0x2100
movq %rax, -0x480(%rbp)
jmp 0x2b02
movq -0x480(%rbp), %rdi
movq 0x124a8(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x2b17
movq 0x124aa(%rip), %rdi     # 0x14fc8
leaq 0xb519(%rip), %rsi      # 0xe03e
callq 0x2100
movq %rax, -0x488(%rbp)
jmp 0x2b33
movq -0x488(%rbp), %rdi
movq 0x12477(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x2b48
movq $0x7a120, -0x290(%rbp) # imm = 0x7A120
leaq -0x28(%rbp), %rdi
callq 0x3b10
movq $0x0, -0x298(%rbp)
movq -0x298(%rbp), %rax
cmpq -0x290(%rbp), %rax
jae 0x2dbe
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x490(%rbp)
callq 0x3830
movq -0x490(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
movl $0x2, %esi
callq 0x3850
jmp 0x2ba8
leaq -0x2b1(%rbp), %rdi
callq 0x38c0
callq 0x2040
cvtsi2sd %eax, %xmm0
movsd 0xb453(%rip), %xmm1     # 0xe018
movsd %xmm1, -0x4b0(%rbp)
divsd %xmm1, %xmm0
movsd %xmm0, -0x4b8(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x498(%rbp)
leaq -0x2b0(%rbp), %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x38e0
movsd -0x4b8(%rbp), %xmm0
movsd %xmm0, (%rax)
callq 0x2040
movsd -0x4b0(%rbp), %xmm1
movq -0x4a0(%rbp), %rdi
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x4a8(%rbp)
movl $0x1, %esi
callq 0x38e0
movsd -0x4a8(%rbp), %xmm0
movq -0x4a0(%rbp), %rsi
movq -0x498(%rbp), %rdx
movsd %xmm0, (%rax)
leaq -0x2e0(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x3930
jmp 0x2c5e
leaq -0x28(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x3900
jmp 0x2c70
leaq -0x2e0(%rbp), %rdi
callq 0x39a0
leaq -0x2b0(%rbp), %rdi
callq 0x39c0
movq -0x298(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x298(%rbp)
jmp 0x2b67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x361e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x3612
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x1d1(%rbp), %rdi
callq 0x38c0
jmp 0x3606
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x35fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x39c0
jmp 0x35fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x35ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x35e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x2b1(%rbp), %rdi
callq 0x38c0
jmp 0x35e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x2dad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x39a0
leaq -0x2b0(%rbp), %rdi
callq 0x39c0
jmp 0x35e2
callq 0x20b0
movq %rax, -0x2e8(%rbp)
leaq -0x358(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x2, %edx
callq 0x69d0
jmp 0x2de1
callq 0x20b0
movq %rax, -0x360(%rbp)
movq -0x360(%rbp), %rax
movq -0x2e8(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xb205(%rip), %xmm1     # 0xe010
divsd %xmm1, %xmm0
movsd %xmm0, -0x288(%rbp)
movq 0x121aa(%rip), %rdi     # 0x14fc8
leaq 0xb2c5(%rip), %rsi      # 0xe0ea
callq 0x2100
movq %rax, -0x4c0(%rbp)
jmp 0x2e33
movq -0x4c0(%rbp), %rdi
movq -0x290(%rbp), %rsi
callq 0x2030
movq %rax, -0x4c8(%rbp)
jmp 0x2e4f
movq -0x4c8(%rbp), %rdi
leaq 0xb2a0(%rip), %rsi      # 0xe0fd
callq 0x2100
movq %rax, -0x4d0(%rbp)
jmp 0x2e6b
movq -0x4d0(%rbp), %rdi
movsd -0x288(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x4d8(%rbp)
jmp 0x2e88
movq -0x4d8(%rbp), %rdi
leaq 0xb252(%rip), %rsi      # 0xe0e8
callq 0x2100
movq %rax, -0x4e0(%rbp)
jmp 0x2ea4
movq -0x4e0(%rbp), %rdi
movq 0x12106(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x2eb9
callq 0x2040
cvtsi2sd %eax, %xmm0
movsd 0xb14e(%rip), %xmm1     # 0xe018
movsd %xmm1, -0x500(%rbp)
divsd %xmm1, %xmm0
movsd %xmm0, -0x508(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x4e8(%rbp)
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x4f0(%rbp)
callq 0x38e0
movsd -0x508(%rbp), %xmm0
movsd %xmm0, (%rax)
callq 0x2040
movsd -0x500(%rbp), %xmm1
movq -0x4f0(%rbp), %rdi
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x4f8(%rbp)
movl $0x1, %esi
callq 0x38e0
movsd -0x4f8(%rbp), %xmm0
movsd %xmm0, (%rax)
callq 0x20b0
movq -0x4f0(%rbp), %rsi
movq -0x4e8(%rbp), %r8
movq %rax, -0x2e8(%rbp)
leaq -0x1a0(%rbp), %rdi
movl $0x3, %edx
leaq -0x1b8(%rbp), %rcx
callq 0x7200
jmp 0x2f76
callq 0x20b0
movq %rax, -0x360(%rbp)
movq -0x360(%rbp), %rax
movq -0x2e8(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xb070(%rip), %xmm1     # 0xe010
divsd %xmm1, %xmm0
movsd %xmm0, -0x288(%rbp)
movq 0x12015(%rip), %rdi     # 0x14fc8
leaq 0xb156(%rip), %rsi      # 0xe110
callq 0x2100
movq %rax, -0x510(%rbp)
jmp 0x2fc8
movq -0x510(%rbp), %rdi
movsd -0x288(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x518(%rbp)
jmp 0x2fe5
movq -0x518(%rbp), %rdi
leaq 0xb0f5(%rip), %rsi      # 0xe0e8
callq 0x2100
movq %rax, -0x520(%rbp)
jmp 0x3001
movq -0x520(%rbp), %rdi
movq 0x11fa9(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x3016
callq 0x20b0
movq %rax, -0x2e8(%rbp)
movq $0x0, -0x368(%rbp)
movq -0x368(%rbp), %rax
cmpq -0x290(%rbp), %rax
jae 0x312c
leaq -0x381(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x3830
movq -0x528(%rbp), %rdx
leaq -0x380(%rbp), %rdi
movl $0x2, %esi
callq 0x3850
jmp 0x306e
leaq -0x381(%rbp), %rdi
callq 0x38c0
movq -0x368(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %r8d
leaq -0x1a0(%rbp), %rdi
movl $0x2, %edx
leaq -0x1b8(%rbp), %rcx
callq 0x7200
jmp 0x30ac
leaq -0x380(%rbp), %rdi
callq 0x39c0
movq -0x368(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x368(%rbp)
jmp 0x302d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
jmp 0x35d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x381(%rbp), %rdi
callq 0x38c0
jmp 0x35d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x39c0
jmp 0x35d6
callq 0x20b0
movq %rax, -0x360(%rbp)
movq -0x360(%rbp), %rax
movq -0x2e8(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xaeba(%rip), %xmm1     # 0xe010
divsd %xmm1, %xmm0
movsd %xmm0, -0x288(%rbp)
movq 0x11e5f(%rip), %rdi     # 0x14fc8
leaq 0xafc9(%rip), %rsi      # 0xe139
callq 0x2100
movq %rax, -0x530(%rbp)
jmp 0x317e
movq -0x530(%rbp), %rdi
movsd -0x288(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x538(%rbp)
jmp 0x319b
movq -0x538(%rbp), %rdi
leaq 0xaf3f(%rip), %rsi      # 0xe0e8
callq 0x2100
movq %rax, -0x540(%rbp)
jmp 0x31b7
movq -0x540(%rbp), %rdi
movq 0x11df3(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x31cc
movabsq $0x3fd3333333333333, %rax # imm = 0x3FD3333333333333
movq %rax, -0x390(%rbp)
callq 0x20b0
movq %rax, -0x2e8(%rbp)
movsd -0x390(%rbp), %xmm0
leaq -0x1a0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0x7980
jmp 0x320d
callq 0x20b0
movq %rax, -0x360(%rbp)
movq -0x360(%rbp), %rax
movq -0x2e8(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xadd9(%rip), %xmm1     # 0xe010
divsd %xmm1, %xmm0
movsd %xmm0, -0x288(%rbp)
movq 0x11d7e(%rip), %rdi     # 0x14fc8
leaq 0xaf11(%rip), %rsi      # 0xe162
callq 0x2100
movq %rax, -0x548(%rbp)
jmp 0x325f
movq -0x548(%rbp), %rdi
movsd -0x390(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x550(%rbp)
jmp 0x327c
movq -0x550(%rbp), %rdi
leaq 0xade0(%rip), %rsi      # 0xe06a
callq 0x2100
movq %rax, -0x558(%rbp)
jmp 0x3298
movq -0x558(%rbp), %rdi
movsd -0x288(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x560(%rbp)
jmp 0x32b5
movq -0x560(%rbp), %rdi
movq 0x11cf5(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x32ca
leaq -0x3a8(%rbp), %rdi
callq 0x3b50
callq 0x20b0
movq %rax, -0x2e8(%rbp)
movq $0x0, -0x3b0(%rbp)
movq -0x3b0(%rbp), %rax
cmpq -0x290(%rbp), %rax
jae 0x34c6
movq -0x3b0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x38e0
movsd (%rax), %xmm0
movsd %xmm0, -0x598(%rbp)
leaq -0x1d0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x38e0
movsd -0x598(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x570(%rbp)
movq -0x3b0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x38e0
movsd (%rax), %xmm0
movsd %xmm0, -0x590(%rbp)
leaq -0x1d0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x38e0
movsd -0x590(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x568(%rbp)
movq -0x3b0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rdi
movl $0x1, %esi
callq 0x38e0
movsd (%rax), %xmm0
movsd %xmm0, -0x588(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movsd -0x588(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x578(%rbp)
movq -0x3b0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rdi
movl $0x1, %esi
callq 0x38e0
movsd (%rax), %xmm0
movsd %xmm0, -0x580(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x38e0
movsd -0x580(%rbp), %xmm3
movsd -0x578(%rbp), %xmm0
movsd -0x570(%rbp), %xmm1
movsd -0x568(%rbp), %xmm2
subsd (%rax), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x390(%rbp), %xmm0
mulsd -0x390(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x34ad
movq -0x3b0(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x3b30
movq %rax, %rsi
leaq -0x3a8(%rbp), %rdi
callq 0x3b70
jmp 0x3488
jmp 0x34ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x100(%rbp)
movl %eax, -0x104(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x3be0
jmp 0x35d6
jmp 0x34af
movq -0x3b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3b0(%rbp)
jmp 0x32ed
callq 0x20b0
movq %rax, -0x360(%rbp)
movq -0x360(%rbp), %rax
movq -0x2e8(%rbp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0xab20(%rip), %xmm1     # 0xe010
divsd %xmm1, %xmm0
movsd %xmm0, -0x288(%rbp)
movq 0x11ac5(%rip), %rdi     # 0x14fc8
leaq 0xac83(%rip), %rsi      # 0xe18d
callq 0x2100
movq %rax, -0x5a0(%rbp)
jmp 0x3518
movq -0x5a0(%rbp), %rdi
movsd -0x288(%rbp), %xmm0
callq 0x21b0
movq %rax, -0x5a8(%rbp)
jmp 0x3535
movq -0x5a8(%rbp), %rdi
leaq 0xaba5(%rip), %rsi      # 0xe0e8
callq 0x2100
movq %rax, -0x5b0(%rbp)
jmp 0x3551
movq -0x5b0(%rbp), %rdi
movq 0x11a59(%rip), %rsi     # 0x14fb8
callq 0x2130
jmp 0x3566
movl $0x0, -0x4(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x3be0
leaq -0x358(%rbp), %rdi
callq 0x6940
leaq -0x280(%rbp), %rdi
callq 0x6940
leaq -0x1f8(%rbp), %rdi
callq 0x36c0
leaq -0x1d0(%rbp), %rdi
callq 0x39c0
leaq -0x1b8(%rbp), %rdi
callq 0x3c40
leaq -0x1a0(%rbp), %rdi
callq 0x6940
leaq -0x28(%rbp), %rdi
callq 0x3c40
movl -0x4(%rbp), %eax
addq $0x5b0, %rsp            # imm = 0x5B0
popq %rbp
retq
leaq -0x358(%rbp), %rdi
callq 0x6940
leaq -0x280(%rbp), %rdi
callq 0x6940
leaq -0x1f8(%rbp), %rdi
callq 0x36c0
leaq -0x1d0(%rbp), %rdi
callq 0x39c0
leaq -0x1b8(%rbp), %rdi
callq 0x3c40
leaq -0x1a0(%rbp), %rdi
callq 0x6940
leaq -0x28(%rbp), %rdi
callq 0x3c40
movq -0x100(%rbp), %rdi
callq 0x2190
nopw %cs:(%rax,%rax)