// File: tomfunkhouser[P]gaps/apps/conf2sfl/conf2sfl.cpp
// Function: CreatePoints(gaps::R3Segmentation*, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Image const&)
static int 
CreatePoints(R3Segmentation *segmentation,
  const R2Grid& px_image, const R2Grid& py_image, const R2Grid& pz_image, 
  const R2Grid& nx_image, const R2Grid& ny_image, const R2Grid& nz_image,
  const R2Grid& tx_image, const R2Grid& ty_image, const R2Grid& tz_image,
  const R2Grid& depth_image, const R2Grid& r1_image, const R2Grid& r2_image,
  const R2Grid& boundary_image, const R2Image& color_image)
{
  // Allocate points 
  segmentation->point_buffer = new R3SegmentationPoint [ depth_image.NEntries() ];
  if (!segmentation->point_buffer) {
    RNFail("Unable to allocate points\n");
    return 0;
  }

  // Fill points
  for (int ix = 0; ix < depth_image.XResolution(); ix++) {
    for (int iy = 0; iy < depth_image.YResolution(); iy++) {
      int i;
      depth_image.IndicesToIndex(ix, iy, i);
      R3SegmentationPoint *point = &segmentation->point_buffer[i];

      // Check depth
      RNScalar depth = depth_image.GridValue(i);
      if (RNIsNegativeOrZero(depth)) continue;
      if ((max_depth > 0) && (depth > max_depth)) continue;
      point->depth = depth;

      // Get position
      RNScalar px = px_image.GridValue(i);
      RNScalar py = py_image.GridValue(i);
      RNScalar pz = pz_image.GridValue(i);
      point->position.Reset(px, py, pz);

      // Get normal
      RNScalar nx = nx_image.GridValue(i);
      RNScalar ny = ny_image.GridValue(i);
      RNScalar nz = nz_image.GridValue(i);
      point->normal.Reset(nx, ny, nz);

      // Get tangent
      RNScalar tx = tx_image.GridValue(i);
      RNScalar ty = ty_image.GridValue(i);
      RNScalar tz = tz_image.GridValue(i);
      point->tangent.Reset(tx, ty, tz);

      // Get radius
      point->radius1 = r1_image.GridValue(i);
      point->radius2 = r2_image.GridValue(i);
      point->area = RN_PI * point->radius1 * point->radius2;

      // Get color
      point->color = color_image.PixelRGB(ix, iy);
    
      // Get flags
      point->boundary = (unsigned int) (boundary_image.GridValue(i) + 0.5);

      // Set grid index
      point->data_index = i;

      // Insert point
      segmentation->points.Insert(point);
    }
  }

  // Create kdtree of points
  R3SegmentationPoint tmp; int position_offset = (unsigned char *) &(tmp.position) - (unsigned char *) &tmp;
  segmentation->kdtree = new R3Kdtree< R3SegmentationPoint *>(segmentation->points, position_offset);
  if (!segmentation->kdtree) {
    RNFail("Unable to create kdtree\n");
    return 0;
  }
  
  // Create arrays of neighbor points
  for (int i = 0; i < segmentation->points.NEntries(); i++) {
    R3SegmentationPoint *point = segmentation->points.Kth(i);
    int ix, iy, neighbor_index;
    depth_image.IndexToIndices(point->data_index, ix, iy);
    for (int s = -1; s <= 1; s++) {
      if ((ix+s < 0) || (ix+s >= depth_image.XResolution())) continue;
      for (int t = -1; t <= 1; t++) {
        if ((s == 0) && (t == 0)) continue;
        if ((iy+t < 0) || (iy+t >= depth_image.YResolution())) continue;
        depth_image.IndicesToIndex(ix+s, iy+t, neighbor_index);
        R3SegmentationPoint *neighbor = &segmentation->point_buffer[neighbor_index];

        // Check if across boundary
        if ((point->boundary & RGBD_SHADOW_BOUNDARY) && (neighbor->boundary & RGBD_SILHOUETTE_BOUNDARY)) continue;
        if ((point->boundary & RGBD_SILHOUETTE_BOUNDARY) && (neighbor->boundary & RGBD_SHADOW_BOUNDARY)) continue;

        // Check if too far away
        if (max_neighbor_distance_factor > 0) {
          RNScalar radius = (point->radius1 > neighbor->radius1) ? neighbor->radius1 : point->radius1;
          RNScalar max_neighbor_distance = (radius > 0) ? max_neighbor_distance_factor * radius : 0.25;
          RNScalar dd = R3SquaredDistance(point->position, neighbor->position);
          if (dd > max_neighbor_distance * max_neighbor_distance) continue;
        }

        // Check if too much color difference
        if (max_neighbor_color_difference > 0) {
          RNScalar dr = fabs(point->color.R() - neighbor->color.R());
          if (dr > max_neighbor_color_difference) continue;
          RNScalar dg = fabs(point->color.G() - neighbor->color.G());
          if (dg > max_neighbor_color_difference) continue;
          RNScalar db = fabs(point->color.B() - neighbor->color.B());
          if (db > max_neighbor_color_difference) continue;
        }

        // Check if too much normal angle
        if (max_neighbor_normal_angle > 0) {
          RNScalar dot = fabs(point->normal.Dot(neighbor->normal));
          RNAngle normal_angle = (dot < 1) ? RN_PI_OVER_TWO - acos(dot) : RN_PI_OVER_TWO;
          if (normal_angle > max_neighbor_normal_angle) continue;
        }
        
        // Insert neighbor
        point->neighbors.Insert(neighbor);
      }
    }
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x2f8, %rsp            # imm = 0x2F8
movq 0x340(%rsp), %rax
movq 0x338(%rsp), %rax
movq 0x330(%rsp), %rax
movq 0x328(%rsp), %rax
movq 0x320(%rsp), %rax
movq 0x318(%rsp), %rax
movq 0x310(%rsp), %rax
movq 0x308(%rsp), %rax
movq 0x300(%rsp), %rax
movq %rdi, 0x2e8(%rsp)
movq %rsi, 0x2e0(%rsp)
movq %rdx, 0x2d8(%rsp)
movq %rcx, 0x2d0(%rsp)
movq %r8, 0x2c8(%rsp)
movq %r9, 0x2c0(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1f290
cltq
movq %rax, 0xc8(%rsp)
movl $0xe0, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, 0xc0(%rsp)
callq 0x16040
movq %rax, %rcx
movq 0xc8(%rsp), %rax
movq %rcx, 0xd0(%rsp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0xd8(%rsp)
cmpq $0x0, %rax
je 0x1d517
movq 0xd8(%rsp), %rax
movq 0xc8(%rsp), %rcx
imulq $0xe0, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x3bea0
jmp 0x1d4f4
movq 0xb0(%rsp), %rcx
movq 0xa8(%rsp), %rax
addq $0xe0, %rax
cmpq %rcx, %rax
movq %rax, 0xb8(%rsp)
jne 0x1d4dd
movq 0xd8(%rsp), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x2e8(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x1d5de
leaq 0x1dff12(%rip), %rdi    # 0x1fd457
movb $0x0, %al
callq 0x1779b0
movl $0x0, 0x2f4(%rsp)
jmp 0x1e0a2
movq 0xd8(%rsp), %rcx
movq %rax, %rsi
movq 0xa8(%rsp), %rax
movq %rsi, 0x2b8(%rsp)
movl %edx, 0x2b4(%rsp)
cmpq %rax, %rcx
movq %rax, 0xa0(%rsp)
je 0x1d5c4
movq 0xa0(%rsp), %rdi
addq $-0xe0, %rdi
movq %rdi, 0x98(%rsp)
callq 0x1f2b0
movq 0xd8(%rsp), %rcx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0xa0(%rsp)
jne 0x1d58b
movq 0xc0(%rsp), %rsi
movq 0xd0(%rsp), %rdi
callq 0x16e20
jmp 0x1e0b1
movl $0x0, 0x2b0(%rsp)
movl 0x2b0(%rsp), %eax
movl %eax, 0x94(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1f1a0
movl %eax, %ecx
movl 0x94(%rsp), %eax
cmpl %ecx, %eax
jge 0x1d9d9
movl $0x0, 0x2ac(%rsp)
movl 0x2ac(%rsp), %eax
movl %eax, 0x90(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1f1c0
movl %eax, %ecx
movl 0x90(%rsp), %eax
cmpl %ecx, %eax
jge 0x1d9c1
movq 0x320(%rsp), %rdi
movl 0x2b0(%rsp), %esi
movl 0x2ac(%rsp), %edx
leaq 0x2a8(%rsp), %rcx
callq 0x1f2d0
movq 0x2e8(%rsp), %rax
movq 0x28(%rax), %rax
movslq 0x2a8(%rsp), %rcx
imulq $0xe0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x2a0(%rsp)
movq 0x320(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x298(%rsp)
movsd 0x298(%rsp), %xmm0
leaq 0x24b086(%rip), %rax    # 0x268748
movsd (%rax), %xmm1
callq 0x1f320
cmpl $0x0, %eax
je 0x1d6d5
jmp 0x1d9ab
movsd 0x24b153(%rip), %xmm0   # 0x268830
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d6fe
movsd 0x298(%rsp), %xmm0
ucomisd 0x24b139(%rip), %xmm0   # 0x268830
jbe 0x1d6fe
jmp 0x1d9ab
movsd 0x298(%rsp), %xmm0
movq 0x2a0(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x2e0(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x290(%rsp)
movq 0x2d8(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x288(%rsp)
movq 0x2d0(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x280(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x8, %rdi
movsd 0x290(%rsp), %xmm0
movsd 0x288(%rsp), %xmm1
movsd 0x280(%rsp), %xmm2
callq 0x1f350
movq 0x2c8(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x278(%rsp)
movq 0x2c0(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x270(%rsp)
movq 0x300(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x268(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
movsd 0x278(%rsp), %xmm0
movsd 0x270(%rsp), %xmm1
movsd 0x268(%rsp), %xmm2
callq 0x1f390
movq 0x308(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x260(%rsp)
movq 0x310(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x258(%rsp)
movq 0x318(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd %xmm0, 0x250(%rsp)
movq 0x2a0(%rsp), %rdi
addq $0x38, %rdi
movsd 0x260(%rsp), %xmm0
movsd 0x258(%rsp), %xmm1
movsd 0x250(%rsp), %xmm2
callq 0x1f390
movq 0x328(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movq 0x2a0(%rsp), %rax
movsd %xmm0, 0x50(%rax)
movq 0x330(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movq 0x2a0(%rsp), %rax
movsd %xmm0, 0x58(%rax)
leaq 0x1e5e5b(%rip), %rax    # 0x203740
movsd (%rax), %xmm0
movq 0x2a0(%rsp), %rax
movsd 0x50(%rax), %xmm2
movsd 0x58(%rax), %xmm1
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rax)
movq 0x340(%rsp), %rsi
movl 0x2b0(%rsp), %edx
movl 0x2ac(%rsp), %ecx
leaq 0x238(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x16a1c0
movq 0x88(%rsp), %rsi
movq 0x2a0(%rsp), %rdi
addq $0x78, %rdi
callq 0x173370
movq 0x338(%rsp), %rdi
movl 0x2a8(%rsp), %esi
callq 0x1f300
movsd 0x1df6c8(%rip), %xmm1   # 0x1fd030
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq 0x2a0(%rsp), %rax
movl %ecx, 0xa4(%rax)
movl 0x2a8(%rsp), %ecx
movq 0x2a0(%rsp), %rax
movl %ecx, 0xd4(%rax)
movq 0x2e8(%rsp), %rdi
movq 0x2a0(%rsp), %rsi
callq 0x1f3d0
movl 0x2ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2ac(%rsp)
jmp 0x1d620
jmp 0x1d9c3
movl 0x2b0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2b0(%rsp)
jmp 0x1d5e9
leaq 0x158(%rsp), %rdi
callq 0x3bea0
movl $0x8, 0x154(%rsp)
movl $0x60, %edi
callq 0x16740
movq %rax, 0x80(%rsp)
jmp 0x1da05
movq 0x80(%rsp), %rdi
movq 0x2e8(%rsp), %rsi
movl 0x154(%rsp), %edx
callq 0x1f400
jmp 0x1da23
movq 0x80(%rsp), %rcx
movq 0x2e8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x2e8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1dab5
leaq 0x1dfa25(%rip), %rdi    # 0x1fd472
xorl %eax, %eax
callq 0x1779b0
jmp 0x1da56
movl $0x0, 0x2f4(%rsp)
movl $0x1, 0x150(%rsp)
jmp 0x1e084
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b8(%rsp)
movl %eax, 0x2b4(%rsp)
jmp 0x1e093
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b8(%rsp)
movl %eax, 0x2b4(%rsp)
movl $0x60, %esi
callq 0x16750
jmp 0x1e093
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, 0x7c(%rsp)
movq 0x2e8(%rsp), %rdi
callq 0x1ecf0
movl %eax, %ecx
movl 0x7c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1e06e
movq 0x2e8(%rsp), %rdi
movl 0x14c(%rsp), %esi
callq 0x1f6a0
movq %rax, 0x70(%rsp)
jmp 0x1db01
movq 0x70(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x320(%rsp), %rdi
movq 0x140(%rsp), %rax
movl 0xd4(%rax), %esi
leaq 0x13c(%rsp), %rdx
leaq 0x138(%rsp), %rcx
callq 0x1f6c0
jmp 0x1db3b
movl $0xffffffff, 0x130(%rsp) # imm = 0xFFFFFFFF
cmpl $0x1, 0x130(%rsp)
jg 0x1e056
movl 0x13c(%rsp), %eax
addl 0x130(%rsp), %eax
cmpl $0x0, %eax
jl 0x1db90
movl 0x13c(%rsp), %eax
addl 0x130(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1f1a0
movl %eax, %ecx
movl 0x6c(%rsp), %eax
cmpl %ecx, %eax
jl 0x1db95
jmp 0x1e040
movl $0xffffffff, 0x12c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x1, 0x12c(%rsp)
jg 0x1e03e
cmpl $0x0, 0x130(%rsp)
jne 0x1dbc7
cmpl $0x0, 0x12c(%rsp)
jne 0x1dbc7
jmp 0x1e028
movl 0x138(%rsp), %eax
addl 0x12c(%rsp), %eax
cmpl $0x0, %eax
jl 0x1dc03
movl 0x138(%rsp), %eax
addl 0x12c(%rsp), %eax
movl %eax, 0x68(%rsp)
movq 0x320(%rsp), %rdi
callq 0x1f1c0
movl %eax, %ecx
movl 0x68(%rsp), %eax
cmpl %ecx, %eax
jl 0x1dc08
jmp 0x1e028
movq 0x320(%rsp), %rdi
movl 0x13c(%rsp), %esi
movl 0x130(%rsp), %eax
addl %eax, %esi
movl 0x138(%rsp), %edx
movl 0x12c(%rsp), %eax
addl %eax, %edx
leaq 0x134(%rsp), %rcx
callq 0x1f2d0
jmp 0x1dc3f
movq 0x2e8(%rsp), %rax
movq 0x28(%rax), %rax
movslq 0x134(%rsp), %rcx
imulq $0xe0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x120(%rsp)
movq 0x140(%rsp), %rax
movl 0xa4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1dc96
movq 0x120(%rsp), %rax
movl 0xa4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1dc96
jmp 0x1e028
movq 0x140(%rsp), %rax
movl 0xa4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1dcc7
movq 0x120(%rsp), %rax
movl 0xa4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1dcc7
jmp 0x1e028
movsd 0x241aa1(%rip), %xmm0   # 0x25f770
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1ddd5
movq 0x140(%rsp), %rax
movsd 0x50(%rax), %xmm0
movq 0x120(%rsp), %rax
ucomisd 0x50(%rax), %xmm0
jbe 0x1dd0d
movq 0x120(%rsp), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x1dd20
movq 0x140(%rsp), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x118(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1dd5a
movsd 0x241a27(%rip), %xmm0   # 0x25f770
mulsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0x1dd6a
movsd 0x1df2b6(%rip), %xmm0   # 0x1fd018
movsd %xmm0, 0x58(%rsp)
jmp 0x1dd6a
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
movq 0x140(%rsp), %rdi
addq $0x8, %rdi
movq 0x120(%rsp), %rsi
addq $0x8, %rsi
callq 0xc0520
movsd %xmm0, 0x50(%rsp)
jmp 0x1dd9e
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0x110(%rsp), %xmm1
mulsd 0x110(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1ddd3
jmp 0x1e028
jmp 0x1ddd5
movsd 0x24aa63(%rip), %xmm0   # 0x268840
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1df36
movq 0x140(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f700
movsd %xmm0, 0x48(%rsp)
jmp 0x1de03
movq 0x120(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f700
movsd %xmm0, 0x40(%rsp)
jmp 0x1de1c
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
subsd %xmm1, %xmm0
movaps 0x1df23d(%rip), %xmm1   # 0x1fd070
pand %xmm1, %xmm0
movsd %xmm0, 0x100(%rsp)
movsd 0x100(%rsp), %xmm0
ucomisd 0x24a9ef(%rip), %xmm0   # 0x268840
jbe 0x1de58
jmp 0x1e028
movq 0x140(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f710
movsd %xmm0, 0x38(%rsp)
jmp 0x1de71
movq 0x120(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f710
movsd %xmm0, 0x30(%rsp)
jmp 0x1de8a
movsd 0x30(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
subsd %xmm1, %xmm0
movaps 0x1df1cf(%rip), %xmm1   # 0x1fd070
pand %xmm1, %xmm0
movsd %xmm0, 0xf8(%rsp)
movsd 0xf8(%rsp), %xmm0
ucomisd 0x24a981(%rip), %xmm0   # 0x268840
jbe 0x1dec6
jmp 0x1e028
movq 0x140(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f720
movsd %xmm0, 0x28(%rsp)
jmp 0x1dedf
movq 0x120(%rsp), %rdi
addq $0x78, %rdi
callq 0x1f720
movsd %xmm0, 0x20(%rsp)
jmp 0x1def8
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
subsd %xmm1, %xmm0
movaps 0x1df161(%rip), %xmm1   # 0x1fd070
pand %xmm1, %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0xf0(%rsp), %xmm0
ucomisd 0x24a913(%rip), %xmm0   # 0x268840
jbe 0x1df34
jmp 0x1e028
jmp 0x1df36
movsd 0x24a90a(%rip), %xmm0   # 0x268848
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1e008
movq 0x140(%rsp), %rdi
addq $0x20, %rdi
movq 0x120(%rsp), %rsi
addq $0x20, %rsi
callq 0x12c4c0
movsd %xmm0, 0x18(%rsp)
jmp 0x1df70
movsd 0x18(%rsp), %xmm0
movaps 0x1df0f3(%rip), %xmm1   # 0x1fd070
pand %xmm1, %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x1df08e(%rip), %xmm0   # 0x1fd020
ucomisd 0xe8(%rsp), %xmm0
jbe 0x1dfd1
leaq 0x1e57ac(%rip), %rax    # 0x203750
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xe8(%rsp), %xmm0
callq 0x166c0
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x1dfe2
leaq 0x1e5778(%rip), %rax    # 0x203750
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm0
ucomisd 0x24a846(%rip), %xmm0   # 0x268848
jbe 0x1e006
jmp 0x1e028
jmp 0x1e008
movq 0x140(%rsp), %rdi
addq $0xb0, %rdi
movq 0x120(%rsp), %rsi
callq 0x1f3d0
jmp 0x1e026
jmp 0x1e028
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0x1dba0
jmp 0x1e040
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0x1db46
jmp 0x1e058
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x1dac0
movl $0x1, 0x2f4(%rsp)
movl $0x1, 0x150(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x1f2b0
jmp 0x1e0a2
leaq 0x158(%rsp), %rdi
callq 0x1f2b0
jmp 0x1e0b1
movl 0x2f4(%rsp), %eax
addq $0x2f8, %rsp            # imm = 0x2F8
retq
movq 0x2b8(%rsp), %rdi
callq 0x16ca0
nop