// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::WriteGSVStream(_IO_FILE*) const
int GSVScene::
WriteGSVStream(FILE *fp) const
{
  // Convenient variables
  int dummy = 0;

  // Make sure everything is uptodate
  R3Box foobar = BBox();
  if (foobar[0][0] == FLT_MAX) printf("Ouch\n");

  // Write magic keyword
  char magic[16] = { '\0' };
  strncpy(magic, "GSV", 16);
  if (fwrite(magic, sizeof(char), 16, fp) != (unsigned int) 16) {
    RNFail("Unable to write GSV scene file\n");
    return 0;
  }

  // Write header
  int endian_test = 1;
  int major_version = 2;
  int minor_version = 0;
  unsigned long long scene_file_offset = 0;
  fwrite(&dummy, sizeof(int), 1, fp);
  fwrite(&dummy, sizeof(int), 1, fp);
  fwrite(&scene_file_offset, sizeof(unsigned long long), 1, fp);
  fwrite(&endian_test, sizeof(int), 1, fp);
  fwrite(&major_version, sizeof(int), 1, fp);
  fwrite(&minor_version, sizeof(int), 1, fp);
  for (int j = 0; j < 53; j++) {
    fwrite(&dummy, sizeof(int), 1, fp);
  }

  // Write points
  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 iu = 0; iu < segment->NSurveys(); iu++) {
        GSVSurvey *survey = segment->Survey(iu);
        for (int ia = 0; ia < survey->NScans(); ia++) {
          GSVScan *scan = survey->Scan(ia);
          scan->ReadPoints();
          for (int ie = 0; ie < scan->NScanlines(); ie++) {
            GSVScanline *scanline = scan->Scanline(ie);
            scanline->WritePoints(fp, FALSE);
          }
          scan->ReleasePoints();
        }
      }
    }
  }

  // Get scene file offset
  scene_file_offset = RNFileTell(fp);

  // Write scene 
  int scene_nruns = NRuns();
  R3Box scene_bbox = BBox();
  R4Matrix scene_matrix = Transformation().Matrix();
  fwrite(&scene_nruns, sizeof(int), 1, fp);
  fwrite(&(scene_bbox[0][0]), sizeof(RNCoord), 6, fp);
  fwrite(&(scene_matrix[0][0]), sizeof(RNScalar), 16, fp);
  for (int j = 0; j < 89; j++) {
    fwrite(&dummy, sizeof(int), 1, fp);
  }

  // Write runs
  for (int ir = 0; ir < NRuns(); ir++) {
    GSVRun *run = Run(ir);
    int run_ncameras = run->NCameras();
    int run_nlasers = run->NLasers();
    int run_nsegments = run->NSegments();
    R3Box run_bbox = run->BBox();
    char run_name[256] = { '\0' };
    if (run->Name()) strncpy(run_name, run->Name(), 255);
    fwrite(run_name, sizeof(char), 256, fp);
    fwrite(&run_ncameras, sizeof(int), 1, fp);
    fwrite(&run_nlasers, sizeof(int), 1, fp);
    fwrite(&run_nsegments, sizeof(int), 1, fp);
    fwrite(&(run_bbox[0][0]), sizeof(RNCoord), 6, fp);
    for (int j = 0; j < 23; j++) {
      fwrite(&dummy, sizeof(int), 1, fp);
    }

    // Write cameras
    for (int ic = 0; ic < run->NCameras(); ic++) {
      GSVCamera *camera = run->Camera(ic);
      int camera_ntapestries = camera->NTapestries();
      int camera_distortion_type = camera->DistortionType();
      RNLength camera_focal_x = camera->XFocal();
      RNLength camera_focal_y = camera->YFocal();
      RNCoord camera_center_x = camera->XCenter();
      RNCoord camera_center_y = camera->YCenter();
      RNScalar camera_k1 = camera->K1();
      RNScalar camera_k2 = camera->K2();
      RNScalar camera_k3 = camera->K3();
      RNScalar camera_p1 = camera->P1();
      RNScalar camera_p2 = camera->P2();
      RNAngle camera_fov_max = camera->MaxFov();
      R3Box camera_bbox = camera->BBox();
      int camera_width = camera->ImageWidth();
      int camera_height = camera->ImageHeight();
      fwrite(&camera_ntapestries, sizeof(int), 1, fp);
      fwrite(&camera_distortion_type, sizeof(int), 1, fp);
      fwrite(&camera_focal_x, sizeof(RNLength), 1, fp);
      fwrite(&camera_focal_y, sizeof(RNLength), 1, fp);
      fwrite(&camera_center_x, sizeof(RNCoord), 1, fp);
      fwrite(&camera_center_y, sizeof(RNCoord), 1, fp);
      fwrite(&camera_k1, sizeof(RNScalar), 1, fp);
      fwrite(&camera_k2, sizeof(RNScalar), 1, fp);
      fwrite(&camera_k3, sizeof(RNScalar), 1, fp);
      fwrite(&camera_p1, sizeof(RNScalar), 1, fp);
      fwrite(&camera_p2, sizeof(RNScalar), 1, fp);
      fwrite(&camera_fov_max, sizeof(RNAngle), 1, fp);
      fwrite(&(camera_bbox[0][0]), sizeof(RNCoord), 6, fp);
      fwrite(&camera_width, sizeof(int), 1, fp);
      fwrite(&camera_height, sizeof(int), 1, fp);
      for (int j = 0; j < 13; j++) {
        fwrite(&dummy, sizeof(int), 1, fp);
      }
    }

    // Write lasers
    for (int il = 0; il < run->NLasers(); il++) {
      GSVLaser *laser = run->Laser(il);
      int device_type = laser->DeviceType();
      int max_sweep_index = laser->MaxSweepIndex();
      int max_beam_index = laser->MaxBeamIndex();
      int laser_nsurveys = laser->NSurveys();
      R3Box laser_bbox = laser->BBox();
      fwrite(&device_type, sizeof(int), 1, fp);
      fwrite(&laser_nsurveys, sizeof(int), 1, fp);
      fwrite(&(laser_bbox[0][0]), sizeof(RNCoord), 6, fp);
      fwrite(&max_sweep_index, sizeof(int), 1, fp);
      fwrite(&max_beam_index, sizeof(int), 1, fp);
      for (int j = 0; j < 22; j++) {
        fwrite(&dummy, sizeof(int), 1, fp);
      }
    }

    // Write segments
    for (int is = 0; is < run->NSegments(); is++) {
      GSVSegment *segment = run->Segment(is);
      int segment_nsurveys = segment->NSurveys();
      int segment_ntapestries = segment->NTapestries();
      int segment_npanoramas = segment->NPanoramas();
      R3Box segment_bbox = segment->BBox();
      char segment_name[256] = { '\0' };
      if (segment->Name()) strncpy(segment_name, segment->Name(), 255);
      fwrite(segment_name, sizeof(char), 256, fp);
      fwrite(&segment_nsurveys, sizeof(int), 1, fp);
      fwrite(&segment_ntapestries, sizeof(int), 1, fp);
      fwrite(&segment_npanoramas, sizeof(int), 1, fp);
      fwrite(&(segment_bbox[0][0]), sizeof(RNCoord), 6, fp);
      for (int j = 0; j < 23; j++) {
        fwrite(&dummy, sizeof(int), 1, fp);
      }

      // Write surveys
      for (int iu = 0; iu < segment->NSurveys(); iu++) {
        GSVSurvey *survey = segment->Survey(iu);
        int survey_laser_index = (survey->Laser()) ? survey->Laser()->RunIndex() : -1;
        int survey_nscans = survey->NScans();
        R3Box survey_bbox = segment->BBox();
        fwrite(&survey_laser_index, sizeof(int), 1, fp);
        fwrite(&survey_nscans, sizeof(int), 1, fp);
        fwrite(&(survey_bbox[0][0]), sizeof(RNCoord), 6, fp);
        for (int j = 0; j < 24; j++) {
          fwrite(&dummy, sizeof(int), 1, fp);
        }

        // Write scans
        for (int ia = 0; ia < survey->NScans(); ia++) {
          GSVScan *scan = survey->Scan(ia);
          int scan_nscanlines = scan->NScanlines();
          R3Box scan_bbox = scan->BBox();
          fwrite(&scan_nscanlines, sizeof(int), 1, fp);
          fwrite(&(scan_bbox[0][0]), sizeof(RNCoord), 6, fp);
          for (int j = 0; j < 24; j++) {
            fwrite(&dummy, sizeof(int), 1, fp);
          }

          // Write scanlines
          for (int ie = 0; ie < scan->NScanlines(); ie++) {
            GSVScanline *scanline = scan->Scanline(ie);
            int scanline_npoints = scanline->NPoints();
            R3Point scanline_viewpoint = scanline->Pose().Viewpoint();
            R3Quaternion scanline_orientation = scanline->Pose().Orientation();
            RNScalar scanline_timestamp = scanline->Timestamp();
            int scanline_sweep_index = scanline->SweepIndex();
            R3Box scanline_bbox = scanline->BBox();
            unsigned long long scanline_file_offset = scanline->FileOffset();
            fwrite(&(scanline_npoints), sizeof(int), 1, fp);
            fwrite(&(scanline_viewpoint[0]), sizeof(RNCoord), 3, fp);
            fwrite(&(scanline_orientation[0]), sizeof(RNCoord), 4, fp);
            fwrite(&scanline_timestamp, sizeof(RNScalar), 1, fp);
            fwrite(&(scanline_bbox[0][0]), sizeof(RNCoord), 6, fp);
            fwrite(&(scanline_file_offset), sizeof(unsigned long long), 1, fp);
            fwrite(&(scanline_sweep_index), sizeof(int), 1, fp);
            for (int j = 0; j < 14; j++) {
              fwrite(&dummy, sizeof(int), 1, fp);
            }
          }
        }
      }
      
      // Write tapestries
      for (int it = 0; it < segment->NTapestries(); it++) {
        GSVTapestry *tapestry = segment->Tapestry(it);
        int tapestry_camera_index = (tapestry->Camera()) ? tapestry->Camera()->RunIndex() : -1;
        int tapestry_nimages = tapestry->NImages();
        R3Box tapestry_bbox = segment->BBox();
        fwrite(&tapestry_camera_index, sizeof(int), 1, fp);
        fwrite(&tapestry_nimages, sizeof(int), 1, fp);
        fwrite(&(tapestry_bbox[0][0]), sizeof(RNCoord), 6, fp);
        for (int j = 0; j < 24; j++) {
          fwrite(&dummy, sizeof(int), 1, fp);
        }
      }

      // Write panoramas
      for (int ip = 0; ip < segment->NPanoramas(); ip++) {
        GSVPanorama *panorama = segment->Panorama(ip);
        int panorama_nimages = panorama->NImages();
        R3Point panorama_viewpoint = panorama->Viewpoint();
        RNScalar panorama_timestamp = panorama->Timestamp();
        char panorama_name[256] = { '\0' };
        if (panorama->Name()) strncpy(panorama_name, panorama->Name(), 255);
        fwrite(panorama_name, sizeof(char), 256, fp);
        fwrite(&panorama_nimages, sizeof(int), 1, fp);
        fwrite(&(panorama_viewpoint[0]), sizeof(RNCoord), 3, fp);
        fwrite(&panorama_timestamp, sizeof(RNScalar), 1, fp);
        for (int j = 0; j < 22; j++) {
          fwrite(&dummy, sizeof(int), 1, fp);
        }

        // Write images
        for (int ii = 0; ii < panorama->NImages(); ii++) {
          GSVImage *image = panorama->Image(ii);
          int image_tapestry_index = (image->Tapestry()) ? image->Tapestry()->SegmentIndex() : -1;
          int image_ncolumns = image->Width();
          R3Point image_viewpoint0 = image->Pose(0).Viewpoint();
          R3Point image_viewpoint1 = image->Pose(image->Width()-1).Viewpoint();
          R3Quaternion image_orientation0 = image->Pose(0).Orientation();
          R3Quaternion image_orientation1 = image->Pose(image->Width()-1).Orientation();
          RNScalar image_timestamp0 = image->Timestamp(0);
          RNScalar image_timestamp1 = image->Timestamp(image->Width()-1);
          char image_name[256] = { '\0' };
          if (image->Name()) strncpy(image_name, image->Name(), 255);
          fwrite(image_name, sizeof(char), 256, fp);
          fwrite(&image_tapestry_index, sizeof(int), 1, fp);
          fwrite(&image_ncolumns, sizeof(int), 1, fp);
          fwrite(&(image_viewpoint0[0]), sizeof(RNCoord), 3, fp);
          fwrite(&(image_viewpoint1[0]), sizeof(RNCoord), 3, fp);
          fwrite(&(image_orientation0[0]), sizeof(RNCoord), 4, fp);
          fwrite(&(image_orientation1[0]), sizeof(RNCoord), 4, fp);
          fwrite(&image_timestamp0, sizeof(RNScalar), 1, fp);
          fwrite(&image_timestamp1, sizeof(RNScalar), 1, fp);
          for (int j = 0; j < 14; j++) {
            fwrite(&dummy, sizeof(int), 1, fp);
          }
        }
      }
    }
  }

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

  // Re-write header with updated scene file offset
  RNFileSeek(fp, 0, RN_FILE_SEEK_SET);
  fwrite(magic, sizeof(char), 16, fp);
  fwrite(&dummy, sizeof(int), 1, fp);
  fwrite(&dummy, sizeof(int), 1, fp);
  fwrite(&scene_file_offset, sizeof(unsigned long long), 1, fp);
  fwrite(&endian_test, sizeof(int), 1, fp);
  fwrite(&major_version, sizeof(int), 1, fp);
  fwrite(&minor_version, sizeof(int), 1, fp);

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

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6b8, %rsp            # imm = 0x6B8
movq %rsi, %rbx
movq %rdi, %r14
movl $0x0, (%rsp)
movsd 0x38(%rdi), %xmm0
ucomisd 0x117781(%rip), %xmm0   # 0x14e008
jne 0x36893
jp 0x36893
movq %r14, %rdi
callq 0x331ec
leaq 0x30(%r14), %r12
leaq 0x2f8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xbf038
movsd 0x8(%r15), %xmm0
ucomisd 0x117750(%rip), %xmm0   # 0x14e008
jne 0x368c8
jp 0x368c8
leaq 0x1183b0(%rip), %rdi    # 0x14ec73
callq 0x27f40
movupd 0x1183b9(%rip), %xmm0   # 0x14ec89
leaq 0x170(%rsp), %rdi
movapd %xmm0, (%rdi)
movl $0x1, %esi
movl $0x10, %edx
movq %rbx, %rcx
callq 0x28330
cmpq $0x10, %rax
jne 0x37b23
movq %r12, 0x18(%rsp)
movq %r14, 0x48(%rsp)
leaq 0x7c(%rsp), %rbp
movl $0x1, (%rbp)
leaq 0x78(%rsp), %r13
movl $0x2, (%r13)
leaq 0x74(%rsp), %r12
movl $0x0, (%r12)
leaq 0x80(%rsp), %r14
movq $0x0, (%r14)
movq %rsp, %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x35, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x369bd
movq 0x48(%rsp), %r14
cmpl $0x0, 0x14(%r14)
jle 0x36ac6
xorl %ecx, %ecx
movq 0x8(%r14), %rax
movq %rcx, 0x58(%rsp)
movq (%rax,%rcx,8), %rcx
cmpl $0x0, 0x24(%rcx)
jle 0x36aac
xorl %edx, %edx
movq %rcx, 0x50(%rsp)
movq 0x18(%rcx), %rax
movq %rdx, 0x20(%rsp)
movq (%rax,%rdx,8), %rcx
cmpl $0x0, 0x2c(%rcx)
jle 0x36a92
xorl %r14d, %r14d
movq %rcx, 0x28(%rsp)
movq 0x20(%rcx), %rax
movq (%rax,%r14,8), %r12
cmpl $0x0, 0x34(%r12)
jle 0x36a81
xorl %r13d, %r13d
movq 0x28(%r12), %rax
movq (%rax,%r13,8), %r15
movq %r15, %rdi
callq 0x405e6
cmpl $0x0, 0x34(%r15)
jle 0x36a6c
xorl %ebp, %ebp
movq 0x28(%r15), %rax
movq (%rax,%rbp,8), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x42eda
incq %rbp
movslq 0x34(%r15), %rax
cmpq %rax, %rbp
jl 0x36a4e
movq %r15, %rdi
callq 0x406c0
incq %r13
movslq 0x34(%r12), %rax
cmpq %rax, %r13
jl 0x36a34
incq %r14
movq 0x28(%rsp), %rcx
movslq 0x2c(%rcx), %rax
cmpq %rax, %r14
jl 0x36a21
movq 0x20(%rsp), %rdx
incq %rdx
movq 0x50(%rsp), %rcx
movslq 0x24(%rcx), %rax
cmpq %rax, %rdx
jl 0x36a06
movq 0x58(%rsp), %rcx
incq %rcx
movq 0x48(%rsp), %r14
movslq 0x14(%r14), %rax
cmpq %rax, %rcx
jl 0x369e8
movq %rbx, %rdi
callq 0xfc9f7
movq %rax, 0x80(%rsp)
movl 0x14(%r14), %eax
movl %eax, 0x70(%rsp)
movsd 0x38(%r14), %xmm0
ucomisd 0x11751c(%rip), %xmm0   # 0x14e008
movq 0x18(%rsp), %r15
jne 0x36afd
jp 0x36afd
movq %r14, %rdi
callq 0x331ec
leaq 0x2c0(%rsp), %rdi
movq %r15, %rsi
callq 0xbf038
leaq 0x70(%r14), %rsi
leaq 0x530(%rsp), %rdi
callq 0xc4102
leaq 0x70(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x28330
leaq 0x2c8(%rsp), %rdi
movl $0x8, %esi
movl $0x6, %edx
movq %rbx, %rcx
callq 0x28330
leaq 0x530(%rsp), %rdi
movl $0x8, %esi
movl $0x10, %edx
movq %rbx, %rcx
callq 0x28330
movl $0x59, %ebp
movq %rsp, %r14
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x36b71
movq 0x48(%rsp), %rcx
cmpl $0x0, 0x14(%rcx)
jle 0x37a45
xorl %eax, %eax
movsd 0x117465(%rip), %xmm1   # 0x14e008
leaq 0x5b0(%rsp), %r15
movq %rsp, %r14
movq %rax, %rdx
movq 0x8(%rcx), %rax
movq %rdx, 0x88(%rsp)
movq (%rax,%rdx,8), %r12
movl 0x34(%r12), %eax
movl %eax, 0x6c(%rsp)
movl 0x44(%r12), %eax
movl %eax, 0x68(%rsp)
movl 0x24(%r12), %eax
movl %eax, 0x64(%rsp)
movsd 0x58(%r12), %xmm0
ucomisd %xmm1, %xmm0
jne 0x36bf3
jp 0x36bf3
movq %r12, %rdi
callq 0x3836c
leaq 0x50(%r12), %rsi
leaq 0x288(%rsp), %rdi
callq 0xbf038
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x274b0
movq %r12, 0x18(%rsp)
movq 0x48(%r12), %rsi
testq %rsi, %rsi
je 0x36c30
movl $0xff, %edx
movq %r15, %rdi
callq 0x27450
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x6c(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x68(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x64(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x290(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x17, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x36ca9
movq 0x18(%rsp), %rcx
cmpl $0x0, 0x34(%rcx)
jle 0x36f9b
xorl %r15d, %r15d
movq 0x28(%rcx), %rax
movq (%rax,%r15,8), %r12
movl 0x24(%r12), %eax
movl %eax, 0x30(%rsp)
movl 0x28(%r12), %eax
movl %eax, 0x14(%rsp)
movsd 0x38(%r12), %xmm0
movsd %xmm0, 0x330(%rsp)
movsd 0x40(%r12), %xmm0
movsd %xmm0, 0x180(%rsp)
movsd 0x48(%r12), %xmm0
movsd %xmm0, 0x138(%rsp)
movsd 0x50(%r12), %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0x58(%r12), %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x60(%r12), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x68(%r12), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x70(%r12), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x78(%r12), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x80(%r12), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x90(%r12), %xmm0
ucomisd 0x11726b(%rip), %xmm0   # 0x14e008
leaq 0x180(%rsp), %r13
jne 0x36db1
jp 0x36db1
movq %r12, %rdi
callq 0x3be94
leaq 0x88(%r12), %rsi
leaq 0x430(%rsp), %rdi
callq 0xbf038
movl 0x2c(%r12), %eax
testl %eax, %eax
movl $0x790, %ecx            # imm = 0x790
cmovsl %ecx, %eax
movl %eax, 0x10(%rsp)
movl 0x30(%r12), %eax
testl %eax, %eax
movl $0xa20, %ecx            # imm = 0xA20
cmovsl %ecx, %eax
movl %eax, 0xc(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x30(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x330(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x138(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0xe0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x118(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0xc8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0xb0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x98(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x40(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x38(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x438(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0xd, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x36f60
leaq 0x430(%rsp), %rdi
callq 0xbfe90
incq %r15
movq 0x18(%rsp), %rcx
movslq 0x34(%rcx), %rax
cmpq %rax, %r15
jl 0x36cd4
cmpl $0x0, 0x44(%rcx)
leaq 0x180(%rsp), %r13
jle 0x370dc
xorl %r15d, %r15d
movq 0x38(%rcx), %rax
movq (%rax,%r15,8), %r12
movl 0x28(%r12), %eax
movl %eax, 0x330(%rsp)
movl 0x2c(%r12), %eax
movl %eax, 0x180(%rsp)
movl 0x30(%r12), %eax
movl %eax, 0x138(%rsp)
movl 0x24(%r12), %eax
movl %eax, 0xe0(%rsp)
movsd 0x40(%r12), %xmm0
ucomisd 0x117011(%rip), %xmm0   # 0x14e008
jne 0x37003
jp 0x37003
movq %r12, %rdi
callq 0x3f190
addq $0x38, %r12
leaq 0x430(%rsp), %rdi
movq %r12, %rsi
callq 0xbf038
movl $0x4, %esi
movl $0x1, %edx
leaq 0x330(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0xe0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x438(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x138(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x16, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x37099
leaq 0x430(%rsp), %rdi
callq 0xbfe90
incq %r15
movq 0x18(%rsp), %rcx
movslq 0x44(%rcx), %rax
cmpq %rax, %r15
leaq 0x180(%rsp), %r13
jl 0x36fb0
cmpl $0x0, 0x24(%rcx)
jle 0x37a08
xorl %edx, %edx
movq 0x18(%rcx), %rax
movq %rdx, 0x90(%rsp)
movq (%rax,%rdx,8), %r12
movl 0x2c(%r12), %eax
movl %eax, 0x14(%rsp)
movl 0x3c(%r12), %eax
movl %eax, 0x10(%rsp)
movl 0x4c(%r12), %eax
movl %eax, 0xc(%rsp)
movsd 0x58(%r12), %xmm0
ucomisd 0x116ee6(%rip), %xmm0   # 0x14e008
jne 0x3712e
jp 0x3712e
movq %r12, %rdi
callq 0x3a62e
leaq 0x50(%r12), %rsi
leaq 0x138(%rsp), %rdi
movq %rsi, 0x50(%rsp)
callq 0xbf038
movl $0x100, %edx            # imm = 0x100
leaq 0x430(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x274b0
movq %r12, 0x20(%rsp)
movq 0x88(%r12), %rsi
testq %rsi, %rsi
je 0x3717b
movl $0xff, %edx
movq %r15, %rdi
callq 0x27450
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x140(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x17, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x371f4
movq 0x20(%rsp), %rdi
cmpl $0x0, 0x2c(%rdi)
leaq 0x330(%rsp), %r15
leaq 0x180(%rsp), %r13
jle 0x37556
xorl %r12d, %r12d
movq 0x20(%rdi), %rax
movq (%rax,%r12,8), %rcx
movq 0x18(%rcx), %rax
testq %rax, %rax
je 0x37245
movl 0x10(%rax), %eax
jmp 0x3724a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x40(%rsp)
movq %rcx, 0x28(%rsp)
movl 0x34(%rcx), %eax
movl %eax, 0x38(%rsp)
movsd 0x58(%rdi), %xmm0
ucomisd 0x116da1(%rip), %xmm0   # 0x14e008
jne 0x37270
jp 0x37270
callq 0x3a62e
movq %r15, %rdi
movq 0x50(%rsp), %rsi
callq 0xbf038
movq %r12, 0x58(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x40(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x38(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x338(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x18, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x372cf
movq 0x28(%rsp), %rcx
cmpl $0x0, 0x34(%rcx)
leaq 0x180(%rsp), %r13
jle 0x3752c
xorl %r15d, %r15d
movq 0x28(%rcx), %rax
movq (%rax,%r15,8), %r12
movl 0x34(%r12), %eax
movl %eax, 0x30(%rsp)
movsd 0x40(%r12), %xmm0
ucomisd 0x116ce6(%rip), %xmm0   # 0x14e008
jne 0x3732e
jp 0x3732e
movq %r12, %rdi
callq 0x40a24
leaq 0x38(%r12), %rsi
movq %r13, %rdi
callq 0xbf038
movl $0x4, %esi
movl $0x1, %edx
leaq 0x30(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x188(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x18, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x37371
cmpl $0x0, 0x34(%r12)
jle 0x37507
xorl %ebp, %ebp
movq 0x28(%r12), %rax
movq (%rax,%rbp,8), %r13
movl 0x30(%r13), %eax
movl %eax, 0x8(%rsp)
leaq 0x40(%r13), %rsi
leaq 0xc8(%rsp), %rdi
callq 0xd5e3e
leaq 0x58(%r13), %rsi
leaq 0x118(%rsp), %rdi
callq 0xc2f66
movsd 0x78(%r13), %xmm0
movsd %xmm0, 0xb0(%rsp)
movl 0x80(%r13), %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
callq 0x42c46
testl %eax, %eax
je 0x373f9
movq %r13, %rdi
callq 0x42c60
leaq 0x88(%r13), %rsi
leaq 0xe0(%rsp), %rdi
callq 0xbf038
movq 0x18(%r13), %rax
movq %rax, 0x98(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x3, %edx
leaq 0xc8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x4, %edx
leaq 0x118(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0xb0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0xe8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x98(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0xe, %r13d
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %r13d
jne 0x374cf
leaq 0xe0(%rsp), %rdi
callq 0xbfe90
incq %rbp
movslq 0x34(%r12), %rax
cmpq %rax, %rbp
jl 0x37398
leaq 0x180(%rsp), %r13
movq %r13, %rdi
callq 0xbfe90
incq %r15
movq 0x28(%rsp), %rcx
movslq 0x34(%rcx), %rax
cmpq %rax, %r15
jl 0x37302
leaq 0x330(%rsp), %r15
movq %r15, %rdi
callq 0xbfe90
movq 0x58(%rsp), %r12
incq %r12
movq 0x20(%rsp), %rdi
movslq 0x2c(%rdi), %rax
cmpq %rax, %r12
jl 0x3722f
cmpl $0x0, 0x3c(%rdi)
jle 0x37648
xorl %r15d, %r15d
movq 0x30(%rdi), %rax
movq (%rax,%r15,8), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
je 0x37579
movl 0x10(%rcx), %ecx
jmp 0x3757e
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x180(%rsp)
movl 0x34(%rax), %eax
movl %eax, 0xe0(%rsp)
movsd 0x58(%rdi), %xmm0
ucomisd 0x116a6c(%rip), %xmm0   # 0x14e008
jne 0x375a5
jp 0x375a5
callq 0x3a62e
leaq 0x330(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xbf038
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0xe0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x6, %edx
leaq 0x338(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x18, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x37605
leaq 0x330(%rsp), %rdi
callq 0xbfe90
incq %r15
movq 0x20(%rsp), %rdi
movslq 0x3c(%rdi), %rax
cmpq %rax, %r15
leaq 0x180(%rsp), %r13
jl 0x37563
cmpl $0x0, 0x4c(%rdi)
jle 0x379de
xorl %r12d, %r12d
movq 0x40(%rdi), %rax
movq (%rax,%r12,8), %r13
movl 0x24(%r13), %eax
movl %eax, 0x8(%rsp)
movsd 0x28(%r13), %xmm0
ucomisd 0x116995(%rip), %xmm0   # 0x14e008
jne 0x3767f
jp 0x3767f
movq %r13, %rdi
callq 0x3cf6e
leaq 0x28(%r13), %rsi
leaq 0xc8(%rsp), %rdi
callq 0xd5e3e
movsd 0x70(%r13), %xmm0
ucomisd 0x1169d2(%rip), %xmm0   # 0x14e070
jne 0x376aa
jp 0x376aa
movq %r13, %rdi
callq 0x3d230
movq %r12, 0x28(%rsp)
movsd 0x70(%r13), %xmm0
movsd %xmm0, 0x40(%rsp)
movl $0x100, %edx            # imm = 0x100
leaq 0x330(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x274b0
movq %r13, %r15
movq 0x78(%r13), %rsi
testq %rsi, %rsi
je 0x376eb
movl $0xff, %edx
movq %r12, %rdi
callq 0x27450
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
movq %r12, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x3, %edx
leaq 0xc8(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x40(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x16, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x3774d
cmpl $0x0, 0x24(%r15)
jle 0x379c4
movq %r15, %rcx
xorl %r13d, %r13d
movq 0x18(%rcx), %rax
movq (%rax,%r13,8), %r12
movq 0x8(%r12), %rax
testq %rax, %rax
leaq 0x180(%rsp), %rbp
je 0x37796
movl 0x10(%rax), %eax
jmp 0x3779b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rsp)
movq %r12, %rdi
callq 0x3d64c
movl %eax, 0x60(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3d698
leaq 0xb0(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0xd5e3e
movq %rbp, %rdi
callq 0x455ba
movq %r12, %rdi
callq 0x3d64c
decl %eax
movq %rbp, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x3d698
leaq 0x98(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0xd5e3e
movq %rbp, %rdi
callq 0x455ba
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3d698
leaq 0xe0(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0xc2f66
movq %rbp, %rdi
callq 0x455ba
movq %r12, %rdi
callq 0x3d64c
decl %eax
movq %rbp, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x3d698
leaq 0x118(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0xc2f66
movq %rbp, %rdi
callq 0x455ba
movq %r12, %rdi
xorl %esi, %esi
callq 0x3d79c
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
callq 0x3d64c
decl %eax
movq %r12, %rdi
movl %eax, %esi
callq 0x3d79c
movsd %xmm0, 0x30(%rsp)
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
xorl %esi, %esi
callq 0x274b0
movq 0xb8(%r12), %rsi
testq %rsi, %rsi
je 0x378ba
movl $0xff, %edx
movq %rbp, %rdi
callq 0x27450
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
leaq 0x60(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x3, %edx
leaq 0xb0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x3, %edx
leaq 0x98(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x4, %edx
leaq 0xe0(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x4, %edx
leaq 0x118(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x38(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x8, %esi
movl $0x1, %edx
leaq 0x30(%rsp), %rdi
movq %rbx, %rcx
callq 0x28330
movl $0xe, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x28330
decl %ebp
jne 0x37998
incq %r13
movq %r15, %rcx
movslq 0x24(%r15), %rax
cmpq %rax, %r13
jl 0x37777
movq 0x28(%rsp), %r12
incq %r12
movq 0x20(%rsp), %rdi
movslq 0x4c(%rdi), %rax
cmpq %rax, %r12
jl 0x37655
leaq 0x138(%rsp), %rdi
callq 0xbfe90
movq 0x90(%rsp), %rdx
incq %rdx
movq 0x18(%rsp), %rcx
movslq 0x24(%rcx), %rax
cmpq %rax, %rdx
jl 0x370e8
leaq 0x288(%rsp), %rdi
callq 0xbfe90
movq 0x88(%rsp), %rdx
incq %rdx
movq 0x48(%rsp), %rcx
movslq 0x14(%rcx), %rax
cmpq %rax, %rdx
movq %rdx, %rax
movsd 0x1165d1(%rip), %xmm1   # 0x14e008
leaq 0x5b0(%rsp), %r15
jl 0x36bae
movq %rbx, %rdi
callq 0xfc9f7
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xfc9e6
leaq 0x170(%rsp), %rdi
movl $0x1, %esi
movl $0x10, %edx
movq %rbx, %rcx
callq 0x28330
movq %rsp, %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x28330
leaq 0x80(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x28330
leaq 0x7c(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x28330
leaq 0x78(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x28330
leaq 0x74(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x28330
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xfc9e6
leaq 0x2c0(%rsp), %rdi
callq 0xbfe90
movl $0x1, %ebx
jmp 0x37b33
xorl %ebx, %ebx
leaq 0x117127(%rip), %rdi    # 0x14ec53
xorl %eax, %eax
callq 0xfd64a
leaq 0x2f8(%rsp), %rdi
callq 0xbfe90
movl %ebx, %eax
addq $0x6b8, %rsp            # imm = 0x6B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37b67
jmp 0x37bf7
jmp 0x37b67
jmp 0x37bf7
jmp 0x37bf7
movq %rax, %rbx
jmp 0x37be8
jmp 0x37b70
jmp 0x37b70
movq %rax, %rbx
jmp 0x37bdb
jmp 0x37ba6
jmp 0x37ba6
jmp 0x37ba6
jmp 0x37ba6
jmp 0x37b83
jmp 0x37b83
jmp 0x37b83
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x455ba
jmp 0x37bce
jmp 0x37ba6
jmp 0x37ba6
jmp 0x37ba6
jmp 0x37ba6
movq %rax, %rbx
jmp 0x37bc1
jmp 0x37ba6
jmp 0x37ba6
movq %rax, %rbx
jmp 0x37bce
jmp 0x37bf7
jmp 0x37bb1
jmp 0x37bb1
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0xbfe90
leaq 0x330(%rsp), %rdi
callq 0xbfe90
leaq 0x138(%rsp), %rdi
callq 0xbfe90
leaq 0x288(%rsp), %rdi
callq 0xbfe90
leaq 0x2c0(%rsp), %rdi
callq 0xbfe90
jmp 0x37bfa
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0xbfe90
movq %rbx, %rdi
callq 0x28160
nop