// File: tomfunkhouser[P]gaps/apps/pfm2pfm/pfm2pfm.cpp
// Function: ApplyOperations(gaps::R2Grid*, Operation*, int)
static int
ApplyOperations(R2Grid *grid, Operation *operations, int noperations)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Apply operations
  for (int i = 0; i < noperations; i++) {
    Operation *operation = &operations[i];

    // Read grid operand
    R2Grid *grid1 = NULL;
    R2Grid *grid2 = NULL;
    switch (operation->type) {
    case ADD_GRID_OPERATION: 
    case SUBTRACT_GRID_OPERATION: 
    case MULTIPLY_GRID_OPERATION: 
    case DIVIDE_GRID_OPERATION: 
    case MASK_GRID_OPERATION: 
    case OVERLAY_GRID_OPERATION: 
    case THRESHOLD_GRID_OPERATION: 
      grid1 = ReadGrid(operation->operand1);
      if (!grid1) {
        RNFail("Unable to read grid file (%s) for operation %d\n", operation->operand1, i);
        return 0;
      }
      break;

    case POISSON_OPERATION: 
      grid1 = ReadGrid(operation->operand1);
      if (!grid1) {
        RNFail("Unable to read grid file (%s) for operation %d\n", operation->operand1, i);
        return 0;
      }
      grid2 = ReadGrid(operation->operand2);
      if (!grid2) {
        RNFail("Unable to read grid file (%s) for operation %d\n", operation->operand2, i);
        return 0;
      }
      break;
    }

    // Apply operation
    switch (operation->type) {
    case NOP_OPERATION: break;
    case ABS_OPERATION: grid->Abs(); break;
    case SQUARE_OPERATION: grid->Square(); break;
    case SQRT_OPERATION: grid->Sqrt(); break;
    case NEGATE_OPERATION: grid->Negate(); break;
    case INVERT_OPERATION: grid->Invert(); break;
    case NORMALIZE_OPERATION: grid->Normalize(); break;
    case DETECT_EDGES_OPERATION: grid->DetectEdges(); break;
    case DETECT_CORNERS_OPERATION: grid->DetectCorners(); break;
    case FILL_HOLES_OPERATION: grid->FillHoles(); break;
    case FILL_GAPS_OPERATION: grid->FillHoles(atoi(operation->operand1)); break;
    case GRADIENT_X_OPERATION: grid->Gradient(RN_X); break;
    case GRADIENT_Y_OPERATION: grid->Gradient(RN_Y); break;
    case GRADIENT_MAGNITUDE_OPERATION: grid->GradientMagnitude(); break;
    case GRADIENT_ANGLE_OPERATION: grid->GradientAngle(); break;
    case LAPLACIAN_OPERATION: grid->Laplacian(); break;
    case LAPLACIAN_X_OPERATION: grid->Laplacian(RN_X); break;
    case LAPLACIAN_Y_OPERATION: grid->Laplacian(RN_Y); break;
    case HARRIS_CORNER_FILTER_OPERATION: grid->HarrisCornerFilter(atoi(operation->operand1), atof(operation->operand2)); break;
    case HESSIAN_XX_OPERATION: grid->Hessian(RN_X, RN_X); break;
    case HESSIAN_XY_OPERATION: grid->Hessian(RN_X, RN_Y); break;
    case HESSIAN_YX_OPERATION: grid->Hessian(RN_Y, RN_X); break;
    case HESSIAN_YY_OPERATION: grid->Hessian(RN_Y, RN_Y); break;
    case SIGNED_DISTANCE_OPERATION: grid->SignedDistanceTransform(); break;
    case SQUARED_DISTANCE_OPERATION: grid->SquaredDistanceTransform(); break;
    case CLEAR_OPERATION: grid->Clear(atof(operation->operand1)); break;
    case ADD_OPERATION: grid->Add(atof(operation->operand1)); break;
    case SUBTRACT_OPERATION: grid->Subtract(atof(operation->operand1)); break;
    case MULTIPLY_OPERATION: grid->Multiply(atof(operation->operand1)); break;
    case DIVIDE_OPERATION: grid->Divide(atof(operation->operand1)); break;
    case POW_OPERATION: grid->Pow(atof(operation->operand1)); break;
    case BILATERAL_FILTER_OPERATION: grid->BilateralFilter(atof(operation->operand1), atof(operation->operand2)); break;
    case MAX_OPERATION: grid->MaxFilter(atof(operation->operand1)); break;
    case MIN_OPERATION: grid->MinFilter(atof(operation->operand1)); break;
    case MEDIAN_OPERATION: grid->MedianFilter(atof(operation->operand1)); break;
    case PERCENTILE_OPERATION: grid->PercentileFilter(atof(operation->operand1), atof(operation->operand2)); break;
    case MASK_NONMINIMA_OPERATION: grid->MaskNonMinima(atof(operation->operand1)); break;
    case MASK_NONMAXIMA_OPERATION: grid->MaskNonMaxima(atof(operation->operand1)); break;
    case FLATTEN_OPERATION: FlattenGrid(grid, atof(operation->operand1), atof(operation->operand2)); break;
    case CONNECTED_COMPONENT_SIZE_OPERATION: grid->ConnectedComponentSizeFilter(atof(operation->operand1)); break; 
    case CONNECTED_COMPONENT_LABEL_OPERATION: grid->ConnectedComponentLabelFilter(atof(operation->operand1)); break; 
    case DILATE_OPERATION: grid->Dilate(atof(operation->operand1)); break;
    case ERODE_OPERATION: grid->Erode(atof(operation->operand1)); break;
    case BLUR_OPERATION: grid->Blur(atof(operation->operand1)); break;
    case BLUR_X_OPERATION: grid->Blur(RN_X, atof(operation->operand1)); break;
    case BLUR_Y_OPERATION: grid->Blur(RN_Y, atof(operation->operand1)); break;
    case ADD_NOISE_OPERATION: grid->AddNoise(atof(operation->operand1)); break;
    case POINT_SYMMETRY_OPERATION: grid->PointSymmetryTransform(atoi(operation->operand1)); break;
    case CROP_OPERATION: *grid = R2Grid(*grid, atoi(operation->operand1), atoi(operation->operand2), atoi(operation->operand3), atoi(operation->operand4)); break;
    case RESAMPLE_OPERATION: grid->Resample(atoi(operation->operand1), atoi(operation->operand2)); break;
    case ADD_GRID_OPERATION: grid->Add(*grid1); break;
    case SUBTRACT_GRID_OPERATION: grid->Subtract(*grid1); break;
    case MULTIPLY_GRID_OPERATION: grid->Multiply(*grid1); break;
    case DIVIDE_GRID_OPERATION: grid->Divide(*grid1); break;
    case MASK_GRID_OPERATION: grid->Mask(*grid1); break;
    case OVERLAY_GRID_OPERATION: grid->Overlay(*grid1); break;
    case SUN3D_BITSHIFT_OPERATION: SUN3DBitshift(grid); break;
    case POISSON_OPERATION: Poisson(grid, grid1, grid2); break;
    case HASH_OPERATION: Hash(grid, atoi(operation->operand1)); break;
    case DU_OPERATION: DU(grid); break;
    case DV_OPERATION: DV(grid); break;
    case TMP_OPERATION: Tmp(grid); break;

    case REFINE_OPERATION: {
      RNScalar scale = atof(operation->operand1);
      int xres = (int) (scale * (grid->XResolution() - 1) + 1 + 0.5);
      int yres = (int) (scale * (grid->YResolution() - 1) + 1 + 0.5);
      grid->Resample(xres, yres);
      break; }

    case CONNECTED_COMPONENT_OPERATION: {
      RNScalar under_isolevel_value, too_small_value, too_large_value;
      if (!strcmp(operation->operand4, "keep")) under_isolevel_value = R2_GRID_KEEP_VALUE;
      else if (!strcmp(operation->operand4, "unknown")) under_isolevel_value = R2_GRID_UNKNOWN_VALUE;
      else under_isolevel_value = atof(operation->operand4);
      if (!strcmp(operation->operand5, "keep")) too_small_value = R2_GRID_KEEP_VALUE;
      else if (!strcmp(operation->operand5, "unknown")) too_small_value = R2_GRID_UNKNOWN_VALUE;
      else too_small_value = atof(operation->operand5);
      if (!strcmp(operation->operand6, "keep")) too_large_value = R2_GRID_KEEP_VALUE;
      else if (!strcmp(operation->operand5, "unknown")) too_large_value = R2_GRID_UNKNOWN_VALUE;
      else too_large_value = atof(operation->operand6);
      grid->ConnectedComponentFilter(atof(operation->operand1), atof(operation->operand2), atof(operation->operand3), under_isolevel_value, too_small_value, too_large_value);
      break; }

    case SUBSTITUTE_OPERATION: {
      RNScalar value1, value2;
      if (!strcmp(operation->operand1, "unknown")) value1 = R2_GRID_UNKNOWN_VALUE;
      else value1 = atof(operation->operand1);
      if (!strcmp(operation->operand2, "unknown")) value2 = R2_GRID_UNKNOWN_VALUE;
      else value2 = atof(operation->operand2);
      grid->Substitute(value1, value2); 
      break; }

    case THRESHOLD_OPERATION: 
    case THRESHOLD_GRID_OPERATION: {
      RNScalar value1, value2;
      if (!strcmp(operation->operand2, "keep")) value1 = R2_GRID_KEEP_VALUE;
      else if (!strcmp(operation->operand2, "input")) value1 = R2_GRID_INPUT_VALUE;
      else if (!strcmp(operation->operand2, "unknown")) value1 = R2_GRID_UNKNOWN_VALUE;
      else value1 = atof(operation->operand2);
      if (!strcmp(operation->operand3, "keep")) value2 = R2_GRID_KEEP_VALUE;
      else if (!strcmp(operation->operand3, "input")) value2 = R2_GRID_INPUT_VALUE;
      else if (!strcmp(operation->operand3, "unknown")) value2 = R2_GRID_UNKNOWN_VALUE;
      else value2 = atof(operation->operand3);
      if (operation->type == THRESHOLD_GRID_OPERATION) grid->Threshold(*grid1, value1, value2); 
      else grid->Threshold(atof(operation->operand1), value1, value2); 
      break; }

    default: 
      RNFail("Unknown operation type (%d) in operation %d\n", operation->type, i); 
      return 0; 
    }

    // Print debug message
    if (print_debug) {
      printf("Applied operation: %d %s %s %s %s %s %s\n", operation->type, 
             (operation->operand1) ? operation->operand1 : "-", 
             (operation->operand2) ? operation->operand2 : "-", 
             (operation->operand3) ? operation->operand3 : "-",
             (operation->operand4) ? operation->operand4 : "-",
             (operation->operand5) ? operation->operand5 : "-",
             (operation->operand6) ? operation->operand6 : "-");
      printf("  Cardinality = %d\n", grid->Cardinality());
      RNInterval grid_range = grid->Range();
      printf("  Minimum = %g\n", grid_range.Min());
      printf("  Maximum = %g\n", grid_range.Max());
      printf("  L1Norm = %g\n", grid->L1Norm());
      printf("  L2Norm = %g\n", grid->L2Norm());
      fflush(stdout);
    }
  }

  // Print statistics
  if (print_verbose) {
    printf("Applied operations ...\n");
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Operations = %d\n", noperations);
    printf("  Resolution = %d %d\n", grid->XResolution(), grid->YResolution());
    printf("  Spacing = %g\n", grid->GridToWorldScaleFactor());
    printf("  Cardinality = %d\n", grid->Cardinality());
    RNInterval grid_range = grid->Range();
    printf("  Minimum = %g\n", grid_range.Min());
    printf("  Maximum = %g\n", grid_range.Max());
    printf("  L1Norm = %g\n", grid->L1Norm());
    printf("  L2Norm = %g\n", grid->L2Norm());
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x378, %rsp            # imm = 0x378
movq %rdi, 0x368(%rsp)
movq %rsi, 0x360(%rsp)
movl %edx, 0x35c(%rsp)
leaq 0x348(%rsp), %rdi
callq 0x48d30
leaq 0x348(%rsp), %rdi
callq 0xb7f0
movl $0x0, 0x344(%rsp)
movl 0x344(%rsp), %eax
cmpl 0x35c(%rsp), %eax
jge 0xaabd
movq 0x360(%rsp), %rax
movslq 0x344(%rsp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x338(%rsp)
movq $0x0, 0x330(%rsp)
movq $0x0, 0x328(%rsp)
movq 0x338(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1dc(%rsp)
addl $-0x36, %eax
subl $0x7, %eax
jb 0x979a
jmp 0x9789
movl 0x1dc(%rsp), %eax
subl $0x3e, %eax
je 0x97f4
jmp 0x98a0
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x94e0
movq %rax, 0x330(%rsp)
cmpq $0x0, 0x330(%rsp)
jne 0x97ef
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x344(%rsp), %edx
leaq 0xa20c9(%rip), %rdi     # 0xab8a1
movb $0x0, %al
callq 0x4c7f0
movl $0x0, 0x374(%rsp)
jmp 0xac0d
jmp 0x98a0
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x94e0
movq %rax, 0x330(%rsp)
cmpq $0x0, 0x330(%rsp)
jne 0x9849
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rsi
movl 0x344(%rsp), %edx
leaq 0xa206f(%rip), %rdi     # 0xab8a1
movb $0x0, %al
callq 0x4c7f0
movl $0x0, 0x374(%rsp)
jmp 0xac0d
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x94e0
movq %rax, 0x328(%rsp)
cmpq $0x0, 0x328(%rsp)
jne 0x989e
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rsi
movl 0x344(%rsp), %edx
leaq 0xa201a(%rip), %rdi     # 0xab8a1
movb $0x0, %al
callq 0x4c7f0
movl $0x0, 0x374(%rsp)
jmp 0xac0d
jmp 0x98a0
movq 0x338(%rsp), %rax
movl (%rax), %eax
movq %rax, 0x1d0(%rsp)
subq $0x42, %rax
ja 0xa823
movq 0x1d0(%rsp), %rax
leaq 0xa1795(%rip), %rcx     # 0xab060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe4c0
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe600
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe560
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe690
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe740
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe920
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xb8b0
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xb8c0
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xe9b0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movq 0x1c8(%rsp), %rdi
movl %eax, %esi
callq 0xf640
jmp 0xa852
movq 0x368(%rsp), %rdi
xorl %esi, %esi
callq 0x13230
jmp 0xa852
movq 0x368(%rsp), %rdi
movl $0x1, %esi
callq 0x13230
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x13600
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x133c0
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x13820
jmp 0xa852
movq 0x368(%rsp), %rdi
xorl %esi, %esi
callq 0x13860
jmp 0xa852
movq 0x368(%rsp), %rdi
movl $0x1, %esi
callq 0x13860
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movl %eax, 0x1c4(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movq 0x1b8(%rsp), %rdi
movl 0x1c4(%rsp), %esi
callq 0x13c30
jmp 0xa852
movq 0x368(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x13380
jmp 0xa852
movq 0x368(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x13380
jmp 0xa852
movq 0x368(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x13380
jmp 0xa852
movq 0x368(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x13380
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x14c20
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0xfbf0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x1b0(%rsp), %rdi
callq 0xfa70
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x1a8(%rsp), %rdi
callq 0x14220
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x1a0(%rsp), %rdi
callq 0x143a0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x198(%rsp), %rdi
callq 0x144d0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x190(%rsp), %rdi
callq 0xe950
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x188(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x188(%rsp), %rdi
callq 0x14810
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x178(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x180(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movq 0x178(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x180(%rsp), %xmm0
xorl %esi, %esi
callq 0x11640
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x170(%rsp), %rdi
callq 0xb8e0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x168(%rsp), %rdi
callq 0xb910
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x160(%rsp), %rdi
callq 0xb940
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x158(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movq 0x150(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x158(%rsp), %xmm0
callq 0x11c80
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x148(%rsp), %rdi
callq 0x12170
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x140(%rsp), %rdi
callq 0x12a80
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x138(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movq 0x130(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x138(%rsp), %xmm0
callq 0x5620
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x128(%rsp), %rdi
callq 0x1aea0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x120(%rsp), %rdi
callq 0x1a200
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x118(%rsp), %rdi
callq 0xfaf0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x110(%rsp), %rdi
callq 0x103e0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x108(%rsp), %rdi
callq 0x10b10
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x100(%rsp), %rdi
xorl %esi, %esi
callq 0x10500
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0xf8(%rsp), %rdi
movl $0x1, %esi
callq 0x10500
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0xf0(%rsp), %rdi
callq 0x114d0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movq 0xe8(%rsp), %rdi
movl %eax, %esi
callq 0x15770
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movl %eax, 0xd4(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4430
movl %eax, 0xd8(%rsp)
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x4430
movl %eax, 0xdc(%rsp)
movq 0x338(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x4430
movq 0xc8(%rsp), %rsi
movl 0xd4(%rsp), %edx
movl 0xd8(%rsp), %ecx
movl 0xdc(%rsp), %r8d
movl %eax, %r9d
leaq 0x258(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0xc7a0
movq 0xe0(%rsp), %rsi
movq 0x368(%rsp), %rdi
callq 0xcf70
jmp 0xa0db
leaq 0x258(%rsp), %rdi
callq 0xd3e0
jmp 0xa852
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x250(%rsp)
movl %eax, 0x24c(%rsp)
leaq 0x258(%rsp), %rdi
callq 0xd3e0
jmp 0xac1c
movq 0x368(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movl %eax, 0xc4(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4430
movq 0xb8(%rsp), %rdi
movl 0xc4(%rsp), %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x15e50
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x142b0
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x143e0
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x14560
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x14650
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x148b0
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0x14980
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x6680
jmp 0xa852
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
movq 0x328(%rsp), %rdx
callq 0x5ca0
jmp 0xa852
movq 0x368(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4430
movq 0xb0(%rsp), %rdi
movl %eax, %esi
callq 0x6720
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x68a0
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x6a90
jmp 0xa852
movq 0x368(%rsp), %rdi
callq 0x6c80
jmp 0xa852
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x240(%rsp)
movsd 0x240(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movq 0x368(%rsp), %rdi
callq 0xaed0
movsd 0xa0(%rsp), %xmm0
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd 0xa0d27(%rip), %xmm1    # 0xab020
addsd %xmm1, %xmm0
movsd 0xa0d3b(%rip), %xmm1    # 0xab040
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x23c(%rsp)
movsd 0x240(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x368(%rsp), %rdi
callq 0xaef0
movsd 0xa8(%rsp), %xmm0
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd 0xa0cd1(%rip), %xmm1    # 0xab020
addsd %xmm1, %xmm0
movsd 0xa0ce5(%rip), %xmm1    # 0xab040
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x238(%rsp)
movq 0x368(%rsp), %rdi
movl 0x23c(%rsp), %esi
movl 0x238(%rsp), %edx
xorl %ecx, %ecx
callq 0x15e50
jmp 0xa852
movq 0x338(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0xa1532(%rip), %rsi     # 0xab8d1
callq 0x43c0
cmpl $0x0, %eax
jne 0xa3bc
movsd 0xa0c97(%rip), %xmm0    # 0xab048
movsd %xmm0, 0x230(%rsp)
jmp 0xa408
movq 0x338(%rsp), %rax
movq 0x20(%rax), %rdi
leaq 0xa1507(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa3ec
movsd 0xa0c27(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x230(%rsp)
jmp 0xa406
movq 0x338(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x230(%rsp)
jmp 0xa408
movq 0x338(%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0xa14b6(%rip), %rsi     # 0xab8d1
callq 0x43c0
cmpl $0x0, %eax
jne 0xa438
movsd 0xa0c1b(%rip), %xmm0    # 0xab048
movsd %xmm0, 0x228(%rsp)
jmp 0xa484
movq 0x338(%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0xa148b(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa468
movsd 0xa0bab(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x228(%rsp)
jmp 0xa482
movq 0x338(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x228(%rsp)
jmp 0xa484
movq 0x338(%rsp), %rax
movq 0x30(%rax), %rdi
leaq 0xa143a(%rip), %rsi     # 0xab8d1
callq 0x43c0
cmpl $0x0, %eax
jne 0xa4b4
movsd 0xa0b9f(%rip), %xmm0    # 0xab048
movsd %xmm0, 0x220(%rsp)
jmp 0xa500
movq 0x338(%rsp), %rax
movq 0x28(%rax), %rdi
leaq 0xa140f(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa4e4
movsd 0xa0b2f(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x220(%rsp)
jmp 0xa4fe
movq 0x338(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x220(%rsp)
jmp 0xa500
movq 0x368(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x98(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x90(%rsp)
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x4330
movq 0x88(%rsp), %rdi
movsd 0x90(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x98(%rsp), %xmm0
movsd 0x230(%rsp), %xmm3
movsd 0x228(%rsp), %xmm4
movsd 0x220(%rsp), %xmm5
callq 0x1b780
jmp 0xa852
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0xa132c(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa5c7
movsd 0xa0a4c(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x218(%rsp)
jmp 0xa5e1
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x218(%rsp)
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa12e2(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa611
movsd 0xa0a02(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x210(%rsp)
jmp 0xa62b
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x210(%rsp)
movq 0x368(%rsp), %rdi
movsd 0x218(%rsp), %xmm0
movsd 0x210(%rsp), %xmm1
callq 0x141a0
jmp 0xa852
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa126f(%rip), %rsi     # 0xab8d1
callq 0x43c0
cmpl $0x0, %eax
jne 0xa67f
movsd 0xa09d4(%rip), %xmm0    # 0xab048
movsd %xmm0, 0x208(%rsp)
jmp 0xa6fd
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa124c(%rip), %rsi     # 0xab8de
callq 0x43c0
cmpl $0x0, %eax
jne 0xa6af
movsd 0xa09ac(%rip), %xmm0    # 0xab050
movsd %xmm0, 0x208(%rsp)
jmp 0xa6fb
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa1214(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa6df
movsd 0xa0934(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x208(%rsp)
jmp 0xa6f9
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x208(%rsp)
jmp 0xa6fb
jmp 0xa6fd
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0xa11c1(%rip), %rsi     # 0xab8d1
callq 0x43c0
cmpl $0x0, %eax
jne 0xa72d
movsd 0xa0926(%rip), %xmm0    # 0xab048
movsd %xmm0, 0x200(%rsp)
jmp 0xa7ab
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0xa119e(%rip), %rsi     # 0xab8de
callq 0x43c0
cmpl $0x0, %eax
jne 0xa75d
movsd 0xa08fe(%rip), %xmm0    # 0xab050
movsd %xmm0, 0x200(%rsp)
jmp 0xa7a9
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0xa1166(%rip), %rsi     # 0xab8d6
callq 0x43c0
cmpl $0x0, %eax
jne 0xa78d
movsd 0xa0886(%rip), %xmm0    # 0xab008
movsd %xmm0, 0x200(%rsp)
jmp 0xa7a7
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x4330
movsd %xmm0, 0x200(%rsp)
jmp 0xa7a9
jmp 0xa7ab
movq 0x338(%rsp), %rax
cmpl $0x3c, (%rax)
jne 0xa7e1
movq 0x368(%rsp), %rdi
movq 0x330(%rsp), %rsi
movsd 0x208(%rsp), %xmm0
movsd 0x200(%rsp), %xmm1
callq 0x14a40
jmp 0xa821
movq 0x368(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x4330
movq 0x80(%rsp), %rdi
movsd 0x208(%rsp), %xmm1
movsd 0x200(%rsp), %xmm2
callq 0x102d0
jmp 0xa852
movq 0x338(%rsp), %rax
movl (%rax), %esi
movl 0x344(%rsp), %edx
leaq 0xa10a9(%rip), %rdi     # 0xab8e4
movb $0x0, %al
callq 0x4c7f0
movl $0x0, 0x374(%rsp)
jmp 0xac0d
cmpl $0x0, 0xc110b(%rip)     # 0xcb964
je 0xaaa5
movq 0x338(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x7c(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa88f
movq 0x338(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x70(%rsp)
jmp 0xa89d
leaq 0xa10a4(%rip), %rax     # 0xab93a
movq %rax, 0x70(%rsp)
jmp 0xa89d
movq 0x70(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0xa8c9
movq 0x338(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x60(%rsp)
jmp 0xa8d7
leaq 0xa106a(%rip), %rax     # 0xab93a
movq %rax, 0x60(%rsp)
jmp 0xa8d7
movq 0x60(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0xa903
movq 0x338(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0xa911
leaq 0xa1030(%rip), %rax     # 0xab93a
movq %rax, 0x50(%rsp)
jmp 0xa911
movq 0x50(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0xa93d
movq 0x338(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0xa94b
leaq 0xa0ff6(%rip), %rax     # 0xab93a
movq %rax, 0x40(%rsp)
jmp 0xa94b
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0xa977
movq 0x338(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0xa985
leaq 0xa0fbc(%rip), %rax     # 0xab93a
movq %rax, 0x30(%rsp)
jmp 0xa985
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x338(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0xa9b1
movq 0x338(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0xa9bf
leaq 0xa0f82(%rip), %rax     # 0xab93a
movq %rax, 0x20(%rsp)
jmp 0xa9bf
movq 0x28(%rsp), %r10
movq 0x38(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x58(%rsp), %rcx
movq 0x68(%rsp), %rdx
movl 0x7c(%rsp), %esi
movq 0x20(%rsp), %rax
leaq 0xa0f29(%rip), %rdi     # 0xab911
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd830
movl %eax, %esi
leaq 0xa0e41(%rip), %rdi     # 0xab84f
movb $0x0, %al
callq 0x4050
movq 0x368(%rsp), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xd440
leaq 0x1f0(%rsp), %rdi
callq 0xb600
leaq 0xa0e25(%rip), %rdi     # 0xab863
movb $0x1, %al
callq 0x4050
leaq 0x1f0(%rsp), %rdi
callq 0xb8a0
leaq 0xa0e1a(%rip), %rdi     # 0xab873
movb $0x1, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd6d0
leaq 0xa0e0f(%rip), %rdi     # 0xab883
movb $0x1, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd770
leaq 0xa0e03(%rip), %rdi     # 0xab892
movb $0x1, %al
callq 0x4050
movq 0xbf513(%rip), %rax     # 0xc9fb0
movq (%rax), %rdi
callq 0x42e0
jmp 0xaaa7
movl 0x344(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x344(%rsp)
jmp 0x9723
cmpl $0x0, 0xc0e9c(%rip)     # 0xcb960
je 0xac02
leaq 0xa0e6b(%rip), %rdi     # 0xab93c
movb $0x0, %al
callq 0x4050
leaq 0x348(%rsp), %rdi
callq 0x48df0
leaq 0xa0d26(%rip), %rdi     # 0xab812
movb $0x1, %al
callq 0x4050
movl 0x35c(%rsp), %esi
leaq 0xa0e53(%rip), %rdi     # 0xab954
movb $0x0, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xaed0
movl %eax, 0x1c(%rsp)
movq 0x368(%rsp), %rdi
callq 0xaef0
movl 0x1c(%rsp), %esi
movl %eax, %edx
leaq 0xa0cf6(%rip), %rdi     # 0xab829
movb $0x0, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xb840
leaq 0xa0cf1(%rip), %rdi     # 0xab83f
movb $0x1, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd830
movl %eax, %esi
leaq 0xa0ce4(%rip), %rdi     # 0xab84f
movb $0x0, %al
callq 0x4050
movq 0x368(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xd440
leaq 0x1e0(%rsp), %rdi
callq 0xb600
leaq 0xa0cc8(%rip), %rdi     # 0xab863
movb $0x1, %al
callq 0x4050
leaq 0x1e0(%rsp), %rdi
callq 0xb8a0
leaq 0xa0cbd(%rip), %rdi     # 0xab873
movb $0x1, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd6d0
leaq 0xa0cb2(%rip), %rdi     # 0xab883
movb $0x1, %al
callq 0x4050
movq 0x368(%rsp), %rdi
callq 0xd770
leaq 0xa0ca6(%rip), %rdi     # 0xab892
movb $0x1, %al
callq 0x4050
movq 0xbf3b6(%rip), %rax     # 0xc9fb0
movq (%rax), %rdi
callq 0x42e0
movl $0x1, 0x374(%rsp)
movl 0x374(%rsp), %eax
addq $0x378, %rsp            # imm = 0x378
retq
movq 0x250(%rsp), %rdi
callq 0x44b0
nopl (%rax)