// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::ReadGSVStreamFromOldVersion(_IO_FILE*, int)
int GSVScene::
ReadGSVStreamFromOldVersion(FILE *fp, RNBoolean read_points)
{
  // Convenient variables
  int dummy = 0;

  // Read magic keyword
  char magic[16] = { '\0' };
  if (fread(magic, sizeof(char), 16, fp) != (unsigned int) 16) {
    RNFail("Unable to read first bytes from GSV scene file\n");
    fclose(fp);
    return 0;
  }

  // Check magic keyword
  if (strcmp(magic, "GSV")) {
    RNFail("Invalid file format for GSV scene file\n");
    fclose(fp);
    return 0;
  }

  // Read header
  int endian_test;
  int major_version;
  int minor_version;
  unsigned long long scene_file_offset = 0;
  fread(&dummy, sizeof(int), 1, fp);
  fread(&dummy, sizeof(int), 1, fp);
  fread(&scene_file_offset, sizeof(unsigned long long), 1, fp);
  fread(&endian_test, sizeof(int), 1, fp);
  fread(&major_version, sizeof(int), 1, fp);
  fread(&minor_version, sizeof(int), 1, fp);
  if ((major_version != 0) || (minor_version != 1)) {
    for (int j = 0; j < 53; j++) {
      fread(&dummy, sizeof(int), 1, fp);
    }
  }

  // Seek to beginning of scene stuff
  assert(((major_version != 0) || (minor_version != 1)) || (scene_file_offset == 0));
  assert(((major_version == 0) && (minor_version == 1)) || (scene_file_offset > 0));
  unsigned long long point_file_offset = RNFileTell(fp);
  if (scene_file_offset > 0) {
    if (!RNFileSeek(fp, scene_file_offset, RN_FILE_SEEK_SET)) {
      RNFail("Unable to seek to scene file offset\n");
      fclose(fp);
      return 0;
    }
  }

  // Read scene stuff
  int scene_nruns;
  R3Box scene_bbox;
  fread(&scene_nruns, sizeof(int), 1, fp);
  fread(&(scene_bbox[0][0]), sizeof(RNCoord), 6, fp);
  for (int j = 0; j < 121; j++) {
    fread(&dummy, sizeof(int), 1, fp);
  }
  
  // Read runs
  for (int ir = 0; ir < scene_nruns; ir++) {
    // Create run
    GSVRun *run = new GSVRun();

    // Read run stuff
    int run_ncameras;
    int run_nlasers;
    int run_nsegments;
    R3Box run_bbox;
    char run_name[256];
    fread(run_name, sizeof(char), 256, fp);
    fread(&run_ncameras, sizeof(int), 1, fp);
    fread(&run_nlasers, sizeof(int), 1, fp);
    fread(&run_nsegments, sizeof(int), 1, fp);
    fread(&(run_bbox[0][0]), sizeof(RNCoord), 6, fp);
    for (int j = 0; j < 23; j++) {
      fread(&dummy, sizeof(int), 1, fp);
    }

    // Read cameras
    for (int ic = 0; ic < run_ncameras; ic++) {
      GSVCamera *camera = new GSVCamera();

      // Read camera stuff
      int camera_ntapestries;
      int camera_distortion_type;
      RNLength camera_focal_x;
      RNLength camera_focal_y;
      RNCoord camera_center_x;
      RNCoord camera_center_y;
      RNScalar camera_k1;
      RNScalar camera_k2;
      RNScalar camera_k3;
      RNScalar camera_p1;
      RNScalar camera_p2;
      RNAngle camera_fov_max;
      R3Box camera_bbox;
      fread(&camera_ntapestries, sizeof(int), 1, fp);
      fread(&camera_distortion_type, sizeof(int), 1, fp);
      fread(&camera_focal_x, sizeof(RNLength), 1, fp);
      fread(&camera_focal_y, sizeof(RNLength), 1, fp);
      fread(&camera_center_x, sizeof(RNCoord), 1, fp);
      fread(&camera_center_y, sizeof(RNCoord), 1, fp);
      fread(&camera_k1, sizeof(RNScalar), 1, fp);
      fread(&camera_k2, sizeof(RNScalar), 1, fp);
      fread(&camera_k3, sizeof(RNScalar), 1, fp);
      fread(&camera_p1, sizeof(RNScalar), 1, fp);
      fread(&camera_p2, sizeof(RNScalar), 1, fp);
      fread(&camera_fov_max, sizeof(RNAngle), 1, fp);
      fread(&(camera_bbox[0][0]), sizeof(RNCoord), 6, fp);
      for (int j = 0; j < 15; j++) {
        fread(&dummy, sizeof(int), 1, fp);
      }

      // Set camera stuff
      camera->SetDistortionType(camera_distortion_type);
      camera->SetXFocal(camera_focal_x);
      camera->SetYFocal(camera_focal_y);
      camera->SetXCenter(camera_center_x);
      camera->SetYCenter(camera_center_y);
      camera->SetK1(camera_k1);
      camera->SetK2(camera_k2);
      camera->SetK3(camera_k3);
      camera->SetP1(camera_p1);
      camera->SetP2(camera_p2);
      camera->SetMaxFov(camera_fov_max);
      camera->SetBBox(camera_bbox);
      run->InsertCamera(camera);
    }

    // Read lasers
    for (int il = 0; il < run_nlasers; il++) {
      GSVLaser *laser = new GSVLaser();

      // Read laser stuff
      int laser_nscans;
      R3Box laser_bbox;
      fread(&laser_nscans, sizeof(int), 1, fp);
      fread(&(laser_bbox[0][0]), sizeof(RNCoord), 6, fp);
      for (int j = 0; j < 25; j++) {
        fread(&dummy, sizeof(int), 1, fp);
      }

      // Set laser stuff
      laser->SetBBox(laser_bbox);
      run->InsertLaser(laser);
    }

    // Read segments
    for (int is = 0; is < run_nsegments; is++) {
      GSVSegment *segment = new GSVSegment();

      // Read segment stuff
      int segment_nscans;
      int segment_ntapestries;
      int segment_npanoramas;
      R3Box segment_bbox;
      fread(&segment_nscans, sizeof(int), 1, fp);
      fread(&segment_ntapestries, sizeof(int), 1, fp);
      fread(&segment_npanoramas, sizeof(int), 1, fp);
      fread(&(segment_bbox[0][0]), sizeof(RNCoord), 6, fp);
      for (int j = 0; j < 23; j++) {
        fread(&dummy, sizeof(int), 1, fp);
      }

      // Read scans
      for (int ia = 0; ia < segment_nscans; ia++) {
        GSVScan *scan = new GSVScan();

        // Read scan stuff
        int scan_laser_index;
        int scan_nscanlines;
        R3Box scan_bbox;
        fread(&scan_laser_index, sizeof(int), 1, fp);
        fread(&scan_nscanlines, sizeof(int), 1, fp);
        fread(&(scan_bbox[0][0]), sizeof(RNCoord), 6, fp);
        for (int j = 0; j < 24; j++) {
          fread(&dummy, sizeof(int), 1, fp);
        }

        // Read scanlines
        for (int ie = 0; ie < scan_nscanlines; ie++) {
          GSVScanline *scanline = new GSVScanline();

          // Read scanline stuff
          int scanline_npoints;
          R3Point scanline_viewpoint;
          R3Quaternion scanline_orientation;
          RNScalar scanline_timestamp;
          R3Box scanline_bbox;
          unsigned long long scanline_file_offset;
          fread(&(scanline_npoints), sizeof(int), 1, fp);
          fread(&(scanline_viewpoint[0]), sizeof(RNCoord), 3, fp);
          fread(&(scanline_orientation[0]), sizeof(RNCoord), 4, fp);
          fread(&scanline_timestamp, sizeof(RNScalar), 1, fp);
          fread(&(scanline_bbox[0][0]), sizeof(RNCoord), 6, fp);
          fread(&(scanline_file_offset), sizeof(unsigned long long), 1, fp);
          for (int j = 0; j < 15; j++) {
            fread(&dummy, sizeof(int), 1, fp);
          }

          // Read points
          if ((major_version == 0) && (minor_version == 1)) {
            ReadScanlinePointsFromOldVersion(fp, scanline);
          }

          // Set scanline stuff
          GSVPose scanline_pose(scanline_viewpoint, scanline_orientation);
          scanline->SetPose(scanline_pose);
          scanline->SetTimestamp(scanline_timestamp);
          scanline->SetBBox(scanline_bbox);
          scanline->SetNPoints(scanline_npoints);
          scanline->SetFileOffset(scanline_file_offset);
          scan->InsertScanline(scanline);
        }

        // Set scan stuff
        scan->SetBBox(scan_bbox);

        // Create survey
        GSVSurvey *survey = new GSVSurvey();
        survey->InsertScan(scan);
        segment->InsertSurvey(survey);
        
        // Insert survey into laser
        if (scan_laser_index >= 0) {
          GSVLaser *scan_laser = run->Laser(scan_laser_index);
          scan_laser->InsertSurvey(survey);
        }
      }

      // Read tapestries
      for (int it = 0; it < segment_ntapestries; it++) {
        GSVTapestry *tapestry = new GSVTapestry();

        // Read tapestry stuff
        int tapestry_camera_index;
        int tapestry_nimages;
        R3Box tapestry_bbox;
        fread(&tapestry_camera_index, sizeof(int), 1, fp);
        fread(&tapestry_nimages, sizeof(int), 1, fp);
        fread(&(tapestry_bbox[0][0]), sizeof(RNCoord), 6, fp);
        for (int j = 0; j < 24; j++) {
          fread(&dummy, sizeof(int), 1, fp);
        }

        // Set tapestry stuff
        tapestry->SetBBox(tapestry_bbox);
        segment->InsertTapestry(tapestry);
        if (tapestry_camera_index >= 0) {
          GSVCamera *camera = run->Camera(tapestry_camera_index);
          camera->InsertTapestry(tapestry);
        }
      }

      // Read panoramas
      for (int ip = 0; ip < segment_npanoramas; ip++) {
        GSVPanorama *panorama = new GSVPanorama();

        // Read panorama stuff
        int panorama_nimages;
        R3Point panorama_viewpoint;
        RNScalar panorama_timestamp;
        fread(&panorama_nimages, sizeof(int), 1, fp);
        fread(&(panorama_viewpoint[0]), sizeof(RNCoord), 3, fp);
        fread(&panorama_timestamp, sizeof(RNScalar), 1, fp);
        for (int j = 0; j < 22; j++) {
          fread(&dummy, sizeof(int), 1, fp);
        }

        // Read images
        for (int ii = 0; ii < panorama_nimages; ii++) {
          GSVImage *image = new GSVImage();

          // Read image stuff
          int image_tapestry_index, image_ncolumns;
          R3Point image_viewpoint0, image_viewpoint1;
          R3Quaternion image_orientation0, image_orientation1;
          RNScalar image_timestamp0, image_timestamp1;
          fread(&image_tapestry_index, sizeof(int), 1, fp);
          fread(&image_ncolumns, sizeof(int), 1, fp);
          fread(&(image_viewpoint0[0]), sizeof(RNCoord), 3, fp);
          fread(&(image_viewpoint1[0]), sizeof(RNCoord), 3, fp);
          fread(&(image_orientation0[0]), sizeof(RNCoord), 4, fp);
          fread(&(image_orientation1[0]), sizeof(RNCoord), 4, fp);
          fread(&image_timestamp0, sizeof(RNScalar), 1, fp);
          fread(&image_timestamp1, sizeof(RNScalar), 1, fp);
          for (int j = 0; j < 14; j++) {
            fread(&dummy, sizeof(int), 1, fp);
          }

          // Set image stuff
          GSVPose image_pose0(image_viewpoint0, image_orientation0);
          GSVPose image_pose1(image_viewpoint1, image_orientation1);
          image->SetPose(image_pose0, image_pose1);
          image->SetTimestamp(image_timestamp0, image_timestamp1);
          panorama->InsertImage(image);

          // Insert image into tapestry
          if (image_tapestry_index >= 0) {
            GSVTapestry *tapestry = segment->Tapestry(image_tapestry_index);
            tapestry->InsertImage(image);
          }
        }

        // Set panorama stuff
        panorama->SetViewpoint(panorama_viewpoint);
        panorama->SetTimestamp(panorama_timestamp);
        segment->InsertPanorama(panorama);
      }

      // Set segment stuff
      segment->SetBBox(segment_bbox);
      run->InsertSegment(segment);
    }

    // Set run stuff
    run->SetName(run_name);
    run->SetBBox(run_bbox);
    InsertRun(run);
  }

  // Get end of file offset
  unsigned long long end_of_file_offset = RNFileTell(fp);

  // Read points
  if (read_points) {
    if ((major_version == 0) && (minor_version == 2)) {
      if (!RNFileSeek(fp, point_file_offset, RN_FILE_SEEK_SET)) {
        RNFail("Unable to seek to point file offset\n");
        fclose(fp);
        return 0;
      }
      for (int ir = 0; ir < NRuns(); ir++) {
        GSVRun *run = Run(ir);
        for (int is = 0; is < run->NSegments(); is++) {
          GSVSegment *segment = run->Segment(is);
          for (int ia = 0; ia < segment->NScans(); ia++) {
            GSVScan *scan = segment->Scan(ia);
            for (int ie = 0; ie < scan->NScanlines(); ie++) {
              GSVScanline *scanline = scan->Scanline(ie);
              ReadScanlinePointsFromOldVersion(fp, scanline);
            }
          }
        }
      }
    }
  }

  // Seek to end of file
  RNFileSeek(fp, end_of_file_offset, RN_FILE_SEEK_SET);

  // Set scene stuff
  // SetBBox(scene_bbox);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movl %edx, 0x64(%rsp)
movq %rsi, %rbx
andl $0x0, (%rsp)
movq %rdi, 0x90(%rsp)
xorps %xmm0, %xmm0
leaq 0x1e0(%rsp), %rdi
movaps %xmm0, (%rdi)
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
cmpq $0x10, %rax
jne 0x32814
cmpl $0x565347, 0x1e0(%rsp) # imm = 0x565347
jne 0x3281d
leaq 0x150(%rsp), %r12
andq $0x0, (%r12)
movq %rsp, %r13
pushq $0x4
popq %r14
pushq $0x1
popq %r15
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x8
popq %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x164(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x160(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x15c(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
movl (%r12), %eax
movl (%r13), %r13d
movl %r13d, 0x60(%rsp)
xorl $0x1, %r13d
movl %eax, 0x58(%rsp)
orl %r13d, %eax
je 0x32849
pushq $0x35
popq %rbp
movq %rsp, %r14
pushq $0x4
popq %r15
pushq $0x1
popq %r12
subl $0x1, %ebp
jb 0x32849
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x327fc
leaq 0xf93a6(%rip), %rdi     # 0x12bbc1
jmp 0x32824
leaq 0xf93cd(%rip), %rdi     # 0x12bbf1
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xe434a
movq %rbx, %rdi
callq 0x27930
movl %ebp, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0xe3997
movq %rax, 0x120(%rsp)
movq 0x150(%rsp), %rsi
testq %rsi, %rsi
je 0x3287a
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe3986
testl %eax, %eax
je 0x3348d
leaq 0x268(%rsp), %rdi
callq 0xac95e
leaq 0x8c(%rsp), %rdi
pushq $0x4
popq %r14
pushq $0x1
popq %r15
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x270(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x79
popq %rbp
movq %rsp, %r12
subl $0x1, %ebp
jb 0x328d9
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x328c1
movl 0x8c(%rsp), %ebp
orl 0x58(%rsp), %r13d
sete 0x7(%rsp)
xorl %eax, %eax
pushq $0x1
popq %r13
pushq $0x4
popq %r15
movl %ebp, 0x20(%rsp)
movq %rax, 0x128(%rsp)
cmpl %ebp, %eax
jge 0x33499
movl $0x90, %edi
callq 0x27940
movq %rax, 0x10(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x35f68
leaq 0x230(%rsp), %rdi
callq 0xac95e
movl $0x100, %edx            # imm = 0x100
leaq 0x2a0(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rcx
callq 0x27ee0
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x84(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x238(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x17
popq %rbp
subl $0x1, %ebp
jb 0x329b9
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x329a1
movl 0x88(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
cmpl 0x18(%rsp), %ecx
movl 0x20(%rsp), %ebp
je 0x32c18
movl $0xc8, %edi
callq 0x27940
movq %rax, %r14
movq %rax, %rdi
callq 0x3955c
leaq 0x98(%rsp), %rdi
callq 0xac95e
leaq 0x5c(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x2c(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x168(%rsp), %rdi
pushq $0x8
popq %rbp
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x1f8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x1a8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x130(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x108(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xf0(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xd8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xa0(%rsp), %rdi
movq %rbp, %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0xf
popq %rbp
subl $0x1, %ebp
jb 0x32b2c
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x32b14
movl 0x2c(%rsp), %esi
movq %r14, %rdi
callq 0x397b2
movq 0x10(%rsp), %rbp
movsd 0x168(%rsp), %xmm0
movq %r14, %rdi
callq 0x397be
movsd 0x1f8(%rsp), %xmm0
movq %r14, %rdi
callq 0x397c4
movsd 0x1a8(%rsp), %xmm0
movq %r14, %rdi
callq 0x397ca
movsd 0x130(%rsp), %xmm0
movq %r14, %rdi
callq 0x397d0
movsd 0x108(%rsp), %xmm0
movq %r14, %rdi
callq 0x397d6
movsd 0xf0(%rsp), %xmm0
movq %r14, %rdi
callq 0x397dc
movsd 0xd8(%rsp), %xmm0
movq %r14, %rdi
callq 0x397e2
movsd 0x50(%rsp), %xmm0
movq %r14, %rdi
callq 0x397e8
movsd 0x48(%rsp), %xmm0
movq %r14, %rdi
callq 0x397ee
movsd 0x40(%rsp), %xmm0
movq %r14, %rdi
callq 0x397f4
movq %r14, %rdi
addq $0x88, %rdi
leaq 0x98(%rsp), %rsi
callq 0x30d44
movq %rbp, %rdi
movq %r14, %rsi
callq 0x36364
leaq 0x98(%rsp), %rdi
callq 0xad65a
movl 0x8(%rsp), %ecx
incl %ecx
jmp 0x329cb
movl 0x84(%rsp), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movl %ecx, 0x8(%rsp)
cmpl 0x8(%rsp), %eax
je 0x32cdc
movl %eax, %r12d
pushq $0x78
popq %rdi
callq 0x27940
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x3c210
leaq 0x98(%rsp), %rdi
callq 0xac95e
leaq 0x168(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xa0(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x19
popq %rbp
subl $0x1, %ebp
jb 0x32ca0
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x32c88
movq %r14, %rdi
addq $0x38, %rdi
leaq 0x98(%rsp), %rsi
callq 0x30d44
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x363c8
leaq 0x98(%rsp), %rdi
callq 0xad65a
movl %r12d, %eax
incl %eax
movl 0x20(%rsp), %ebp
jmp 0x32c2a
xorl %eax, %eax
movl 0x80(%rsp), %ecx
movl %ecx, 0x68(%rsp)
movl %eax, 0x6c(%rsp)
cmpl 0x68(%rsp), %eax
jge 0x33438
movl $0x98, %edi
callq 0x27940
movq %rax, 0x30(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x37710
leaq 0x1f8(%rsp), %rdi
callq 0xac95e
leaq 0x5c(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x2c(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x7c(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x200(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x17
popq %rbp
subl $0x1, %ebp
jb 0x32d87
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x32d6f
movl 0x5c(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x28(%rsp)
movl %ecx, 0x38(%rsp)
cmpl 0x28(%rsp), %ecx
movl 0x20(%rsp), %ebp
je 0x3303d
pushq $0x78
popq %rdi
callq 0x27940
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x3ccdc
leaq 0x168(%rsp), %rdi
callq 0xac95e
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x170(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x18
popq %rbp
subl $0x1, %ebp
jb 0x32e21
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x32e09
movl 0x48(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x18(%rsp)
cmpl 0x18(%rsp), %ecx
je 0x32fc1
movl %ecx, %r12d
movl $0xc8, %edi
callq 0x27940
movq %rax, %rbp
movq %rax, %rdi
callq 0x3ddd8
leaq 0x108(%rsp), %rdi
callq 0xc0dfa
leaq 0x130(%rsp), %rdi
callq 0xb0522
leaq 0x1a8(%rsp), %rdi
callq 0xac95e
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x108(%rsp), %rdi
pushq $0x8
popq %r14
movq %r14, %rsi
pushq $0x3
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xf0(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x1b0(%rsp), %rdi
movq %r14, %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0xf
popq %r14
subl $0x1, %r14d
jb 0x32f1b
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x32f02
cmpb $0x0, 0x7(%rsp)
je 0x32f2d
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x35c72
leaq 0x98(%rsp), %r14
movq %r14, %rdi
leaq 0x108(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x41d1e
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3e4a6
movsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x78(%rbp)
movq %rbp, %rdi
addq $0x88, %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x30d44
movl 0x40(%rsp), %eax
movl %eax, 0x30(%rbp)
movq 0xd8(%rsp), %rax
movq %rax, 0x18(%rbp)
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x3d726
leaq 0x98(%rsp), %rdi
callq 0x41e6a
leaq 0x1a8(%rsp), %rdi
callq 0xad65a
movl %r12d, %ecx
incl %ecx
jmp 0x32e30
movq 0x8(%rsp), %rdi
addq $0x38, %rdi
leaq 0x168(%rsp), %rsi
callq 0x30d44
movl $0x80, %edi
callq 0x27940
movq %rax, %rbp
movq %rax, %rdi
callq 0x3c590
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x3c966
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x37e76
movslq 0x50(%rsp), %rax
testq %rax, %rax
js 0x33025
movq 0x10(%rsp), %rcx
movq 0x38(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
movq %rbp, %rsi
callq 0x3c3a8
leaq 0x168(%rsp), %rdi
callq 0xad65a
movl 0x38(%rsp), %ecx
incl %ecx
jmp 0x32d96
movl 0x2c(%rsp), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movl %ecx, 0x8(%rsp)
cmpl 0x8(%rsp), %eax
je 0x33134
movl %eax, %r12d
pushq $0x78
popq %rdi
callq 0x27940
movq %rax, %r14
movq %rax, %rdi
callq 0x3bb24
leaq 0x98(%rsp), %rdi
callq 0xac95e
leaq 0x168(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x1a8(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xa0(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x18
popq %rbp
subl $0x1, %ebp
jb 0x330d6
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x330be
movq %r14, %rdi
addq $0x38, %rdi
leaq 0x98(%rsp), %rsi
callq 0x30d44
movq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x37f68
movslq 0x168(%rsp), %rax
testq %rax, %rax
js 0x33119
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r14, %rsi
callq 0x396fe
leaq 0x98(%rsp), %rdi
callq 0xad65a
movl %r12d, %eax
incl %eax
movl 0x20(%rsp), %ebp
jmp 0x3304c
movl 0x7c(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x70(%rsp)
movl %ecx, 0x28(%rsp)
cmpl 0x70(%rsp), %ecx
je 0x333fa
movl $0x88, %edi
callq 0x27940
movq %rax, 0x38(%rsp)
movq %rax, %rdi
xorl %esi, %esi
callq 0x3a2f4
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0xc0dfa
leaq 0x78(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
movq %r14, %rdi
pushq $0x8
popq %r14
movq %r14, %rsi
pushq $0x3
popq %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0x16
popq %rbp
subl $0x1, %ebp
jb 0x331d0
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x331b8
movl 0x78(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movl %eax, 0x18(%rsp)
movl %ecx, 0x8(%rsp)
cmpl 0x18(%rsp), %ecx
movl 0x20(%rsp), %ebp
je 0x333bd
movl $0xc8, %edi
callq 0x27940
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x3a9ec
leaq 0xf0(%rsp), %rdi
callq 0xc0dfa
leaq 0xd8(%rsp), %rdi
callq 0xc0dfa
leaq 0x1a8(%rsp), %rdi
callq 0xb0522
leaq 0x130(%rsp), %rdi
callq 0xb0522
leaq 0x74(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x158(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xf0(%rsp), %rdi
pushq $0x8
popq %rbp
movq %rbp, %rsi
pushq $0x3
popq %r12
movq %r12, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0xd8(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x1a8(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x130(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
pushq $0xe
popq %rbp
leaq 0x98(%rsp), %r12
subl $0x1, %ebp
jb 0x3330d
movq %rsp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x27ee0
jmp 0x332f5
movq %r12, %rdi
leaq 0xf0(%rsp), %rsi
leaq 0x1a8(%rsp), %rdx
callq 0x41d1e
leaq 0x168(%rsp), %rbp
movq %rbp, %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x41d1e
movq %r14, %rdi
leaq 0x98(%rsp), %rsi
movq %rbp, %rdx
callq 0x3b1c0
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movq %r14, %rdi
callq 0x3b1f8
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x3a54a
movslq 0x74(%rsp), %rax
testq %rax, %rax
js 0x33398
movq 0x30(%rsp), %rcx
movq 0x30(%rcx), %rcx
movq (%rcx,%rax,8), %rdi
movq %r14, %rsi
callq 0x3bf94
leaq 0x168(%rsp), %rdi
callq 0x41e6a
leaq 0x98(%rsp), %rdi
callq 0x41e6a
movl 0x8(%rsp), %ecx
incl %ecx
jmp 0x331df
movq 0x38(%rsp), %r14
movq %r14, %rdi
addq $0x28, %rdi
leaq 0x108(%rsp), %rsi
callq 0xc10e6
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x70(%r14)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x37fcc
movl 0x28(%rsp), %ecx
incl %ecx
jmp 0x33143
movq 0x30(%rsp), %r14
movq %r14, %rdi
addq $0x50, %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x30d44
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x36272
leaq 0x1f8(%rsp), %rdi
callq 0xad65a
movl 0x6c(%rsp), %eax
incl %eax
jmp 0x32ce9
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x3642c
movq %r14, %rdi
addq $0x50, %rdi
leaq 0x230(%rsp), %rsi
callq 0x30d44
movq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x31726
leaq 0x230(%rsp), %rdi
callq 0xad65a
movq 0x128(%rsp), %rax
incl %eax
jmp 0x328f8
leaq 0xf8785(%rip), %rdi     # 0x12bc19
jmp 0x32826
movq %rbx, %rdi
callq 0xe3997
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x33581
movl 0x60(%rsp), %eax
xorl $0x2, %eax
orl %eax, 0x58(%rsp)
jne 0x33581
movq %rbx, %rdi
movq 0x120(%rsp), %rsi
xorl %edx, %edx
callq 0xe3986
testl %eax, %eax
je 0x335a5
xorl %edx, %edx
movq 0x90(%rsp), %rcx
movslq 0x14(%rcx), %rax
cmpq %rax, %rdx
jge 0x33581
movq 0x8(%rcx), %rax
movq %rdx, 0x20(%rsp)
movq (%rax,%rdx,8), %r13
xorl %ebp, %ebp
movslq 0x24(%r13), %rax
cmpq %rax, %rbp
jge 0x33574
movq 0x18(%r13), %rax
movq (%rax,%rbp,8), %r14
xorl %r12d, %r12d
movq %rbp, 0x8(%rsp)
movq %r14, %rdi
callq 0x3796a
cmpl %eax, %r12d
jge 0x3356f
movq %r14, %r15
movq %r14, %rdi
movl %r12d, %ebp
movl %r12d, %esi
callq 0x3798c
movq %rax, %r12
xorl %r14d, %r14d
movslq 0x34(%r12), %rax
cmpq %rax, %r14
jge 0x3355f
movq 0x28(%r12), %rax
movq (%rax,%r14,8), %rdx
movq %rbx, %rsi
callq 0x35c72
incq %r14
jmp 0x3353f
movl %ebp, %r12d
incl %r12d
movq 0x8(%rsp), %rbp
movq %r15, %r14
jmp 0x3351b
incq %rbp
jmp 0x33502
movq 0x20(%rsp), %rdx
incq %rdx
jmp 0x334de
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0xe3986
pushq $0x1
popq %rbp
leaq 0x268(%rsp), %rdi
callq 0xad65a
jmp 0x32835
leaq 0xf8692(%rip), %rdi     # 0x12bc3e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xe434a
movq %rbx, %rdi
callq 0x27930
jmp 0x33593
jmp 0x3369a
jmp 0x3369a
movq %rax, %rbx
movl $0x90, %esi
movq 0x10(%rsp), %rdi
callq 0x27960
jmp 0x33751
jmp 0x3369a
jmp 0x3361d
jmp 0x3361d
movq %rax, %rbx
movl $0x98, %esi
movq 0x30(%rsp), %rdi
jmp 0x33613
jmp 0x3361d
movq %rax, %rbx
pushq $0x78
popq %rsi
jmp 0x33610
jmp 0x3361d
jmp 0x3361d
jmp 0x3361d
movq %rax, %rbx
movl $0xc8, %esi
movq %r14, %rdi
callq 0x27960
jmp 0x33744
movq %rax, %rbx
jmp 0x33744
jmp 0x336c7
jmp 0x33637
jmp 0x3369a
jmp 0x3369a
jmp 0x336e9
jmp 0x33688
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x3373f
jmp 0x336c7
jmp 0x336c7
movq %rax, %rbx
movl $0x88, %esi
movq 0x38(%rsp), %rdi
jmp 0x336ba
jmp 0x336e9
movq %rax, %rbx
movl $0x80, %esi
jmp 0x336db
jmp 0x336c7
movq %rax, %rbx
pushq $0x78
popq %rsi
jmp 0x336b7
jmp 0x336c7
jmp 0x336c7
movq %rax, %rbx
pushq $0x78
popq %rsi
movq 0x8(%rsp), %rdi
jmp 0x336ba
jmp 0x336c7
jmp 0x336c7
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x33732
jmp 0x336e9
movq %rax, %rbx
jmp 0x33751
jmp 0x336cc
jmp 0x336ee
jmp 0x336c7
movq %rax, %rbx
jmp 0x336fe
jmp 0x336c7
movq %rax, %rbx
movl $0xc8, %esi
movq %r14, %rdi
callq 0x27960
jmp 0x33737
jmp 0x336c7
jmp 0x336c7
jmp 0x336c7
movq %rax, %rbx
jmp 0x33737
movq %rax, %rbx
jmp 0x3371d
jmp 0x336e9
movq %rax, %rbx
movl $0xc8, %esi
movq %rbp, %rdi
callq 0x27960
jmp 0x3372a
jmp 0x336e9
jmp 0x336e9
movq %rax, %rbx
jmp 0x3372a
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x41e6a
leaq 0x98(%rsp), %rdi
callq 0x41e6a
jmp 0x33737
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x41e6a
leaq 0x1a8(%rsp), %rdi
callq 0xad65a
leaq 0x168(%rsp), %rdi
callq 0xad65a
leaq 0x1f8(%rsp), %rdi
callq 0xad65a
leaq 0x230(%rsp), %rdi
callq 0xad65a
leaq 0x268(%rsp), %rdi
callq 0xad65a
movq %rbx, %rdi
callq 0x28170