// File: tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RenderGridTriangle(gaps::R2Point const&, gaps::R2Point const&, gaps::R2Point const&, double, double, double, double, double, double, gaps::R2Grid&)
void R2Grid::
RenderGridTriangle(
   const R2Point& pointA, const R2Point& pointB, const R2Point& pointC,
   RNScalar valueA, RNScalar valueB, RNScalar valueC,
   RNScalar depthA, RNScalar depthB, RNScalar depthC,
   R2Grid& depth_grid)
{
  // Check values
  if (valueA == R2_GRID_UNKNOWN_VALUE) return;
  if (valueB == R2_GRID_UNKNOWN_VALUE) return;
  if (valueC == R2_GRID_UNKNOWN_VALUE) return;

  // Check depths
  if (depthA == R2_GRID_UNKNOWN_VALUE) return;
  if (depthB == R2_GRID_UNKNOWN_VALUE) return;
  if (depthC == R2_GRID_UNKNOWN_VALUE) return;

  // Get convenient variables
  R2Point points[3] = { pointA, pointB, pointC };
  RNScalar values[3] = { valueA, valueB, valueC };
  RNScalar depths[3] = { depthA, depthB, depthC };

  // Sort vertex indices by Y coordinate
  int iv0, iv1, iv2;
  if (points[0].Y() < points[1].Y()) {
    if (points[0].Y() < points[2].Y()) { 
      if (points[1].Y() < points[2].Y()) { iv0 = 0; iv1 = 1; iv2 = 2; }
      else { iv0 = 0; iv1 = 2; iv2 = 1; }
    }
    else { iv0 = 2; iv1 = 0; iv2 = 1; }
  }
  else {
    if (points[1].Y() < points[2].Y()) { 
      if (points[0].Y() < points[2].Y()) { iv0 = 1; iv1 = 0; iv2 = 2; }
      else { iv0 = 1; iv1 = 2; iv2 = 0; }
    }
    else { iv0 = 2; iv1 = 1; iv2 = 0; }
  }
  
  // Sort vertex coordinates
  double dy = points[iv2].Y() - points[iv0].Y();
  double t1 = (dy > 0) ? (points[iv1].Y() - points[iv0].Y()) / dy : 0;
  double y0 = points[iv0].Y();
  double y1 = points[iv1].Y();
  double y2 = points[iv2].Y();
  double x0 = points[iv0].X();
  double x2 = points[iv2].X();
  double x1a = points[iv1].X();
  double x1b = (1-t1)*x0 + t1*x2;
  double value0 = values[iv0];
  double value2 = values[iv2];
  double value1a = values[iv1];
  double value1b = (1-t1)*value0 + t1*value2;
  double depth0 = depths[iv0];
  double depth2 = depths[iv2];
  double depth1a = depths[iv1];
  double depth1b = (1-t1)*depth0 + t1*depth2;
  if (x1a > x1b) { 
    double swap;
    swap = x1a; x1a = x1b; x1b = swap; 
    swap = value1a; value1a = value1b; value1b = swap; 
    swap = depth1a; depth1a = depth1b; depth1b = swap; 
  }

  // Rasterize lower half of triangle
  int iy0 = (int) (y0 + 0.5);
  int iy1 = (int) (y1 + 0.5);
  int nysteps = iy1 - iy0;
  double xa_step = (nysteps > 0) ? (x1a - x0) / nysteps : 0;
  double xb_step = (nysteps > 0) ? (x1b - x0) / nysteps : 0;
  double valuea_step = (nysteps > 0) ? (value1a  - value0) / nysteps : 0;
  double valueb_step = (nysteps > 0) ? (value1b  - value0) / nysteps : 0;
  double deptha_step = (nysteps > 0) ? (depth1a  - depth0) / nysteps : 0;
  double depthb_step = (nysteps > 0) ? (depth1b  - depth0) / nysteps : 0;
  double xa = x0;
  double xb = x0;
  double valuea = value0;
  double valueb = value0;
  double deptha = depth0;
  double depthb = depth0;
  for (int iy = iy0; iy <= iy1; iy++) {
    int ixa = (int) (xa + 0.5);
    int ixb = (int) (xb + 0.5);
    int nxsteps = ixb - ixa;
    double value_step = (nxsteps > 0) ? (valueb - valuea) / nxsteps : 0;
    double depth_step = (nxsteps > 0) ? (depthb - deptha) / nxsteps : 0;
    double value = valuea;
    double depth = deptha;
    for (int ix = ixa; ix <= ixb; ix++) {
      RNScalar old_depth = depth_grid.GridValue(ix, iy);
      if ((old_depth == R2_GRID_UNKNOWN_VALUE) || (depth < old_depth)) {
        SetGridValue(ix, iy, value);
        depth_grid.SetGridValue(ix, iy, depth);
      }
      value += value_step;
      depth += depth_step;
    }
    valuea += valuea_step;
    valueb += valueb_step;
    deptha += deptha_step;
    depthb += depthb_step;
    xa += xa_step;
    xb += xb_step;
  }
  
  // Rasterize upper half of triangle
  int iy2 = (int) (y2 + 0.5);
  nysteps = iy2 - iy1;
  xa_step = (nysteps > 0) ? (x2 - x1a) / nysteps : 0;
  xb_step = (nysteps > 0) ? (x2 - x1b) / nysteps : 0;
  valuea_step = (nysteps > 0) ? (value2  - value1a) / nysteps : 0;
  valueb_step = (nysteps > 0) ? (value2  - value1b) / nysteps : 0;
  deptha_step = (nysteps > 0) ? (depth2  - depth1a) / nysteps : 0;
  depthb_step = (nysteps > 0) ? (depth2  - depth1b) / nysteps : 0;
  xa = x1a;
  xb = x1b;
  valuea = value1a;
  valueb = value1b;
  deptha = depth1a;
  depthb = depth1b;
  for (int iy = iy1; iy <= iy2; iy++) {
    int ixa = (int) (xa + 0.5);
    int ixb = (int) (xb + 0.5);
    int nxsteps = ixb - ixa;
    double value_step = (nxsteps > 0) ? (valueb - valuea) / nxsteps : 0;
    double depth_step = (nxsteps > 0) ? (depthb - deptha) / nxsteps : 0;
    double value = valuea;
    double depth = deptha;
    for (int ix = ixa; ix <= ixb; ix++) {
      RNScalar old_depth = depth_grid.GridValue(ix, iy);
      if ((old_depth == R2_GRID_UNKNOWN_VALUE) || (depth < old_depth)) {
        SetGridValue(ix, iy, value);
        depth_grid.SetGridValue(ix, iy, depth);
      }
      value += value_step;
      depth += depth_step;
    }
    valuea += valuea_step;
    valueb += valueb_step;
    deptha += deptha_step;
    depthb += depthb_step;
    xa += xa_step;
    xb += xb_step;
  }
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movq %rdi, 0x320(%rsp)
movq %rsi, 0x318(%rsp)
movq %rdx, 0x310(%rsp)
movq %rcx, 0x308(%rsp)
movsd %xmm0, 0x300(%rsp)
movsd %xmm1, 0x2f8(%rsp)
movsd %xmm2, 0x2f0(%rsp)
movsd %xmm3, 0x2e8(%rsp)
movsd %xmm4, 0x2e0(%rsp)
movsd %xmm5, 0x2d8(%rsp)
movq %r8, 0x2d0(%rsp)
movq 0x320(%rsp), %rax
movq %rax, 0xc0(%rsp)
movsd 0x300(%rsp), %xmm0
movsd 0x8183a(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb2683
jp 0xb2683
jmp 0xb384e
movsd 0x2f8(%rsp), %xmm0
movsd 0x8181c(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb26a1
jp 0xb26a1
jmp 0xb384e
movsd 0x2f0(%rsp), %xmm0
movsd 0x817fe(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb26bf
jp 0xb26bf
jmp 0xb384e
movsd 0x2e8(%rsp), %xmm0
movsd 0x817e0(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb26dd
jp 0xb26dd
jmp 0xb384e
movsd 0x2e0(%rsp), %xmm0
movsd 0x817c2(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb26fb
jp 0xb26fb
jmp 0xb384e
movsd 0x2d8(%rsp), %xmm0
movsd 0x817a4(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb2719
jp 0xb2719
jmp 0xb384e
movq 0x318(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
callq 0xc3170
leaq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
movq 0x310(%rsp), %rsi
callq 0xc3170
leaq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
movq 0x308(%rsp), %rsi
callq 0xc3170
movsd 0x300(%rsp), %xmm0
movsd %xmm0, 0x280(%rsp)
movsd 0x2f8(%rsp), %xmm0
movsd %xmm0, 0x288(%rsp)
movsd 0x2f0(%rsp), %xmm0
movsd %xmm0, 0x290(%rsp)
movsd 0x2e8(%rsp), %xmm0
movsd %xmm0, 0x260(%rsp)
movsd 0x2e0(%rsp), %xmm0
movsd %xmm0, 0x268(%rsp)
movsd 0x2d8(%rsp), %xmm0
movsd %xmm0, 0x270(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0x38c60
movsd %xmm0, 0xb8(%rsp)
leaq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x38c60
movsd 0xb8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb28e6
leaq 0x2a0(%rsp), %rdi
callq 0x38c60
movsd %xmm0, 0xb0(%rsp)
leaq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
callq 0x38c60
movsd 0xb0(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb28c0
leaq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x38c60
movsd %xmm0, 0xa8(%rsp)
leaq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
callq 0x38c60
movsd 0xa8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb289d
movl $0x0, 0x25c(%rsp)
movl $0x1, 0x258(%rsp)
movl $0x2, 0x254(%rsp)
jmp 0xb28be
movl $0x0, 0x25c(%rsp)
movl $0x2, 0x258(%rsp)
movl $0x1, 0x254(%rsp)
jmp 0xb28e1
movl $0x2, 0x25c(%rsp)
movl $0x0, 0x258(%rsp)
movl $0x1, 0x254(%rsp)
jmp 0xb29bf
leaq 0x2a0(%rsp), %rdi
addq $0x10, %rdi
callq 0x38c60
movsd %xmm0, 0xa0(%rsp)
leaq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
callq 0x38c60
movsd 0xa0(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb299c
leaq 0x2a0(%rsp), %rdi
callq 0x38c60
movsd %xmm0, 0x98(%rsp)
leaq 0x2a0(%rsp), %rdi
addq $0x20, %rdi
callq 0x38c60
movsd 0x98(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb2979
movl $0x1, 0x25c(%rsp)
movl $0x0, 0x258(%rsp)
movl $0x2, 0x254(%rsp)
jmp 0xb299a
movl $0x1, 0x25c(%rsp)
movl $0x2, 0x258(%rsp)
movl $0x0, 0x254(%rsp)
jmp 0xb29bd
movl $0x2, 0x25c(%rsp)
movl $0x1, 0x258(%rsp)
movl $0x0, 0x254(%rsp)
jmp 0xb29bf
movslq 0x254(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movsd %xmm0, 0x90(%rsp)
movslq 0x25c(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movaps %xmm0, %xmm1
movsd 0x90(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x248(%rsp)
movsd 0x248(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xb2a90
movslq 0x258(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movsd %xmm0, 0x80(%rsp)
movslq 0x25c(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movaps %xmm0, %xmm1
movsd 0x80(%rsp), %xmm0
subsd %xmm1, %xmm0
divsd 0x248(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
jmp 0xb2a9e
xorps %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
jmp 0xb2a9e
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x240(%rsp)
movslq 0x25c(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movsd %xmm0, 0x238(%rsp)
movslq 0x258(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movsd %xmm0, 0x230(%rsp)
movslq 0x254(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c60
movsd %xmm0, 0x228(%rsp)
movslq 0x25c(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c50
movsd %xmm0, 0x220(%rsp)
movslq 0x254(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c50
movsd %xmm0, 0x218(%rsp)
movslq 0x258(%rsp), %rax
leaq 0x2a0(%rsp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x38c50
movsd %xmm0, 0x210(%rsp)
movsd 0x80472(%rip), %xmm0    # 0x133008
subsd 0x240(%rsp), %xmm0
movsd 0x220(%rsp), %xmm2
movsd 0x240(%rsp), %xmm1
mulsd 0x218(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x208(%rsp)
movslq 0x25c(%rsp), %rax
movsd 0x280(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x200(%rsp)
movslq 0x254(%rsp), %rax
movsd 0x280(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movslq 0x258(%rsp), %rax
movsd 0x280(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x803e7(%rip), %xmm0    # 0x133008
subsd 0x240(%rsp), %xmm0
movsd 0x200(%rsp), %xmm2
movsd 0x240(%rsp), %xmm1
mulsd 0x1f8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1e8(%rsp)
movslq 0x25c(%rsp), %rax
movsd 0x260(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movslq 0x254(%rsp), %rax
movsd 0x260(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x1d8(%rsp)
movslq 0x258(%rsp), %rax
movsd 0x260(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x8035c(%rip), %xmm0    # 0x133008
subsd 0x240(%rsp), %xmm0
movsd 0x1e0(%rsp), %xmm2
movsd 0x240(%rsp), %xmm1
mulsd 0x1d8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movsd 0x210(%rsp), %xmm0
ucomisd 0x208(%rsp), %xmm0
jbe 0xb2d9b
movsd 0x210(%rsp), %xmm0
movsd %xmm0, 0x1c0(%rsp)
movsd 0x208(%rsp), %xmm0
movsd %xmm0, 0x210(%rsp)
movsd 0x1c0(%rsp), %xmm0
movsd %xmm0, 0x208(%rsp)
movsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1c0(%rsp)
movsd 0x1e8(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1c0(%rsp), %xmm0
movsd %xmm0, 0x1e8(%rsp)
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x1c0(%rsp)
movsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x1c0(%rsp), %xmm0
movsd %xmm0, 0x1c8(%rsp)
movsd 0x8026d(%rip), %xmm0    # 0x133010
addsd 0x238(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1bc(%rsp)
movsd 0x80251(%rip), %xmm0    # 0x133010
addsd 0x230(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1b8(%rsp)
movl 0x1b8(%rsp), %eax
subl 0x1bc(%rsp), %eax
movl %eax, 0x1b4(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2e19
movsd 0x210(%rsp), %xmm0
subsd 0x220(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
jmp 0xb2e24
xorps %xmm0, %xmm0
movsd %xmm0, 0x78(%rsp)
jmp 0xb2e24
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x1a8(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2e64
movsd 0x208(%rsp), %xmm0
subsd 0x220(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0xb2e6f
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0xb2e6f
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x1a0(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2eaf
movsd 0x1f0(%rsp), %xmm0
subsd 0x200(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
jmp 0xb2eba
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
jmp 0xb2eba
movsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x198(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2efa
movsd 0x1e8(%rsp), %xmm0
subsd 0x200(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0xb2f05
xorps %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0xb2f05
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x190(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2f45
movsd 0x1d0(%rsp), %xmm0
subsd 0x1e0(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0xb2f50
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
jmp 0xb2f50
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb2f90
movsd 0x1c8(%rsp), %xmm0
subsd 0x1e0(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0xb2f9b
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0xb2f9b
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x180(%rsp)
movsd 0x220(%rsp), %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x220(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x160(%rsp)
movsd 0x1e0(%rsp), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x1e0(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
movl 0x1bc(%rsp), %eax
movl %eax, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
cmpl 0x1b8(%rsp), %eax
jg 0xb3304
movsd 0x7ffd0(%rip), %xmm0    # 0x133010
addsd 0x178(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x148(%rsp)
movsd 0x7ffb4(%rip), %xmm0    # 0x133010
addsd 0x170(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x144(%rsp)
movl 0x144(%rsp), %eax
subl 0x148(%rsp), %eax
movl %eax, 0x140(%rsp)
cmpl $0x0, 0x140(%rsp)
jle 0xb30b6
movsd 0x160(%rsp), %xmm0
subsd 0x168(%rsp), %xmm0
cvtsi2sdl 0x140(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
jmp 0xb30c1
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
jmp 0xb30c1
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x138(%rsp)
cmpl $0x0, 0x140(%rsp)
jle 0xb3101
movsd 0x150(%rsp), %xmm0
subsd 0x158(%rsp), %xmm0
cvtsi2sdl 0x140(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
jmp 0xb310c
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
jmp 0xb310c
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
movsd 0x168(%rsp), %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x158(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
movl 0x148(%rsp), %eax
movl %eax, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
cmpl 0x144(%rsp), %eax
jg 0xb324c
movq 0x2d0(%rsp), %rdi
movl 0x11c(%rsp), %esi
movl 0x14c(%rsp), %edx
callq 0xb92a0
movsd %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
movsd 0x80d1a(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb31a0
jp 0xb31a0
jmp 0xb31b8
movsd 0x120(%rsp), %xmm1
movsd 0x110(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb3200
movq 0xc0(%rsp), %rdi
movl 0x11c(%rsp), %esi
movl 0x14c(%rsp), %edx
movsd 0x128(%rsp), %xmm0
callq 0x6bc00
movq 0x2d0(%rsp), %rdi
movl 0x11c(%rsp), %esi
movl 0x14c(%rsp), %edx
movsd 0x120(%rsp), %xmm0
callq 0x6bc00
movsd 0x138(%rsp), %xmm0
addsd 0x128(%rsp), %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x130(%rsp), %xmm0
addsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0xb314d
movsd 0x198(%rsp), %xmm0
addsd 0x168(%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x190(%rsp), %xmm0
addsd 0x160(%rsp), %xmm0
movsd %xmm0, 0x160(%rsp)
movsd 0x188(%rsp), %xmm0
addsd 0x158(%rsp), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x180(%rsp), %xmm0
addsd 0x150(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
movsd 0x1a8(%rsp), %xmm0
addsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x1a0(%rsp), %xmm0
addsd 0x170(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0xb3024
movsd 0x7fd04(%rip), %xmm0    # 0x133010
addsd 0x228(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
subl 0x1b8(%rsp), %eax
movl %eax, 0x1b4(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb3366
movsd 0x218(%rsp), %xmm0
subsd 0x210(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb3371
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb3371
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x1a8(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb33b1
movsd 0x218(%rsp), %xmm0
subsd 0x208(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0xb33bc
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0xb33bc
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x1a0(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb33fc
movsd 0x1f8(%rsp), %xmm0
subsd 0x1f0(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0xb3407
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0xb3407
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x198(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb3447
movsd 0x1f8(%rsp), %xmm0
subsd 0x1e8(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0xb3452
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0xb3452
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x190(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb3492
movsd 0x1d8(%rsp), %xmm0
subsd 0x1d0(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0xb349d
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0xb349d
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jle 0xb34dd
movsd 0x1d8(%rsp), %xmm0
subsd 0x1c8(%rsp), %xmm0
cvtsi2sdl 0x1b4(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0xb34e8
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0xb34e8
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x180(%rsp)
movsd 0x210(%rsp), %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x208(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x1e8(%rsp), %xmm0
movsd %xmm0, 0x160(%rsp)
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
movl 0x1b8(%rsp), %eax
movl %eax, 0x108(%rsp)
movl 0x108(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jg 0xb384e
movsd 0x7fa83(%rip), %xmm0    # 0x133010
addsd 0x178(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x104(%rsp)
movsd 0x7fa67(%rip), %xmm0    # 0x133010
addsd 0x170(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x100(%rsp)
movl 0x100(%rsp), %eax
subl 0x104(%rsp), %eax
movl %eax, 0xfc(%rsp)
cmpl $0x0, 0xfc(%rsp)
jle 0xb3603
movsd 0x160(%rsp), %xmm0
subsd 0x168(%rsp), %xmm0
cvtsi2sdl 0xfc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0xb360e
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0xb360e
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xf0(%rsp)
cmpl $0x0, 0xfc(%rsp)
jle 0xb364d
movsd 0x150(%rsp), %xmm0
subsd 0x158(%rsp), %xmm0
cvtsi2sdl 0xfc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
jmp 0xb3657
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
jmp 0xb3657
movsd (%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x168(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0x158(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movl 0x104(%rsp), %eax
movl %eax, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
cmpl 0x100(%rsp), %eax
jg 0xb3796
movq 0x2d0(%rsp), %rdi
movl 0xd4(%rsp), %esi
movl 0x108(%rsp), %edx
callq 0xb92a0
movsd %xmm0, 0xc8(%rsp)
movsd 0xc8(%rsp), %xmm0
movsd 0x807d0(%rip), %xmm1    # 0x133eb0
ucomisd %xmm1, %xmm0
jne 0xb36ea
jp 0xb36ea
jmp 0xb3702
movsd 0xd8(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb374a
movq 0xc0(%rsp), %rdi
movl 0xd4(%rsp), %esi
movl 0x108(%rsp), %edx
movsd 0xe0(%rsp), %xmm0
callq 0x6bc00
movq 0x2d0(%rsp), %rdi
movl 0xd4(%rsp), %esi
movl 0x108(%rsp), %edx
movsd 0xd8(%rsp), %xmm0
callq 0x6bc00
movsd 0xf0(%rsp), %xmm0
addsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe8(%rsp), %xmm0
addsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movl 0xd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
jmp 0xb3697
movsd 0x198(%rsp), %xmm0
addsd 0x168(%rsp), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x190(%rsp), %xmm0
addsd 0x160(%rsp), %xmm0
movsd %xmm0, 0x160(%rsp)
movsd 0x188(%rsp), %xmm0
addsd 0x158(%rsp), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x180(%rsp), %xmm0
addsd 0x150(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
movsd 0x1a8(%rsp), %xmm0
addsd 0x178(%rsp), %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x1a0(%rsp), %xmm0
addsd 0x170(%rsp), %xmm0
movsd %xmm0, 0x170(%rsp)
movl 0x108(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x108(%rsp)
jmp 0xb3571
addq $0x328, %rsp            # imm = 0x328
retq
nopw %cs:(%rax,%rax)