// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDUtil.cpp
// Function: gaps::RGBDCreateTangentChannels(gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid const&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Vector const&, double, int, int)
int RGBDCreateTangentChannels(const R2Grid& input_depth_image, 
  const R2Grid& input_px_image, const R2Grid& input_py_image, const R2Grid& input_pz_image,
  const R2Grid& input_boundary_image,
  R2Grid& output_nx_image, R2Grid& output_ny_image, R2Grid& output_nz_image,
  R2Grid& output_tx_image, R2Grid& output_ty_image, R2Grid& output_tz_image,
  R2Grid& output_r1_image, R2Grid& output_r2_image,
  const R3Point& viewpoint, const R3Vector& towards, const R3Vector& up,
  RNLength neighborhood_world_radius, int neighborhood_pixel_radius, RNBoolean neighborhood_search)
{
  // Initialize normal images
  output_nx_image = input_depth_image; 
  output_nx_image.Clear(R2_GRID_UNKNOWN_VALUE);
  output_ny_image = output_nx_image;
  output_nz_image = output_nx_image;
  output_tx_image = output_nx_image;
  output_ty_image = output_nx_image;
  output_tz_image = output_nx_image;
  output_r1_image = output_nx_image;
  output_r2_image = output_nx_image;

  // Allocate array of neighborhood points
  int pixel_radius = neighborhood_pixel_radius * input_depth_image.XResolution() / 640.0 + 0.5;
  if (pixel_radius == 0) pixel_radius = 1;
  int neighborhood_pixel_radius_squared = pixel_radius * pixel_radius;
  RNScalar neighborhood_world_radius_squared = neighborhood_world_radius * neighborhood_world_radius;
  R3Point *neighborhood_points = new R3Point [ input_depth_image.NEntries() ];

  // Allocate search grid
  R2Grid search_grid(input_depth_image.XResolution(), input_depth_image.YResolution());
  const RNScalar *search_valuesp = search_grid.GridValues();
  search_grid.Clear(-1);

  // Fill normal images
  for (int i = 0; i < input_depth_image.XResolution(); i++) {
    for (int j = 0; j < input_depth_image.YResolution(); j++) {
      int neighborhood_npoints = 0;

      // Check depth
      RNScalar depth = input_depth_image.GridValue(i, j);
      if (RNIsNegativeOrZero(depth)) continue;

      // Get image position
      R2Point image_position(i, j);

      // Get world position
      RNScalar x = input_px_image.GridValue(i, j);
      RNScalar y = input_py_image.GridValue(i, j);
      RNScalar z = input_pz_image.GridValue(i, j);
      R3Point world_position(x, y, z);

      // Create array of neighborhood points
      if (neighborhood_search) {
        // Initialize stack
        int seed_index;
        RNArray<const RNScalar *> stack;
        search_grid.IndicesToIndex(i, j, seed_index);
        const RNScalar *seed_valuep = &search_valuesp[seed_index];
        search_grid.SetGridValue(seed_index, seed_index);
        stack.Insert(seed_valuep);

        // Depth first search, not extending beyond boundaries
        while (!stack.IsEmpty()) {
          // Pop current point off stack
          int ix, iy;
          const RNScalar *current_valuep = stack.Tail(); stack.RemoveTail();
          int current_index = current_valuep - search_valuesp;
          search_grid.IndexToIndices(current_index, ix, iy);

          // Get current info
          RNScalar current_x = input_px_image.GridValue(ix, iy);
          RNScalar current_y = input_py_image.GridValue(ix, iy);
          RNScalar current_z = input_pz_image.GridValue(ix, iy);
          R3Point current_position(current_x, current_y, current_z);
          RNScalar current_boundary_value = input_boundary_image.GridValue(ix, iy);
          int current_boundary = (int) (current_boundary_value + 0.5);
        
          // Add point to array
          neighborhood_points[neighborhood_npoints++] = current_position;

          // Add adjacent points to stack
          for (int inx = ix-1; inx <= ix+1; inx++) {
            if ((inx < 0) || (inx >= search_grid.XResolution())) continue;
            for (int iny = iy-1; iny <= iy+1; iny++) {
              if ((iny < 0) || (iny >= search_grid.YResolution())) continue;

              // Check if neighbor has already been visited
              RNScalar neighbor_value = search_grid.GridValue(inx, iny);
              if (RNIsEqual(neighbor_value, seed_index)) continue;
              search_grid.SetGridValue(inx, iny, seed_index);

              // Check neighbor depth
              RNScalar neighbor_depth = input_depth_image.GridValue(inx, iny);
              if (RNIsNegativeOrZero(neighbor_depth)) continue;

              // Check neighbor image distance
              R2Point neighbor_image_position(inx, iny);
              if (R2SquaredDistance(image_position, neighbor_image_position) > neighborhood_pixel_radius_squared) continue;
            
              // Check neighbor world distance
              RNScalar neighbor_x = input_px_image.GridValue(inx, iny);
              RNScalar neighbor_y = input_py_image.GridValue(inx, iny);
              RNScalar neighbor_z = input_pz_image.GridValue(inx, iny);
              R3Point neighbor_world_position(neighbor_x, neighbor_y, neighbor_z);
              if (neighborhood_world_radius_squared > 0) {
                if (R3SquaredDistance(world_position, neighbor_world_position) > neighborhood_world_radius_squared) continue;
              }

              // Check if neighbor is across boundary
              int neighbor_boundary = (int) (input_boundary_image.GridValue(inx, iny) + 0.5);
              if ((current_boundary == RGBD_SHADOW_BOUNDARY) && (neighbor_boundary == RGBD_SILHOUETTE_BOUNDARY)) continue;
              if ((current_boundary == RGBD_SILHOUETTE_BOUNDARY) && (neighbor_boundary == RGBD_SHADOW_BOUNDARY)) continue;
        
              // Add neighbor to search
              int neighbor_index;
              search_grid.IndicesToIndex(inx, iny, neighbor_index);
              const RNScalar *neighbor_valuep = &search_valuesp[neighbor_index];
              stack.Insert(neighbor_valuep);
            }
          }
        }
      }
      else {
        // Add neighbor points to array
        for (int inx = i-neighborhood_pixel_radius; inx <= i+neighborhood_pixel_radius; inx++) {
          if ((inx < 0) || (inx >= input_depth_image.XResolution())) continue;
          for (int iny = j-neighborhood_pixel_radius; iny <= j+neighborhood_pixel_radius; iny++) {
            if ((iny < 0) || (iny >= input_depth_image.YResolution())) continue;
            
            // Check neighbor depth
            RNScalar neighbor_depth = input_depth_image.GridValue(inx, iny);
            if (RNIsNegativeOrZero(neighbor_depth)) continue;

            // Check neighbor world position
            RNScalar neighbor_x = input_px_image.GridValue(inx, iny);
            RNScalar neighbor_y = input_py_image.GridValue(inx, iny);
            RNScalar neighbor_z = input_pz_image.GridValue(inx, iny);
            R3Point neighbor_world_position(neighbor_x, neighbor_y, neighbor_z);
            if (neighborhood_world_radius_squared > 0) {
              if (R3SquaredDistance(world_position, neighbor_world_position) > neighborhood_world_radius_squared) continue;
            }

            // Add neighbor point to array
            neighborhood_points[neighborhood_npoints++] = neighbor_world_position;
          }
        }
      }

      // Check number of neighbor points
      if (neighborhood_npoints < 3) continue;

      // Solve for normal
      RNScalar variances[3];
      R3Point centroid = R3Centroid(neighborhood_npoints, neighborhood_points);
      R3Triad triad = R3PrincipleAxes(centroid, neighborhood_npoints, neighborhood_points, NULL, variances);
      R3Vector normal = triad[2];
      R3Vector tangent = triad[0];
      
      // Flip normal to point towards camera
      R3Plane plane(world_position, normal);
      if (R3SignedDistance(plane, viewpoint) < 0) normal.Flip(); 

      // Fill normal images
      output_nx_image.SetGridValue(i, j, normal.X());
      output_ny_image.SetGridValue(i, j, normal.Y());
      output_nz_image.SetGridValue(i, j, normal.Z());

      // Fill tangent images
      output_tx_image.SetGridValue(i, j, tangent.X());
      output_ty_image.SetGridValue(i, j, tangent.Y());
      output_tz_image.SetGridValue(i, j, tangent.Z());

      // Fill radius images
      RNScalar r1 = 3 * sqrt(variances[0]);
      RNScalar r2 = 3 * sqrt(variances[1]);
      if (neighborhood_pixel_radius > 1) r1 /= neighborhood_pixel_radius;
      if (neighborhood_pixel_radius > 1) r2 /= neighborhood_pixel_radius;
      output_r1_image.SetGridValue(i, j, r1);
      output_r2_image.SetGridValue(i, j, r2);
    }
  }

  // Delete array of neighborhood points
  delete [] neighborhood_points;

  // Return success 
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movsd %xmm0, 0x18(%rsp)
movq %r9, %rbx
movq %r8, 0x98(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %rbp
movq 0x2b8(%rsp), %r14
movq 0x2b0(%rsp), %r15
movq 0x2a8(%rsp), %r12
movq 0x2a0(%rsp), %r13
movq %r9, %rdi
movq %rbp, %rsi
callq 0x5872a
movsd 0x8793d(%rip), %xmm0    # 0xa8010
movq %rbx, %rdi
callq 0x59dcc
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5872a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5872a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5872a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5872a
movq 0x2c0(%rsp), %rdi
movq %rbx, %rsi
callq 0x5872a
movq 0x2c8(%rsp), %rdi
movq %rbx, %rsi
callq 0x5872a
movq 0x2d0(%rsp), %rdi
movq %rbx, 0xa0(%rsp)
movq %rbx, %rsi
callq 0x5872a
movl 0xc0(%rbp), %ebx
movl %ebx, %eax
movl 0x2f0(%rsp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
divsd 0x88a33(%rip), %xmm0    # 0xa9190
addsd 0x878b3(%rip), %xmm0    # 0xa8018
cvttsd2si %xmm0, %r12d
cmpl $0x1, %r12d
adcl $0x0, %r12d
movslq 0xcc(%rbp), %r15
pushq $0x18
popq %rcx
movq %r15, %rax
mulq %rcx
pushq $-0x1
popq %r14
cmovnoq %rax, %r14
movq %r14, %rdi
callq 0x11040
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0x207c0
imulq $0x18, %r15, %rbx
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
leaq (%rax,%r15), %rdi
callq 0x45d4a
addq $0x18, %r15
cmpq %r15, %rbx
jne 0x207a3
movl 0xc0(%rbp), %ebx
movl 0xc4(%rbp), %edx
leaq 0x198(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x57e7c
movq 0xb8(%r14), %rax
movq %rax, 0x48(%rsp)
movsd 0x8781c(%rip), %xmm0    # 0xa8008
movq %r14, %rdi
callq 0x59dcc
imull %r12d, %r12d
movsd 0x18(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0xb8(%rsp)
movl 0x2f0(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x90(%rsp)
xorl %eax, %eax
leaq 0xd74c5(%rip), %r12     # 0xf7cf8
leaq 0x150(%rsp), %r13
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %rbx
cmpl 0xc0(%rbp), %eax
jge 0x21125
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl %eax, %ecx
movq %rax, 0x8(%rsp)
movl 0x2f0(%rsp), %eax
subl %eax, %ecx
movl %ecx, 0x5c(%rsp)
movq 0x8(%rsp), %rcx
addl %ecx, %eax
movl %eax, 0x60(%rsp)
movq 0x8(%rsp), %rax
xorl %r14d, %r14d
cmpl 0xc4(%rbp), %r14d
jge 0x2111e
movq %rax, %rdx
movq 0xb8(%rbp), %rax
movl 0xc8(%rbp), %ecx
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%r12), %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jae 0x21111
cvtsi2sd %r14d, %xmm1
leaq 0x140(%rsp), %rdi
movsd 0xa8(%rsp), %xmm0
callq 0x66640
movq 0x30(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
movq 0x8(%rsp), %rdx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x40(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
movq %r14, 0x28(%rsp)
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
leaq 0x108(%rsp), %rdi
callq 0x45d4c
cmpl $0x0, 0x2f8(%rsp)
je 0x20d24
movq %r15, %rdi
callq 0x6c0ba
movl 0x260(%rsp), %eax
imull 0x28(%rsp), %eax
addl 0x8(%rsp), %eax
cltq
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
cvtsi2sd %eax, %xmm0
movq 0x250(%rsp), %rcx
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, (%rcx,%rax,8)
movq %r15, %rdi
callq 0x15616
xorl %r14d, %r14d
movslq 0x7c(%rsp), %rax
testq %rax, %rax
je 0x20d0f
movq %r14, %rbx
movq 0x70(%rsp), %rcx
movq -0x8(%rcx,%rax,8), %r14
movq %r15, %rdi
callq 0x1966a
subq 0x48(%rsp), %r14
shrq $0x3, %r14
movl %r14d, %eax
cltd
idivl 0x260(%rsp)
movl %eax, %r14d
movl %edx, %r15d
movq 0x30(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x40(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq %r13, %rdi
callq 0x45d4c
movq 0x98(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r14d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x50(%rsp)
imulq $0x18, %rbx, %rdi
addq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x46036
incq %rbx
movq %rbx, 0xb0(%rsp)
movsd 0x50(%rsp), %xmm0
addsd 0x8757e(%rip), %xmm0    # 0xa8018
cvttsd2si %xmm0, %eax
movl %eax, 0x68(%rsp)
leal -0x1(%r15), %ebx
incl %r15d
leal -0x1(%r14), %eax
movl %eax, 0x64(%rsp)
incl %r14d
movq %r15, %r13
leaq 0x70(%rsp), %r15
cmpl %r13d, %ebx
jg 0x20cf5
testl %ebx, %ebx
js 0x20cee
cmpl 0x258(%rsp), %ebx
jge 0x20cee
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x50(%rsp)
movl 0x64(%rsp), %r15d
movl %ebx, 0x6c(%rsp)
cmpl %r14d, %r15d
jg 0x20cee
testl %r15d, %r15d
js 0x20ce6
cmpl 0x25c(%rsp), %r15d
jge 0x20ce6
movq 0x250(%rsp), %rax
movl 0x260(%rsp), %ecx
imull %r15d, %ecx
addl %ebx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd (%r12), %xmm1
subsd 0x20(%rsp), %xmm0
movapd %xmm1, %xmm2
xorpd 0x8750e(%rip), %xmm2    # 0xa8050
ucomisd %xmm2, %xmm0
jb 0x20b52
ucomisd %xmm0, %xmm1
jae 0x20ce6
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq 0xb8(%rbp), %rax
movl 0xc8(%rbp), %ecx
imull %r15d, %ecx
addl %ebx, %ecx
movslq %ecx, %rcx
movsd (%r12), %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jae 0x20ce6
movq %r14, %rbx
movq %rbp, %r14
movq %r12, %rbp
movq %r13, %r12
cvtsi2sd %r15d, %xmm1
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
movsd 0x50(%rsp), %xmm0
callq 0x66640
leaq 0x140(%rsp), %rdi
movq %r13, %rsi
callq 0x55ac6
ucomisd 0xb8(%rsp), %xmm0
movq %r12, %r13
movq %rbp, %r12
movq %r14, %rbp
movq %rbx, %r14
movl 0x6c(%rsp), %ebx
ja 0x20ce6
movq 0x30(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r15d, %ecx
addl %ebx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r15d, %ecx
addl %ebx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x40(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r15d, %ecx
addl %ebx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
leaq 0x120(%rsp), %rdi
callq 0x45d4c
movsd 0x18(%rsp), %xmm0
ucomisd 0x873e3(%rip), %xmm0    # 0xa8038
jbe 0x20c74
leaq 0x108(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x2492d
ucomisd 0x18(%rsp), %xmm0
ja 0x20ce6
movl 0x68(%rsp), %ecx
movl %ecx, %eax
xorl $0x2, %eax
xorl $0x4, %ecx
movq 0x98(%rsp), %rsi
movq 0xb8(%rsi), %rdx
movl 0xc8(%rsi), %esi
imull %r15d, %esi
addl %ebx, %esi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm0
addsd 0x8736d(%rip), %xmm0    # 0xa8018
cvttsd2si %xmm0, %edx
movl %edx, %esi
xorl $0x2, %esi
xorl $0x4, %edx
orl %eax, %edx
sete %al
orl %ecx, %esi
je 0x20ce6
testb %al, %al
jne 0x20ce6
movl 0x260(%rsp), %eax
imull %r15d, %eax
addl %ebx, %eax
cltq
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
leaq 0x70(%rsp), %rdi
callq 0x15616
incl %r15d
jmp 0x20aed
incl %ebx
jmp 0x20ab7
movq 0x10(%rsp), %rbx
leaq 0x150(%rsp), %r13
movq 0xb0(%rsp), %r14
jmp 0x209a1
movq %r15, %rdi
callq 0x6c128
leaq 0xf0(%rsp), %rcx
jmp 0x20e98
movq 0x28(%rsp), %rcx
movl %ecx, %edx
movl 0x2f0(%rsp), %eax
subl %eax, %edx
movl %edx, 0x20(%rsp)
leal (%rcx,%rax), %r14d
xorl %ebx, %ebx
movl 0x5c(%rsp), %r15d
cmpl 0x60(%rsp), %r15d
jg 0x20e80
testl %r15d, %r15d
js 0x20e78
cmpl 0xc0(%rbp), %r15d
jge 0x20e78
movl 0x20(%rsp), %r13d
cmpl %r14d, %r13d
jg 0x20e70
testl %r13d, %r13d
js 0x20e68
cmpl 0xc4(%rbp), %r13d
jge 0x20e68
movq 0xb8(%rbp), %rax
movl 0xc8(%rbp), %ecx
imull %r13d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movsd (%r12), %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jae 0x20e68
movq 0x30(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r13d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x38(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r13d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x40(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %r13d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
leaq 0x150(%rsp), %rdi
callq 0x45d4c
movsd 0x18(%rsp), %xmm0
ucomisd 0x8720a(%rip), %xmm0    # 0xa8038
jbe 0x20e4d
leaq 0x108(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x2492d
ucomisd 0x18(%rsp), %xmm0
ja 0x20e68
movslq %ebx, %rax
imulq $0x18, %rax, %rdi
addq 0x10(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x46036
incl %ebx
incl %r13d
jmp 0x20d69
leaq 0x150(%rsp), %r13
incl %r15d
jmp 0x20d43
movq 0x10(%rsp), %rax
leaq 0xf0(%rsp), %rcx
leaq 0x70(%rsp), %r15
movq %rbx, %r14
movq %rax, %rbx
cmpl $0x3, %r14d
jl 0x2110c
movq %rcx, %rdi
movl %r14d, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x28400
movq %r13, %rdi
leaq 0xf0(%rsp), %rsi
movl %r14d, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x28489
leaq 0xc0(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x4651c
leaq 0xd8(%rsp), %rdi
movq %r13, %rsi
callq 0x4651c
leaq 0x120(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x449ac
leaq 0x120(%rsp), %rdi
movq 0x2d8(%rsp), %rsi
callq 0x24b5c
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x20f3c
leaq 0xc0(%rsp), %rdi
callq 0x46862
movsd 0xc0(%rsp), %xmm0
movq 0xa0(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
movq 0x28(%rsp), %rsi
imull %esi, %ecx
movq 0x8(%rsp), %rdx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xc8(%rsp), %xmm0
movq 0x2a0(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xd0(%rsp), %xmm0
movq 0x2a8(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xd8(%rsp), %xmm0
movq 0x2b0(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xe0(%rsp), %xmm0
movq 0x2b8(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0xe8(%rsp), %xmm0
movq 0x2c0(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x70(%rsp), %xmm0
ucomisd 0x86fe2(%rip), %xmm0    # 0xa8038
jb 0x2105e
sqrtsd %xmm0, %xmm1
jmp 0x21067
callq 0x11480
movapd %xmm0, %xmm1
mulsd 0x88129(%rip), %xmm1    # 0xa9198
movsd 0x78(%rsp), %xmm0
ucomisd 0x86fbb(%rip), %xmm0    # 0xa8038
jb 0x21085
sqrtsd %xmm0, %xmm0
jmp 0x21096
movsd %xmm1, 0x20(%rsp)
callq 0x11480
movsd 0x20(%rsp), %xmm1
mulsd 0x880fa(%rip), %xmm0    # 0xa9198
movl 0x2f0(%rsp), %eax
cmpl $0x2, %eax
jl 0x210b3
divsd 0x90(%rsp), %xmm1
jl 0x210be
divsd 0x90(%rsp), %xmm0
movq 0x2c8(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
movq 0x28(%rsp), %rsi
imull %esi, %ecx
movq 0x8(%rsp), %rdx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm1, (%rax,%rcx,8)
movq 0x2d0(%rsp), %rcx
movq 0xb8(%rcx), %rax
movl 0xc8(%rcx), %ecx
imull %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x28(%rsp), %r14
incl %r14d
movq 0x8(%rsp), %rax
jmp 0x20885
incl %eax
jmp 0x20845
movq %rbx, %rdi
callq 0x117a0
leaq 0x198(%rsp), %rdi
callq 0x589c0
pushq $0x1
popq %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2117b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x11bc0
jmp 0x2119e
jmp 0x2117b
jmp 0x2117b
jmp 0x2117b
jmp 0x2117b
jmp 0x21184
jmp 0x2117b
jmp 0x2117b
jmp 0x2117b
jmp 0x2117b
jmp 0x21184
jmp 0x21184
jmp 0x21184
movq %rax, %rbx
jmp 0x21191
jmp 0x21184
jmp 0x21184
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x6c128
leaq 0x198(%rsp), %rdi
callq 0x589c0
movq %rbx, %rdi
callq 0x11a80