// File: /workspace/github_cpp_makefile_star2_O1/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 $0x36d8, %rsp           # imm = 0x36D8
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xa9394(%rip), %rsi     # 0xc02a8
leaq 0xc8(%rsp), %rdi
callq 0x6dfb2
xorl %eax, %eax
movl %eax, 0x18(%rsp)
movl %eax, 0x14(%rsp)
leaq 0x26d0(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x11970
testq %rax, %rax
je 0x18230
movq %r15, (%rsp)
movl %ebx, 0x1c(%rsp)
movl $0x1, %r13d
leaq 0xa95a2(%rip), %r12     # 0xc0500
leaq 0x26d0(%rsp), %rbp
leaq 0x2d0(%rsp), %rbx
leaq 0x1ed0(%rsp), %r15
movl $0x0, 0x10(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x11590
movl $0x2, %ecx
cmpl $0x1, %eax
jne 0x174c2
cmpb $0x23, 0x2d0(%rsp)
je 0x174c2
movabsq $0x74657361746164, %rax # imm = 0x74657361746164
cmpq %rax, 0x2d0(%rsp)
jne 0x17002
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x11310
movq %rbp, %rdi
leaq 0xa7683(%rip), %rsi     # 0xbe65a
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x11590
movl %eax, %r12d
cmpl $0x2, %eax
jne 0x1749b
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x68(%rax)
jmp 0x174ae
movq 0x2d0(%rsp), %rax
movabsq $0x65636e6575716573, %rdx # imm = 0x65636E6575716573
xorq %rdx, %rax
movzbl 0x2d8(%rsp), %edx
orq %rax, %rdx
je 0x1745e
movl 0x2d0(%rsp), %eax
movl $0x656d616e, %edx       # imm = 0x656D616E
xorl %edx, %eax
movzbl 0x2d4(%rsp), %edx
orl %eax, %edx
je 0x1745e
movq 0x2d8(%rsp), %rax
movabsq $0x6e6f6974756c6f73, %rdi # imm = 0x6E6F6974756C6F73
xorq %rdi, %rax
movq 0x2d0(%rsp), %rdx
movabsq $0x65725f6874706564, %rsi # imm = 0x65725F6874706564
xorq %rsi, %rdx
movzbl 0x2e0(%rsp), %esi
orq %rdx, %rsi
orq %rax, %rsi
je 0x174ec
movq 0x2d8(%rsp), %rax
xorq %rdi, %rax
movq 0x2d0(%rsp), %rdx
movabsq $0x65725f726f6c6f63, %rsi # imm = 0x65725F726F6C6F63
xorq %rsi, %rdx
movzbl 0x2e0(%rsp), %esi
orq %rdx, %rsi
orq %rax, %rsi
je 0x17667
movdqa 0x2d0(%rsp), %xmm0
pcmpeqb 0xa63f7(%rip), %xmm0    # 0xbd4c0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17514
movq 0x2d0(%rsp), %rax
movabsq $0x69645f726f6c6f63, %rdx # imm = 0x69645F726F6C6F63
xorq %rdx, %rax
movq 0x2d8(%rsp), %rdx
movabsq $0x79726f74636572, %rsi # imm = 0x79726F74636572
xorq %rsi, %rdx
orq %rax, %rdx
je 0x17514
movdqu 0x2d3(%rsp), %xmm0
pcmpeqb 0xa63b4(%rip), %xmm0    # 0xbd4d0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa63b3(%rip), %xmm1    # 0xbd4e0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17514
movdqu 0x2d3(%rsp), %xmm0
pcmpeqb 0xa639f(%rip), %xmm0    # 0xbd4f0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa639e(%rip), %xmm1    # 0xbd500
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17514
movzwl 0x2e0(%rsp), %eax
movd %eax, %xmm0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa637e(%rip), %xmm1    # 0xbd510
pcmpeqb 0xa6386(%rip), %xmm0    # 0xbd520
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17514
movdqa 0x2d0(%rsp), %xmm0
pcmpeqb 0xa6372(%rip), %xmm0    # 0xbd530
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17514
movq 0x2d0(%rsp), %rax
movabsq $0x69736e6972746e69, %rdx # imm = 0x69736E6972746E69
xorq %rdx, %rax
movq 0x2d3(%rsp), %rdx
movabsq $0x736369736e6972, %rsi # imm = 0x736369736E6972
xorq %rsi, %rdx
orq %rax, %rdx
je 0x17708
movq 0x2d8(%rsp), %rax
movabsq $0x736369736e697274, %rdx # imm = 0x736369736E697274
xorq %rdx, %rax
movq 0x2d0(%rsp), %rdx
movabsq $0x6e695f6874706564, %rsi # imm = 0x6E695F6874706564
xorq %rsi, %rdx
movzbl 0x2e0(%rsp), %esi
orq %rdx, %rsi
orq %rax, %rsi
je 0x17708
movzwl 0x2e0(%rsp), %eax
movd %eax, %xmm0
pcmpeqb 0xa62fe(%rip), %xmm0    # 0xbd550
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa62dd(%rip), %xmm1    # 0xbd540
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17813
movabsq $0x6e695f6874706564, %rax # imm = 0x6E695F6874706564
movq %rax, %xmm0
movabsq $0x736369736e697274, %rax # imm = 0x736369736E697274
movq %rax, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq 0x2e0(%rsp), %xmm1
pcmpeqb 0x2d0(%rsp), %xmm0
pcmpeqb 0xa62ae(%rip), %xmm1    # 0xbd560
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x17813
movl 0x2d0(%rsp), %eax
movl $0x6e616373, %edx       # imm = 0x6E616373
xorl %edx, %eax
movzbl 0x2d4(%rsp), %edx
orl %eax, %edx
je 0x178de
movl 0x2d0(%rsp), %eax
movl $0x67616d69, %edx       # imm = 0x67616D69
xorl %edx, %eax
movzwl 0x2d4(%rsp), %edx
xorl $0x65, %edx
orl %eax, %edx
je 0x178de
movq 0x2d0(%rsp), %rax
movabsq $0x5f64656c6562616c, %rdx # imm = 0x5F64656C6562616C
xorq %rdx, %rax
movq 0x2d6(%rsp), %rdx
movabsq $0x6567616d695f64, %rsi # imm = 0x6567616D695F64
xorq %rsi, %rdx
orq %rax, %rdx
leaq 0xed0(%rsp), %r9
leaq 0x16d0(%rsp), %r11
je 0x17bbf
movl 0x2d0(%rsp), %eax
movl $0x6d617266, %edx       # imm = 0x6D617266
xorl %edx, %eax
movzwl 0x2d4(%rsp), %edx
xorl $0x65, %edx
orl %eax, %edx
je 0x17c26
movq 0x2d0(%rsp), %rax
movabsq $0x6c676e6174636572, %rcx # imm = 0x6C676E6174636572
xorq %rcx, %rax
movzwl 0x2d8(%rsp), %ecx
xorq $0x65, %rcx
orq %rax, %rcx
je 0x17c85
movl 0x2d0(%rsp), %eax
movl $0x6873656d, %ecx       # imm = 0x6873656D
xorl %ecx, %eax
movzbl 0x2d4(%rsp), %ecx
orl %eax, %ecx
jne 0x174c0
movq %rbp, %rdi
leaq 0xa6549(%rip), %rsi     # 0xbd903
movq %rbx, %rdx
movq %r15, %rcx
movq %r9, %r8
movq %r11, %r9
xorl %eax, %eax
callq 0x11590
cmpl $0x4, %eax
jne 0x181ce
movl $0x138, %edi            # imm = 0x138
callq 0x115b0
movq %rax, %r12
movq %rax, %rdi
callq 0x2b988
movq (%r12), %rax
movq %r12, %rdi
leaq 0xed0(%rsp), %rsi
callq *0x180(%rax)
movl %eax, 0x8(%rsp)
testl %eax, %eax
je 0x181f3
movl $0xa0, %edi
callq 0x115b0
movq 0x16d0(%rsp), %xmm0
movq %rax, 0x20(%rsp)
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1ae02
movq 0x20(%rsp), %r12
movq (%r12), %rax
movq %r12, %rdi
leaq 0xed0(%rsp), %rsi
callq *0xc8(%rax)
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x20(%rax)
jmp 0x1820c
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x11310
movq %rbp, %rdi
leaq 0xa71e3(%rip), %rsi     # 0xbe65a
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x11590
movl %eax, %r12d
cmpl $0x2, %eax
jne 0x1749d
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x38(%rax)
jmp 0x174ae
jmp 0x1749d
leaq 0xa61e9(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0x2, %r12d
leaq 0xa9042(%rip), %r12     # 0xc0500
jne 0x174c2
xorl %ecx, %ecx
testb $0x1, %cl
jne 0x18237
movq %rbp, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x11970
incl %r13d
testq %rax, %rax
jne 0x16f7e
jmp 0x18230
movq %rbp, %rdi
leaq 0xa61de(%rip), %rsi     # 0xbd6d4
movq %rbx, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
xorl %eax, %eax
callq 0x11590
cmpl $0x3, %eax
je 0x174c0
jmp 0x176a0
movq %rbp, %rdi
leaq 0xa713c(%rip), %rsi     # 0xbe65a
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x11590
movl %eax, %r12d
cmpl $0x2, %eax
jne 0x176bb
movq 0x2d0(%rsp), %rax
movabsq $0x69645f726f6c6f63, %rcx # imm = 0x69645F726F6C6F63
xorq %rcx, %rax
movq 0x2d8(%rsp), %rcx
movabsq $0x79726f74636572, %rdx # imm = 0x79726F74636572
xorq %rdx, %rcx
orq %rax, %rcx
je 0x176c0
movq 0x2d0(%rsp), %rax
movabsq $0x69645f6874706564, %rcx # imm = 0x69645F6874706564
xorq %rcx, %rax
movq 0x2d8(%rsp), %rcx
xorq %rdx, %rcx
orq %rax, %rcx
je 0x176d2
movdqu 0x2d3(%rsp), %xmm0
pcmpeqb 0xa5f2c(%rip), %xmm0    # 0xbd4d0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa5f2b(%rip), %xmm1    # 0xbd4e0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x176e4
movdqu 0x2d3(%rsp), %xmm0
pcmpeqb 0xa5f17(%rip), %xmm0    # 0xbd4f0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa5f16(%rip), %xmm1    # 0xbd500
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x176f6
movdqa 0x2d0(%rsp), %xmm0
pcmpeqb 0xa5f22(%rip), %xmm0    # 0xbd530
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x176c0
movzwl 0x2e0(%rsp), %eax
movd %eax, %xmm0
movdqa 0x2d0(%rsp), %xmm1
pcmpeqb 0xa5ed6(%rip), %xmm1    # 0xbd510
pcmpeqb 0xa5ede(%rip), %xmm0    # 0xbd520
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x174ae
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x60(%rax)
jmp 0x174ae
cmpl $0x0, 0x18(%rsp)
je 0x17679
cmpl $0x0, 0x14(%rsp)
jne 0x174c0
movq %rbp, %rdi
leaq 0xa6051(%rip), %rsi     # 0xbd6d4
movq %rbx, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
xorl %eax, %eax
callq 0x11590
cmpl $0x3, %eax
je 0x174c0
leaq 0xa5fe6(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
jmp 0x174c2
jmp 0x1749d
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x40(%rax)
jmp 0x174ae
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x48(%rax)
jmp 0x174ae
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x50(%rax)
jmp 0x174ae
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x58(%rax)
jmp 0x174ae
movq %rbp, %rdi
leaq 0xa6f48(%rip), %rsi     # 0xbe65a
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x11590
cmpl $0x2, %eax
jne 0x1780e
movq %r15, %rdi
leaq 0xac301(%rip), %rsi     # 0xc3a33
callq 0x11710
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x178c8
movq (%rsp), %rax
movq 0x58(%rax), %rdi
testq %rdi, %rdi
je 0x17766
leaq 0xa5ffd(%rip), %rsi     # 0xbd756
callq 0x11850
testl %eax, %eax
je 0x1793f
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0xa63bb(%rip), %rsi     # 0xbdb31
leaq 0xed8(%rsp), %rdx
leaq 0xee0(%rsp), %rcx
leaq 0xee8(%rsp), %r8
leaq 0xef0(%rsp), %r9
xorl %eax, %eax
leaq 0xf18(%rsp), %r10
pushq %r10
leaq 0xf18(%rsp), %r10
pushq %r10
leaq 0xf18(%rsp), %r10
pushq %r10
leaq 0xf18(%rsp), %r10
pushq %r10
leaq 0xf18(%rsp), %r10
pushq %r10
callq 0x11ae0
addq $0x30, %rsp
movl %eax, %r12d
cmpl $0x9, %eax
jne 0x17925
leaq 0x16d0(%rsp), %rdi
leaq 0xed0(%rsp), %rsi
callq 0x6e042
leaq 0xc8(%rsp), %rdi
leaq 0x16d0(%rsp), %rsi
callq 0x6e9fc
jmp 0x17936
jmp 0x176a0
movq %rbp, %rdi
leaq 0xa5fad(%rip), %rsi     # 0xbd7ca
movq %rbx, %rdx
movq %r15, %rcx
leaq 0x1ed8(%rsp), %r8
leaq 0x1ee0(%rsp), %r9
xorl %eax, %eax
leaq 0x1f10(%rsp), %r10
pushq %r10
leaq 0x1f10(%rsp), %r10
pushq %r10
leaq 0x1f10(%rsp), %r10
pushq %r10
leaq 0x1f10(%rsp), %r10
pushq %r10
leaq 0x1f10(%rsp), %r10
pushq %r10
leaq 0x1f10(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x30, %rsp
movl %eax, %r12d
cmpl $0xa, %eax
jne 0x178a9
leaq 0xed0(%rsp), %rdi
movq %r15, %rsi
callq 0x6e042
leaq 0xc8(%rsp), %rdi
leaq 0xed0(%rsp), %rsi
callq 0x6e9fc
jmp 0x178ba
leaq 0xa5ddd(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0xa, %r12d
jmp 0x174b7
leaq 0xa5e64(%rip), %rdi     # 0xbd733
movq %r15, %rsi
xorl %eax, %eax
callq 0x79092
jmp 0x176b1
movl 0x1c(%rsp), %esi
cmpl $0x2, %esi
jl 0x178fd
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %esi
cmpl $0x1, %edx
jne 0x174c2
leaq 0xc8(%rsp), %rdi
callq 0x6e0ba
testl %eax, %eax
je 0x17a2e
leaq 0xa5ecf(%rip), %rdi     # 0xbd7e8
xorl %eax, %eax
callq 0x79092
jmp 0x176b1
leaq 0xa5e63(%rip), %rdi     # 0xbd78f
movq %r15, %rsi
xorl %eax, %eax
callq 0x79092
cmpl $0x9, %r12d
jmp 0x17c0a
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0xa61dc(%rip), %rsi     # 0xbdb2b
leaq 0x16d8(%rsp), %rdx
leaq 0x6d8(%rsp), %rcx
leaq 0x1c8(%rsp), %r8
leaq 0x38(%rsp), %r9
xorl %eax, %eax
leaq 0x118(%rsp), %r10
pushq %r10
leaq 0x128(%rsp), %r10
pushq %r10
leaq 0x138(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0xe0(%rsp), %r10
pushq %r10
leaq 0x178(%rsp), %r10
pushq %r10
callq 0x11ae0
addq $0x40, %rsp
movl %eax, %r12d
cmpl $0xb, %eax
jne 0x17bf8
movq 0x1c0(%rsp), %xmm0
movsd 0x140(%rsp), %xmm2
movsd 0x30(%rsp), %xmm4
movsd 0xb0(%rsp), %xmm5
subq $0x8, %rsp
pxor %xmm1, %xmm1
xorps %xmm3, %xmm3
xorps %xmm6, %xmm6
xorps %xmm7, %xmm7
leaq 0xed8(%rsp), %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
pushq %rax
callq 0x6e00c
addq $0x10, %rsp
leaq 0xc8(%rsp), %rdi
leaq 0xed0(%rsp), %rsi
callq 0x6e9fc
jmp 0x17c06
subq $0x8, %rsp
movq %rbp, %rdi
leaq 0xa5e17(%rip), %rsi     # 0xbd853
movq %rbx, %rdx
movq %r15, %rcx
leaq 0xed8(%rsp), %r8
leaq 0x6d8(%rsp), %r9
xorl %eax, %eax
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x80, %rsp
movl %eax, 0x8(%rsp)
cmpl $0x13, %eax
jne 0x17c5f
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0xd0(%rax)
movq %rax, %r12
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
movq %r12, %rdi
callq *0x10(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xed0(%rsp), %rsi
callq *0x1a0(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x1a8(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xc8(%rsp), %rsi
callq *0x78(%rax)
leaq 0x1c0(%rsp), %rdi
leaq 0x6d0(%rsp), %rsi
callq 0x48836
leaq 0x16d0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
xorl %edx, %edx
callq 0x463b6
movq (%r12), %rax
movq %r12, %rdi
leaq 0x16d0(%rsp), %rsi
callq *0x68(%rax)
leaq 0x16d0(%rsp), %rdi
callq 0x46404
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x10(%rax)
leaq 0xa8946(%rip), %r12     # 0xc0500
jmp 0x17c70
movl 0x1c(%rsp), %esi
cmpl $0x2, %esi
jl 0x17bde
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %esi
cmpl $0x1, %edx
jne 0x174c2
leaq 0xc8(%rsp), %rdi
callq 0x6e0ba
testl %eax, %eax
je 0x17e1e
jmp 0x17912
leaq 0xa5b62(%rip), %rdi     # 0xbd761
xorl %eax, %eax
callq 0x79092
cmpl $0xb, %r12d
leaq 0xa88ef(%rip), %r12     # 0xc0500
jne 0x176b1
movq 0x8(%rsp), %rdi
callq 0x115a0
jmp 0x174c0
movl 0x1c(%rsp), %esi
cmpl $0x2, %esi
jl 0x17c45
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
cltd
idivl %esi
cmpl $0x1, %edx
jne 0x174c2
leaq 0xc8(%rsp), %rdi
callq 0x6e0ba
testl %eax, %eax
je 0x18010
jmp 0x17912
leaq 0xa5a27(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0x13, 0x8(%rsp)
je 0x174c0
jmp 0x174c2
subq $0x8, %rsp
movq %rbp, %rdi
leaq 0xa5c44(%rip), %rsi     # 0xbd8d7
movq %rbx, %rdx
movq %r15, %rcx
leaq 0x30(%rsp), %r8
xorl %eax, %eax
leaq 0x1d8(%rsp), %r10
pushq %r10
leaq 0x1d8(%rsp), %r10
pushq %r10
leaq 0x1d8(%rsp), %r10
pushq %r10
leaq 0x700(%rsp), %r10
pushq %r10
leaq 0x700(%rsp), %r10
pushq %r10
leaq 0x700(%rsp), %r10
pushq %r10
leaq 0x1718(%rsp), %r10
pushq %r10
leaq 0x1718(%rsp), %r10
pushq %r10
pushq %r11
leaq 0xf30(%rsp), %r10
pushq %r10
leaq 0xf30(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x60, %rsp
movl %eax, 0x8(%rsp)
cmpl $0xf, %eax
jne 0x17fea
leaq 0x30(%rsp), %rdi
leaq 0xed0(%rsp), %rsi
callq 0x4be74
leaq 0x140(%rsp), %r12
movq %r12, %rdi
leaq 0x6d0(%rsp), %rsi
callq 0x4c970
movq %r12, %rdi
callq 0x4cc00
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
leaq 0x16d0(%rsp), %rsi
callq 0x4c970
movq %r12, %rdi
callq 0x4cc00
leaq 0x128(%rsp), %r12
movq %r12, %rdi
leaq 0x140(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x4d232
movq %r12, %rdi
callq 0x4cc00
movl $0x78, %edi
callq 0x115b0
movq 0x1c0(%rsp), %xmm0
movq 0x1c8(%rsp), %xmm1
movq %rax, 0x20(%rsp)
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
leaq 0x140(%rsp), %rcx
callq 0x413ec
movl $0xa0, %edi
callq 0x115b0
movq %rax, %r12
movq 0x28(%rsp), %xmm0
movq %rax, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
callq 0x1ac82
movq 0x1d0(%rsp), %xmm0
movq %xmm0, 0x98(%r12)
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x20(%rax)
leaq 0xa86e7(%rip), %r12     # 0xc0500
jmp 0x17ffb
subq $0x8, %rsp
movq %rbp, %rdi
leaq 0xa5a23(%rip), %rsi     # 0xbd84f
movq %rbx, %rdx
movq %r15, %rcx
leaq 0xed8(%rsp), %r8
leaq 0x16d8(%rsp), %r9
xorl %eax, %eax
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0x758(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x90, %rsp
movl %eax, 0x8(%rsp)
cmpl $0x15, %eax
jne 0x181a8
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0xd0(%rax)
movq %rax, %r12
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
movq %r12, %rdi
callq *0x10(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xed0(%rsp), %rsi
callq *0x1a0(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x1a8(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0x16d0(%rsp), %rsi
callq *0x1b0(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0x6d0(%rsp), %rsi
callq *0x1b8(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xc8(%rsp), %rsi
callq *0x78(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x48836
leaq 0x1c0(%rsp), %rdi
leaq 0x140(%rsp), %rsi
xorl %edx, %edx
callq 0x463b6
movq (%r12), %rax
movq %r12, %rdi
leaq 0x1c0(%rsp), %rsi
callq *0x68(%rax)
leaq 0x1c0(%rsp), %rdi
callq 0x46404
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x10(%rax)
leaq 0xa851b(%rip), %r12     # 0xc0500
jmp 0x181b9
leaq 0xa569c(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0xf, 0x8(%rsp)
je 0x174c0
jmp 0x174c2
subq $0x8, %rsp
movq %rbp, %rdi
leaq 0xa5872(%rip), %rsi     # 0xbd890
movq %rbx, %rdx
movq %r15, %rcx
leaq 0x38(%rsp), %r8
leaq 0xed8(%rsp), %r9
xorl %eax, %eax
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x750(%rsp), %r10
pushq %r10
leaq 0x1c8(%rsp), %r10
pushq %r10
callq 0x11590
addq $0x90, %rsp
movl %eax, 0x8(%rsp)
cmpl $0x15, %eax
jne 0x181d3
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0xd0(%rax)
movq %rax, %r12
movl 0x18(%rsp), %esi
movl 0x14(%rsp), %edx
movq (%rax), %rax
movq %r12, %rdi
callq *0x10(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xed0(%rsp), %rsi
callq *0x1a0(%rax)
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x1a8(%rax)
movq (%r12), %rax
movq %r12, %rdi
leaq 0xc8(%rsp), %rsi
callq *0x78(%rax)
leaq 0x1c0(%rsp), %rdi
leaq 0x6d0(%rsp), %rsi
callq 0x48836
leaq 0x16d0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
xorl %edx, %edx
callq 0x463b6
movq (%r12), %rax
movq %r12, %rdi
leaq 0x16d0(%rsp), %rsi
callq *0x68(%rax)
leaq 0x16d0(%rsp), %rdi
callq 0x46404
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
callq *0x10(%rax)
jmp 0x181e4
leaq 0xa54de(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0x15, 0x8(%rsp)
je 0x174c0
jmp 0x174c2
jmp 0x176a0
leaq 0xa54b3(%rip), %rdi     # 0xbd68d
movl %r13d, %esi
xorl %eax, %eax
callq 0x79092
movl $0x1, %ecx
cmpl $0x15, 0x8(%rsp)
jmp 0x174b7
leaq 0xa5713(%rip), %rdi     # 0xbd90d
leaq 0xed0(%rsp), %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x79092
cmpl $0x0, 0x8(%rsp)
je 0x1821f
leaq 0xa82e6(%rip), %r12     # 0xc0500
jmp 0x174c0
movl $0x1, %ecx
leaq 0xa82d5(%rip), %r12     # 0xc0500
jmp 0x174c2
movl $0x1, %eax
jmp 0x18239
xorl %eax, %eax
addq $0x36d8, %rsp           # imm = 0x36D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1826e
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
jmp 0x18279
movq %rax, %rbx
movl $0xa0, %esi
jmp 0x18297
movq %rax, %rbx
movl $0x78, %esi
jmp 0x18288
movq %rax, %rbx
leaq 0x16d0(%rsp), %rdi
callq 0x46404
jmp 0x1829f
movq %rax, %rbx
movl $0xa0, %esi
movq 0x20(%rsp), %rdi
jmp 0x1829a
movq %rax, %rbx
movl $0x138, %esi            # imm = 0x138
movq %r12, %rdi
callq 0x115c0
movq %rbx, %rdi
callq 0x11a70
nop