// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDConfiguration.cpp
// Function: gaps::RGBDConfiguration::ReadConfigurationStream(_IO_FILE*, int)
int RGBDConfiguration::
ReadConfigurationStream(FILE *fp, int read_every_kth_image)
{
  // Initialize stuff
  int image_count = 0;
  R3Matrix intrinsics_matrix = R3identity_matrix;
  int image_width = 0;
  int image_height = 0;
  
  // Parse file
  char buffer[4096];
  int line_number = 0;
  while (fgets(buffer, 4096, fp)) {
    char cmd[1024];
    line_number++;
    if (sscanf(buffer, "%s", cmd) != (unsigned int) 1) continue;
    if (cmd[0] == '#') continue;

    // Check cmd
    if (!strcmp(cmd, "dataset")) {
      // Parse dataset format
      char name[1024] = { '\0' };
      if (sscanf(buffer, "%s%s", cmd, name) != (unsigned int) 2) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Set dataset format
      SetDatasetFormat(name);
    }
    else if (!strcmp(cmd, "sequence") || !strcmp(cmd, "name")) {
      // Parse name
      char name[1024] = { '\0' };
      if (sscanf(buffer, "%s%s", cmd, name) != (unsigned int) 2) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Set dataset format
      SetName(name);
    }
    else if (!strcmp(cmd, "depth_resolution")) {
      // Parse dimensions
      if (sscanf(buffer, "%s%d%d", cmd, &image_width, &image_height) != (unsigned int) 3) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }
    }
    else if (!strcmp(cmd, "color_resolution")) {
      // Parse dimensions
      if ((image_width == 0) || (image_height == 0)) {
        if (sscanf(buffer, "%s%d%d", cmd, &image_width, &image_height) != (unsigned int) 3) {
          RNFail("Error parsing line %d of configuration file\n", line_number);
          return 0;
        }
      }
    }
    else if (!strcmp(cmd, "depth_directory") || !strcmp(cmd, "color_directory") ||
             !strcmp(cmd, "category_directory") || !strcmp(cmd, "instance_directory") ||
             !strcmp(cmd, "texture_directory") || !strcmp(cmd, "image_directory")) {
      // Parse directory name
      char dirname[1024];
      if (sscanf(buffer, "%s%s", cmd, dirname) != (unsigned int) 2) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Assign directory name (this leaks memory, but who cares)
      if (!strcmp(cmd, "color_directory")) SetColorDirectory(dirname);
      else if (!strcmp(cmd, "depth_directory")) SetDepthDirectory(dirname);
      else if (!strcmp(cmd, "category_directory")) SetCategoryDirectory(dirname);
      else if (!strcmp(cmd, "instance_directory")) SetInstanceDirectory(dirname);
      else if (!strcmp(cmd, "image_directory")) SetColorDirectory(dirname);
      else if (!strcmp(cmd, "texture_directory")) SetTextureDirectory(dirname);
    }
    else if (!strcmp(cmd, "intrinsics") || !strcmp(cmd, "depth_intrinsics")) { // || !strcmp(cmd, "color_intrinsics")) {
      // Parse intrinsics filename
      char intrinsics_filename[2048];
      if (sscanf(buffer, "%s%s", cmd, intrinsics_filename) != (unsigned int) 2) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Open intrinsics file
      FILE *intrinsics_fp = fopen(intrinsics_filename, "r");
      if (!intrinsics_fp) {
        RNFail("Unable to open intrinsics file %s\n", intrinsics_filename);
        return 0;
      }

      // Read intrinsics file
      if (dataset_format && !strcmp(dataset_format, "matterport")) {
        // Read matterport intrinsics
        double width, height, fx, fy, cx, cy, k1, k2, p1, p2, k3;
        if (fscanf(intrinsics_fp, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &width, &height,
          &fx, &fy, &cx, &cy, &k1, &k2, &p1, &p2, &k3) != (unsigned int) 11) {
          RNFail("Unable to read Matterport intrinsics matrix.\n");
          return 0;
        }

        // Assign intrinsics matrix
        intrinsics_matrix = R3Matrix(fx, 0, cx,   0, fy, cy,   0, 0, 1);
      }
      else {
        // Read matrix
        RNScalar m[9];
        if (fscanf(intrinsics_fp, "%lf%lf%lf%lf%lf%lf%lf%lf%lf", &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], &m[8]) != (unsigned int) 9) {
          RNFail("Unable to read intrinsics file %s\n", intrinsics_filename);
          return 0;
        }

        // Assign intrinsics matrix
        intrinsics_matrix = R3Matrix(m);
      }

      // Close intrinsics file
      fclose(intrinsics_fp);
    }
    else if (!strcmp(cmd, "intrinsics_matrix") || !strcmp(cmd, "depth_intrinsics_matrix")) { // || !strcmp(cmd, "color_intrinsics_matrix")) {
      // Parse matrix
      double m[9];
      if (sscanf(buffer, "%s%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], &m[8]) != (unsigned int) 10) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Assign intrinsics matrix
      intrinsics_matrix = R3Matrix(m);
    }
    else if (!strcmp(cmd, "scan") || !strcmp(cmd, "image")) {
      // Update/check image count
      if ((read_every_kth_image > 1) && ((++image_count % read_every_kth_image) != 1)) continue;

      // Check intrinsics matrix
      if (intrinsics_matrix.IsIdentity()) {
        RNFail("Unable to process scan without prior setting of intrinsics matrix in configuration file\n");
        return 0;
      }
      
      // Parse image names and alignment transformation
      RNScalar m[16];
      char depth_filename[2048], color_filename[2048];
      if (sscanf(buffer, "%s%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, 
         depth_filename, color_filename,
         &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], 
         &m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]) != (unsigned int) 19) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Create RGBD image
      // RGBDImage *image = new RGBDImage(color_filename, depth_filename, intrinsics_matrix, R4Matrix(m), image_width, image_height);
      RGBDImage *image = AllocateImage();
      image->SetNPixels(image_width, image_height);
      image->SetColorFilename(color_filename);
      image->SetDepthFilename(depth_filename);
      image->SetIntrinsics(intrinsics_matrix);
      image->SetCameraToWorld(R3Affine(R4Matrix(m), 0));
      InsertImage(image);
    }
    else if (!strcmp(cmd, "labeled_image")) {
      // Update/check image count
      if ((read_every_kth_image > 1) && ((++image_count % read_every_kth_image) != 1)) continue;

      // Check intrinsics matrix
      if (intrinsics_matrix.IsIdentity()) {
        RNFail("Unable to process scan without prior setting of intrinsics matrix in configuration file\n");
        return 0;
      }
      
      // Parse image names and alignment transformation
      RNScalar m[16];
      char depth_filename[2048], color_filename[2048], category_filename[2048], instance_filename[2048];
      if (sscanf(buffer, "%s%s%s%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, 
         depth_filename, color_filename, category_filename, instance_filename,
         &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], 
         &m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]) != (unsigned int) 21) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Create RGBD image
      // RGBDImage *image = new RGBDImage(color_filename, depth_filename, intrinsics_matrix, R4Matrix(m), image_width, image_height);
      RGBDImage *image = AllocateImage();
      image->SetNPixels(image_width, image_height);
      image->SetColorFilename(color_filename);
      image->SetDepthFilename(depth_filename);
      image->SetCategoryFilename(category_filename);
      image->SetInstanceFilename(instance_filename);
      image->SetIntrinsics(intrinsics_matrix);
      image->SetCameraToWorld(R3Affine(R4Matrix(m), 0));
      InsertImage(image);
    }
    else if (!strcmp(cmd, "frame")) {
      // Update/check image count
      if ((read_every_kth_image > 1) && ((++image_count % read_every_kth_image) != 1)) continue;

      // Check intrinsics matrix
      if (intrinsics_matrix.IsIdentity()) {
        RNFail("Unable to process scan without prior setting of intrinsics matrix in configuration file\n");
        return 0;
      }
      
      // Parse image names and alignment transformation
      RNScalar m[16];
      double depth_timestamp, color_timestamp;
      char depth_filename[2048], color_filename[2048];
      if (sscanf(buffer, "%s%s%lf%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, 
         depth_filename, &depth_timestamp, color_filename, &color_timestamp,
         &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], 
         &m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]) != (unsigned int) 21) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Create RGBD image
      // RGBDImage *image = new RGBDImage(color_filename, depth_filename, intrinsics_matrix, R4Matrix(m), image_width, image_height);
      RGBDImage *image = AllocateImage();
      image->SetNPixels(image_width, image_height);
      image->SetColorFilename(color_filename);
      image->SetDepthFilename(depth_filename);
      image->SetIntrinsics(intrinsics_matrix);
      image->SetCameraToWorld(R3Affine(R4Matrix(m), 0));
      InsertImage(image);
    }
    else if (!strcmp(cmd, "rectangle")) {
      // Parse surface
      char texture_filename[2048];
      RNScalar pixel_spacing, c[3], n[3], u[3], r[3];
      if (sscanf(buffer, "%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, texture_filename, &pixel_spacing, 
        &c[0], &c[1], &c[2], &n[0], &n[1], &n[2], &u[0], &u[1], &u[2], &r[0], &r[1], &r[2]) != (unsigned int) 15) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Create RGBD surface
      R3Point center(c);
      R3Vector axis1(u); axis1.Normalize();
      R3Vector normal(n); normal.Normalize();
      R3Vector axis0 = axis1 % normal; axis0.Normalize();
      // R3Mesh *mesh = new R3Mesh();
      // R3MeshVertex *v00 = mesh->CreateVertex(center - r[0]*axis0 - r[1]*axis1, normal, RNblack_rgb, R2Point(0,0));
      // R3MeshVertex *v10 = mesh->CreateVertex(center + r[0]*axis0 - r[1]*axis1, normal, RNblack_rgb, R2Point(r[0],0));
      // R3MeshVertex *v01 = mesh->CreateVertex(center - r[0]*axis0 + r[1]*axis1, normal, RNblack_rgb, R2Point(0,r[1]));
      // R3MeshVertex *v11 = mesh->CreateVertex(center + r[0]*axis0 + r[1]*axis1, normal, RNblack_rgb, R2Point(r[0],r[1]));
      // mesh->CreateFace(v00, v10, v11);
      // mesh->CreateFace(v00, v11, v01);
      // RGBDSurface *surface = new RGBDSurface(texture_filename, mesh, pixel_spacing);
      R3Rectangle *rectangle = new R3Rectangle(center, axis0, axis1, r[0], r[1]);
      RGBDSurface *surface = new RGBDSurface(texture_filename, rectangle, pixel_spacing);
      surface->thickness = r[2];
      InsertSurface(surface);
    }
    else if (!strcmp(cmd, "mesh")) {
      // Parse surface
      char texture_filename[2048], mesh_filename[2048];
      RNScalar pixel_spacing;
      if (sscanf(buffer, "%s%s%s%lf", cmd, texture_filename, mesh_filename, &pixel_spacing) != (unsigned int) 4) {
        RNFail("Error parsing line %d of configuration file\n", line_number);
        return 0;
      }

      // Read mesh
      R3Mesh *mesh = new R3Mesh();
      if (!mesh->ReadFile(mesh_filename)) {
        RNFail("Unable to read mesh file %s at line %d of configuration file\n", mesh_filename, line_number);
        return 0;
      }

      // Create surface      
      RGBDSurface *surface = new RGBDSurface(texture_filename, mesh, pixel_spacing);
      surface->SetMeshFilename(mesh_filename);
      InsertSurface(surface);
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x36e8, %rsp           # imm = 0x36E8
movl %edx, 0x1c(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0x94c56(%rip), %rsi     # 0xab1d0
leaq 0xf0(%rsp), %rdi
callq 0x648fc
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
leaq 0x14(%rsp), %rax
andl $0x0, (%rax)
pushq $0x1
popq %rbx
leaq 0x26e0(%rsp), %r13
leaq 0x1ae0(%rsp), %r12
leaq 0x1ee0(%rsp), %rbp
movl $0x0, 0x10(%rsp)
movq %r14, 0x28(%rsp)
movq %r13, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x11980
testq %rax, %rax
je 0x17461
movq %r13, %rdi
leaq 0x94e3e(%rip), %rsi     # 0xab420
movq %r12, %rdx
xorl %eax, %eax
callq 0x11590
cmpl $0x1, %eax
jne 0x16aa5
cmpb $0x23, 0x1ae0(%rsp)
je 0x16aa5
movabsq $0x74657361746164, %rax # imm = 0x74657361746164
cmpq %rax, 0x1ae0(%rsp)
jne 0x16657
movl $0x400, %edx            # imm = 0x400
movq %rbp, %rdi
xorl %esi, %esi
callq 0x11310
movq %r13, %rdi
leaq 0x92f57(%rip), %rsi     # 0xa9587
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11590
cmpl $0x2, %eax
jne 0x17466
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
callq *0x68(%rax)
jmp 0x16aa5
movq %r12, %rdi
leaq 0x91fd9(%rip), %rsi     # 0xa863a
pushq $0x9
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16938
movq %r12, %rdi
leaq 0x95a02(%rip), %rsi     # 0xac07d
pushq $0x5
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16938
movq %r15, %r14
movq %rbp, %r15
movq %r12, %rdi
leaq 0x91fa8(%rip), %rsi     # 0xa8643
pushq $0x11
popq %rbp
movq %rbp, %rdx
callq 0x115f0
testl %eax, %eax
je 0x16978
movq %r12, %rdi
leaq 0x91fa3(%rip), %rsi     # 0xa865b
movq %rbp, %rdx
callq 0x115f0
testl %eax, %eax
je 0x16a8c
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91de7(%rip), %xmm0    # 0xa84c0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
movq %r15, %rbp
je 0x169af
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91dd4(%rip), %xmm0    # 0xa84d0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x169af
movq %r12, %rdi
leaq 0x91f57(%rip), %rsi     # 0xa866c
pushq $0x13
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x169af
movq %r12, %rdi
leaq 0x91f50(%rip), %rsi     # 0xa867f
pushq $0x13
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x169af
movq %r12, %rdi
leaq 0x9197b(%rip), %rsi     # 0xa80c4
pushq $0x12
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x169af
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91d76(%rip), %xmm0    # 0xa84e0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x169af
movq %r12, %rdi
leaq 0x91f25(%rip), %rsi     # 0xa86a8
pushq $0xb
popq %rdx
callq 0x115f0
testl %eax, %eax
movq %r14, %r15
je 0x16adc
movq %r12, %rdi
leaq 0x91f02(%rip), %rsi     # 0xa86a2
pushq $0x11
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16adc
movq %r12, %rdi
leaq 0x91f7e(%rip), %rsi     # 0xa8738
pushq $0x12
popq %rdx
callq 0x115f0
testl %eax, %eax
movq 0x28(%rsp), %r14
je 0x16bdb
movq %r12, %rdi
leaq 0x91f59(%rip), %rsi     # 0xa8732
pushq $0x18
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16bdb
movq %r12, %rdi
leaq 0x97127(%rip), %rsi     # 0xad91a
pushq $0x5
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16d62
movq %r12, %rdi
leaq 0x9fce1(%rip), %rsi     # 0xb64ee
pushq $0x6
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16d62
movq %r12, %rdi
leaq 0x91f9a(%rip), %rsi     # 0xa87c1
pushq $0xe
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x16f22
movq %r12, %rdi
leaq 0x91fc9(%rip), %rsi     # 0xa880a
pushq $0x6
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x1710c
movq %r12, %rdi
leaq 0x91ff2(%rip), %rsi     # 0xa884d
pushq $0xa
popq %rdx
callq 0x115f0
testl %eax, %eax
je 0x172c2
movq %r12, %rdi
leaq 0x91815(%rip), %rsi     # 0xa808a
pushq $0x5
popq %rdx
callq 0x115f0
testl %eax, %eax
jne 0x16aa5
movq %r13, %rdi
leaq 0x91ff4(%rip), %rsi     # 0xa8883
movq %r12, %rdx
movq %rbp, %rcx
leaq 0xae0(%rsp), %r8
leaq 0x12e0(%rsp), %r9
xorl %eax, %eax
callq 0x11590
cmpl $0x4, %eax
jne 0x174dc
movl $0x138, %edi            # imm = 0x138
callq 0x115c0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x28a10
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xae0(%rsp), %rsi
callq *0x180(%rax)
testl %eax, %eax
je 0x174de
movl $0xa0, %edi
callq 0x115c0
movq 0x12e0(%rsp), %xmm0
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %rdx
callq 0x19c96
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
leaq 0xae0(%rsp), %rsi
callq *0xc8(%rax)
movq (%r15), %rax
movq %r15, %rdi
movq 0x20(%rsp), %rsi
jmp 0x17459
movl $0x400, %edx            # imm = 0x400
movq %rbp, %rdi
xorl %esi, %esi
callq 0x11310
movq %r13, %rdi
leaq 0x92c36(%rip), %rsi     # 0xa9587
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11590
cmpl $0x2, %eax
jne 0x17468
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
callq *0x38(%rax)
jmp 0x16aa5
movq %r13, %rdi
leaq 0x91cd2(%rip), %rsi     # 0xa8654
movq %r12, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
xorl %eax, %eax
callq 0x11590
cmpl $0x3, %eax
movq %r15, %rbp
movq %r14, %r15
movq 0x28(%rsp), %r14
je 0x16aa5
jmp 0x1748c
movq %r13, %rdi
leaq 0x92bce(%rip), %rsi     # 0xa9587
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11590
cmpl $0x2, %eax
jne 0x1748e
movq %r14, %r15
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91aed(%rip), %xmm0    # 0xa84d0
pmovmskb %xmm0, %eax
pushq $0x40
popq %rcx
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x16a7e
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91aba(%rip), %xmm0    # 0xa84c0
pmovmskb %xmm0, %eax
pushq $0x48
popq %rcx
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x16a7e
movq %r12, %rdi
leaq 0x91c4e(%rip), %rsi     # 0xa866c
pushq $0x13
popq %rdx
callq 0x115f0
pushq $0x50
popq %rcx
testl %eax, %eax
je 0x16a7e
movq %r12, %rdi
leaq 0x91c48(%rip), %rsi     # 0xa867f
pushq $0x13
popq %rdx
callq 0x115f0
pushq $0x58
popq %rcx
testl %eax, %eax
je 0x16a7e
movdqa 0x1ae0(%rsp), %xmm0
pcmpeqb 0x91a89(%rip), %xmm0    # 0xa84e0
pmovmskb %xmm0, %eax
pushq $0x40
popq %rcx
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x16a7e
movq %r12, %rdi
leaq 0x91655(%rip), %rsi     # 0xa80c4
pushq $0x12
popq %rdx
callq 0x115f0
pushq $0x60
popq %rcx
testl %eax, %eax
jne 0x16aa0
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
callq *(%rax,%rcx)
jmp 0x16aa0
cmpl $0x0, 0x18(%rsp)
movq %r15, %rbp
je 0x16aac
cmpl $0x0, 0x14(%rsp)
je 0x16aac
movq %r14, %r15
movq 0x28(%rsp), %r14
incl %ebx
jmp 0x165bf
movq %r13, %rdi
leaq 0x91b9e(%rip), %rsi     # 0xa8654
movq %r12, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
xorl %eax, %eax
callq 0x11590
cmpl $0x3, %eax
movq %r14, %r15
movq 0x28(%rsp), %r14
je 0x16aa5
jmp 0x17490
movq %r13, %rdi
leaq 0x92aa1(%rip), %rsi     # 0xa9587
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x11590
cmpl $0x2, %eax
movq 0x28(%rsp), %r14
jne 0x17492
movq %rbp, %rdi
leaq 0x97c08(%rip), %rsi     # 0xae713
callq 0x11700
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x17494
movq 0x58(%r15), %rdi
testq %rdi, %rdi
je 0x16b3b
leaq 0x91ba8(%rip), %rsi     # 0xa86d6
callq 0x11870
testl %eax, %eax
je 0x16c75
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0x91f66(%rip), %rsi     # 0xa8ab1
leaq 0xae8(%rsp), %rdx
leaq 0xaf0(%rsp), %rcx
leaq 0xaf8(%rsp), %r8
leaq 0xb00(%rsp), %r9
xorl %eax, %eax
leaq 0xb28(%rsp), %r10
pushq %r10
leaq 0xb28(%rsp), %r10
pushq %r10
leaq 0xb28(%rsp), %r10
pushq %r10
leaq 0xb28(%rsp), %r10
pushq %r10
leaq 0xb28(%rsp), %r10
pushq %r10
callq 0x11af0
addq $0x30, %rsp
cmpl $0x9, %eax
jne 0x1749d
leaq 0x12e0(%rsp), %rdi
leaq 0xae0(%rsp), %rsi
callq 0x6498c
leaq 0xf0(%rsp), %rdi
leaq 0x12e0(%rsp), %rsi
jmp 0x16d4e
movq %r13, %rdi
leaq 0x91b65(%rip), %rsi     # 0xa874a
movq %r12, %rdx
movq %rbp, %rcx
leaq 0x1ee8(%rsp), %r8
leaq 0x1ef0(%rsp), %r9
xorl %eax, %eax
leaq 0x1f20(%rsp), %r10
pushq %r10
leaq 0x1f20(%rsp), %r10
pushq %r10
leaq 0x1f20(%rsp), %r10
pushq %r10
leaq 0x1f20(%rsp), %r10
pushq %r10
leaq 0x1f20(%rsp), %r10
pushq %r10
leaq 0x1f20(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x30, %rsp
cmpl $0xa, %eax
jne 0x174b5
leaq 0xae0(%rsp), %rdi
movq %rbp, %rsi
callq 0x6498c
leaq 0xf0(%rsp), %rdi
leaq 0xae0(%rsp), %rsi
callq 0x651e4
jmp 0x16aa5
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0x91e26(%rip), %rsi     # 0xa8aab
leaq 0x12e8(%rsp), %rdx
leaq 0x2e8(%rsp), %rcx
leaq 0x1d8(%rsp), %r8
leaq 0x58(%rsp), %r9
xorl %eax, %eax
leaq 0x140(%rsp), %r10
pushq %r10
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0x160(%rsp), %r10
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0x100(%rsp), %r10
pushq %r10
leaq 0x68(%rsp), %r10
pushq %r10
leaq 0x188(%rsp), %r10
pushq %r10
callq 0x11af0
addq $0x40, %rsp
cmpl $0xb, %eax
jne 0x174b7
movq 0x1d0(%rsp), %xmm0
movsd 0x150(%rsp), %xmm2
movsd 0x50(%rsp), %xmm4
movsd 0x38(%rsp), %xmm5
subq $0x8, %rsp
xorps %xmm1, %xmm1
xorps %xmm3, %xmm3
xorps %xmm6, %xmm6
xorps %xmm7, %xmm7
leaq 0xae8(%rsp), %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
pushq %rax
callq 0x64956
popq %rax
popq %rcx
leaq 0xf0(%rsp), %rdi
leaq 0xae0(%rsp), %rsi
callq 0x651e4
movq 0x8(%rsp), %rdi
callq 0x115b0
jmp 0x16aa5
movl 0x1c(%rsp), %ecx
cmpl $0x2, %ecx
jl 0x16d81
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x16aa5
leaq 0xf0(%rsp), %rdi
callq 0x649f2
testl %eax, %eax
jne 0x174c0
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x91a2f(%rip), %rsi     # 0xa87d3
movq %r12, %rdx
movq %rbp, %rcx
leaq 0xae8(%rsp), %r8
leaq 0x2e8(%rsp), %r9
xorl %eax, %eax
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x80, %rsp
cmpl $0x13, %eax
jne 0x174d0
movq (%r15), %rax
movq %r15, %rdi
callq *0xd0(%rax)
movq %rax, %rdi
movq %rax, 0x8(%rsp)
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
callq *0x10(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xae0(%rsp), %rsi
callq *0x1a0(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x1a8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xf0(%rsp), %rsi
callq *0x78(%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x42d44
leaq 0x12e0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
callq 0x40ce0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0x12e0(%rsp), %rsi
callq *0x68(%rax)
leaq 0x12e0(%rsp), %rdi
callq 0x40d2e
movq (%r15), %rax
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq *0x10(%rax)
jmp 0x16aa5
movl 0x1c(%rsp), %ecx
cmpl $0x2, %ecx
jl 0x16f41
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x16aa5
leaq 0xf0(%rsp), %rdi
callq 0x649f2
testl %eax, %eax
jne 0x174d2
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x9186b(%rip), %rsi     # 0xa87cf
movq %r12, %rdx
movq %rbp, %rcx
leaq 0xae8(%rsp), %r8
leaq 0x12e8(%rsp), %r9
xorl %eax, %eax
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0x368(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x90, %rsp
cmpl $0x15, %eax
jne 0x174d4
movq (%r15), %rax
movq %r15, %rdi
callq *0xd0(%rax)
movq %rax, %rdi
movq %rax, 0x8(%rsp)
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
callq *0x10(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xae0(%rsp), %rsi
callq *0x1a0(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x1a8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0x12e0(%rsp), %rsi
callq *0x1b0(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0x2e0(%rsp), %rsi
callq *0x1b8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xf0(%rsp), %rsi
callq *0x78(%rax)
leaq 0x150(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x42d44
leaq 0x1d0(%rsp), %rdi
leaq 0x150(%rsp), %rsi
xorl %edx, %edx
callq 0x40ce0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0x1d0(%rsp), %rsi
callq *0x68(%rax)
leaq 0x1d0(%rsp), %rdi
jmp 0x16f0a
movl 0x1c(%rsp), %ecx
cmpl $0x2, %ecx
jl 0x1712b
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x16aa5
leaq 0xf0(%rsp), %rdi
callq 0x649f2
testl %eax, %eax
jne 0x174d6
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x916c2(%rip), %rsi     # 0xa8810
movq %r12, %rdx
movq %rbp, %rcx
leaq 0x58(%rsp), %r8
leaq 0xae8(%rsp), %r9
xorl %eax, %eax
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x360(%rsp), %r10
pushq %r10
leaq 0x1d8(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x90, %rsp
cmpl $0x15, %eax
jne 0x174d8
movq (%r15), %rax
movq %r15, %rdi
callq *0xd0(%rax)
movq %rax, %rdi
movq %rax, 0x8(%rsp)
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
callq *0x10(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xae0(%rsp), %rsi
callq *0x1a0(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x1a8(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xf0(%rsp), %rsi
callq *0x78(%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x42d44
leaq 0x12e0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
callq 0x40ce0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
leaq 0x12e0(%rsp), %rsi
callq *0x68(%rax)
jmp 0x16f02
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x91587(%rip), %rsi     # 0xa8857
movq %r12, %rdx
movq %rbp, %rcx
leaq 0x38(%rsp), %r8
leaq 0xae8(%rsp), %r9
xorl %eax, %eax
leaq 0x1e8(%rsp), %r10
pushq %r10
leaq 0x1e8(%rsp), %r10
pushq %r10
leaq 0x1e8(%rsp), %r10
pushq %r10
leaq 0x310(%rsp), %r10
pushq %r10
leaq 0x310(%rsp), %r10
pushq %r10
leaq 0x310(%rsp), %r10
pushq %r10
leaq 0x1328(%rsp), %r10
pushq %r10
leaq 0x1328(%rsp), %r10
pushq %r10
leaq 0x1328(%rsp), %r10
pushq %r10
leaq 0xb40(%rsp), %r10
pushq %r10
leaq 0xb40(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x60, %rsp
cmpl $0xf, %eax
jne 0x174da
leaq 0x50(%rsp), %rdi
leaq 0xae0(%rsp), %rsi
callq 0x45d7a
leaq 0x150(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x4659e
leaq 0x150(%rsp), %rdi
callq 0x4680e
leaq 0x38(%rsp), %rdi
leaq 0x12e0(%rsp), %rsi
callq 0x4659e
leaq 0x38(%rsp), %rdi
callq 0x4680e
leaq 0xd8(%rsp), %rdi
leaq 0x150(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x46bbe
leaq 0xd8(%rsp), %rdi
callq 0x4680e
pushq $0x78
popq %rdi
callq 0x115c0
movq 0x1d0(%rsp), %xmm0
movsd 0x1d8(%rsp), %xmm1
movq %rax, 0x8(%rsp)
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
leaq 0x150(%rsp), %rcx
callq 0x3bfd2
movl $0xa0, %edi
callq 0x115c0
movq 0x30(%rsp), %xmm0
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %rdx
callq 0x19b1e
movq 0x1e0(%rsp), %xmm0
movq 0x20(%rsp), %rsi
movq %xmm0, 0x98(%rsi)
movq (%r15), %rax
movq %r15, %rdi
callq *0x20(%rax)
jmp 0x16aa5
pushq $0x1
popq %rax
jmp 0x1747a
jmp 0x17468
leaq 0x9119e(%rip), %rdi     # 0xa860d
movl %ebx, %esi
xorl %eax, %eax
callq 0x6e732
xorl %eax, %eax
addq $0x36e8, %rsp           # imm = 0x36E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17468
jmp 0x17468
jmp 0x17468
jmp 0x17468
leaq 0x91218(%rip), %rdi     # 0xa86b3
jmp 0x174a4
leaq 0x9126b(%rip), %rdi     # 0xa870f
leaq 0x1ee0(%rsp), %rsi
xorl %eax, %eax
callq 0x6e732
jmp 0x17478
jmp 0x17468
leaq 0x91223(%rip), %rdi     # 0xa86e1
jmp 0x174c7
leaq 0x912a1(%rip), %rdi     # 0xa8768
xorl %eax, %eax
callq 0x6e732
jmp 0x17478
jmp 0x17468
jmp 0x174c0
jmp 0x17468
jmp 0x174c0
jmp 0x17468
jmp 0x17468
jmp 0x17468
leaq 0x913a8(%rip), %rdi     # 0xa888d
leaq 0xae0(%rsp), %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6e732
jmp 0x17478
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
jmp 0x1753f
jmp 0x17534
jmp 0x17511
movq %rax, %rbx
pushq $0x78
popq %rsi
jmp 0x17528
movq %rax, %rbx
movl $0xa0, %esi
movq 0x20(%rsp), %rdi
jmp 0x1752d
movq %rax, %rbx
movl $0x138, %esi            # imm = 0x138
movq 0x8(%rsp), %rdi
callq 0x115d0
jmp 0x17544
movq %rax, %rbx
leaq 0x12e0(%rsp), %rdi
callq 0x40d2e
movq %rbx, %rdi
callq 0x11a80