// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::ReadPlyStream(_IO_FILE*)
int R3Mesh::
ReadPlyStream(FILE *fp)
{
  int i,j;
  PlyFile *ply;
  int nelems;
  PlyProperty **plist;
  char **elist;
  int file_type;
  int nprops;
  int num_elems;
  char *elem_name;
  float version;
  int num_rows = 0;
  int num_cols = 0;

  typedef struct PlyVertex {
    float x, y, z;
    float nx, ny, nz;
    float tx, ty;
    unsigned char red, green, blue;
  } PlyVertex;

  typedef struct PlyFace {
    unsigned char nverts;
    int *verts;
    int material;
    int segment;
    int category;
  } PlyFace;

  typedef struct PlyRangeGrid {
    unsigned char nverts;
    int *verts;
  } PlyRangeGrid;

  // List of property information for a vertex 
  static PlyProperty vert_props[] = { 
    {(char *) "x", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,x), 0, 0, 0, 0},
    {(char *) "y", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,y), 0, 0, 0, 0},
    {(char *) "z", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,z), 0, 0, 0, 0},
    {(char *) "nx", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,nx), 0, 0, 0, 0},
    {(char *) "ny", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,ny), 0, 0, 0, 0},
    {(char *) "nz", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,nz), 0, 0, 0, 0},
    {(char *) "tx", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,tx), 0, 0, 0, 0},
    {(char *) "ty", PLY_FLOAT, PLY_FLOAT, offsetof(PlyVertex,ty), 0, 0, 0, 0},
    {(char *) "red", PLY_UCHAR, PLY_UCHAR, offsetof(PlyVertex,red), 0, 0, 0, 0},
    {(char *) "green", PLY_UCHAR, PLY_UCHAR, offsetof(PlyVertex,green), 0, 0, 0, 0},
    {(char *) "blue", PLY_UCHAR, PLY_UCHAR, offsetof(PlyVertex,blue), 0, 0, 0, 0}
  };

  // List of property information for a face 
  static PlyProperty face_props[] = { 
    {(char *) "vertex_indices", PLY_INT, PLY_INT, offsetof(PlyFace,verts), 1, PLY_UCHAR, PLY_UCHAR, offsetof(PlyFace,nverts)},
    {(char *) "vertex_index", PLY_INT, PLY_INT, offsetof(PlyFace,verts), 1, PLY_UCHAR, PLY_UCHAR, offsetof(PlyFace,nverts)},
    {(char *) "material_id", PLY_INT, PLY_INT, offsetof(PlyFace,material), 0, 0, 0, 0},
    {(char *) "segment_id", PLY_INT, PLY_INT, offsetof(PlyFace,segment), 0, 0, 0, 0},
    {(char *) "category_id", PLY_INT, PLY_INT, offsetof(PlyFace,category), 0, 0, 0, 0}
  };

  // List of property information for a range_grid
  static PlyProperty range_grid_props[] = { 
    {(char *) "vertex_indices", PLY_INT, PLY_INT, offsetof(PlyFace,verts), 1, PLY_UCHAR, PLY_UCHAR, offsetof(PlyFace,nverts)},
  };

  // Read PLY header
  ply = ply_read (fp, &nelems, &elist);
  if (!ply) {
    RNFail("Unable to read ply file header");
    fclose(fp);
    return 0;
  }
  
  // Get header info
  ply_get_info (ply, &version, &file_type);

  // Read all elements
  for (i = 0; i < nelems; i++) {
    // Get the description of the element 
    elem_name = elist[i];
    plist = ply_get_element_description (ply, elem_name, &num_elems, &nprops);

    // Check element type
    if (equal_strings ("vertex", elem_name)) {
      // Allocate block of vertices
      vertex_block = new R3MeshVertex [num_elems];

      // Resize array of vertices
      vertices.Resize(num_elems);

      // set up for getting vertex elements 
      RNBoolean has_normals = 0;
      RNBoolean has_texcoords = 0;
      RNBoolean has_colors = 0;
      for (j = 0; j < nprops; j++) {
	if (equal_strings("x", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[0]);
	else if (equal_strings("y", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[1]);
	else if (equal_strings("z", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[2]);
	else if (equal_strings("nx", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[3]); 
	else if (equal_strings("ny", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[4]); 
	else if (equal_strings("nz", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[5]);
	else if (equal_strings("tx", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[6]); 
	else if (equal_strings("ty", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[7]); 
	else if (equal_strings("red", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[8]); 
	else if (equal_strings("green", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[9]); 
	else if (equal_strings("blue", plist[j]->name)) ply_get_property (ply, elem_name, &vert_props[10]);
	if (equal_strings("nx", plist[j]->name)) has_normals = 1;
	else if (equal_strings("tx", plist[j]->name)) has_texcoords = 1;
	else if (equal_strings("red", plist[j]->name)) has_colors = 1;
      }

      // grab all the vertex elements 
      for (j = 0; j < num_elems; j++) {
        // Read vertex into local struct
        PlyVertex plyvertex;
        ply_get_element(ply, (void *) &plyvertex);

        // Create mesh vertex
        R3Point position(plyvertex.x, plyvertex.y, plyvertex.z);
        R3MeshVertex *v = CreateVertex(position, &vertex_block[j]);
        if (has_normals) {
          R3Vector normal(plyvertex.nx, plyvertex.ny, plyvertex.nz);
          SetVertexNormal(v, normal);
        }
        if (has_texcoords) {
          R2Point texcoords(plyvertex.tx, plyvertex.ty);
          SetVertexTextureCoords(v, texcoords);
        }
        if (has_colors) {
          RNRgb color(plyvertex.red/255.0, plyvertex.green/255.0, plyvertex.blue/255.0);
          SetVertexColor(v, color);
        }
      }
    }
    else if (equal_strings ("face", elem_name)) {
      // Resize array of faces
      faces.Resize(num_elems);

      // set up for getting face elements 
      for (j = 0; j < nprops; j++) {
	if (equal_strings("vertex_indices", plist[j]->name)) ply_get_property (ply, elem_name, &face_props[0]);
	else if (equal_strings("vertex_index", plist[j]->name)) ply_get_property (ply, elem_name, &face_props[1]);
	else if (equal_strings("material_id", plist[j]->name)) ply_get_property (ply, elem_name, &face_props[2]);
	else if (equal_strings("segment_id", plist[j]->name)) ply_get_property (ply, elem_name, &face_props[3]);
	else if (equal_strings("category_id", plist[j]->name)) ply_get_property (ply, elem_name, &face_props[4]);
      }

      // Create stuff for degenerate triangles
      RNArray<R3MeshVertex *> degenerate_triangle_vertices;
      int *degenerate_triangle_materials = new int [ num_elems ];
      int *degenerate_triangle_segments = new int [ num_elems ];
      int *degenerate_triangle_categories = new int [ num_elems ];
      int num_degenerate_triangles = 0;

      // grab all the face elements 
      for (j = 0; j < num_elems; j++) {
        // Read face into local struct
        PlyFace plyface;
        plyface.nverts = 0;
        plyface.verts = NULL;
        plyface.material = -1;
        plyface.segment = -1;
        plyface.category = -1;
        ply_get_element(ply, (void *) &plyface);

        // Create mesh face(s)
        R3MeshVertex *v1 = vertices[plyface.verts[0]];
        for (int k = 2; k < plyface.nverts; k++) {
          // Get vertices
          R3MeshVertex *v2 = vertices[plyface.verts[k-1]];
          R3MeshVertex *v3 = vertices[plyface.verts[k]];

          // Check plyface
          assert(plyface.verts[0] >= 0);
          assert(plyface.verts[k-1] >= 0);
          assert(plyface.verts[k] >= 0);
          assert(plyface.verts[0] < vertices.NEntries());
          assert(plyface.verts[k-1] < vertices.NEntries());
          assert(plyface.verts[k] < vertices.NEntries());

          // Check vertices
          if ((v1 == v2) || (v2 == v3) || (v1 == v3)) continue;

          // Create face
          R3MeshFace *f = CreateFace(v1, v2, v3);
          if (f) {
            // Set material/segment/category
            SetFaceMaterial(f, plyface.material);
            SetFaceSegment(f, plyface.segment);
            SetFaceCategory(f, plyface.category);
          }
          else {
            // Must have been degeneracy (e.g., three faces sharing an edge)
            // Remember for later processing (to preserve vertex indices)
            degenerate_triangle_vertices.Insert(v1);
            degenerate_triangle_vertices.Insert(v2);
            degenerate_triangle_vertices.Insert(v3);
            degenerate_triangle_materials[num_degenerate_triangles] = plyface.material;
            degenerate_triangle_segments[num_degenerate_triangles] = plyface.segment;
            degenerate_triangle_categories[num_degenerate_triangles] = plyface.category;
            num_degenerate_triangles++;
          }
        }

        // Free face data allocated by ply
        if (plyface.verts) free(plyface.verts);
      }
      
      // Create degenerate triangles (do this at end to preserve face ordering)
      for (int i = 0; i < num_degenerate_triangles; i++) {
        R3MeshVertex *v1 = degenerate_triangle_vertices.Kth(3*i + 0);
        R3MeshVertex *v2 = degenerate_triangle_vertices.Kth(3*i + 1);
        R3MeshVertex *v3 = degenerate_triangle_vertices.Kth(3*i + 2);
        R3MeshFace *f = CreateFace(v1, v2, v3);
        if (!f) {
          f = CreateFace(v1, v3, v2);
          if (!f) {
            // Note: these vertices are allocated separately, and so they will not be deleted (memory leak)
            R3MeshVertex *v1a = CreateVertex(VertexPosition(v1));
            R3MeshVertex *v2a = CreateVertex(VertexPosition(v2));
            R3MeshVertex *v3a = CreateVertex(VertexPosition(v3));
            f = CreateFace(v1a, v2a, v3a);
          }
        }
        if (f) {
          SetFaceMaterial(f, degenerate_triangle_materials[i]);
          SetFaceSegment(f, degenerate_triangle_segments[i]);
          SetFaceCategory(f, degenerate_triangle_categories[i]);
        }
      }

      // Delete memory for degenerate triangles
      delete [] degenerate_triangle_materials;
      delete [] degenerate_triangle_segments;
      delete [] degenerate_triangle_categories;
    }
    else if (equal_strings ("range_grid", elem_name)) {
      // Get num_cols and num_rows for range_grid
      int ninfo = 0;
      char **info = ply_get_obj_info(ply, &ninfo);
      for (int i = 0; i < ninfo; i++) {
        char *str = RNStrdup(info[i]);
        char *strp = strtok(str, " \n\t");
        if (strp) {
          if (!strcmp(strp, "num_rows")) {
            strp = strtok(NULL, " \n\t");
            if (strp) num_rows = atoi(strp);
          }
          else if (!strcmp(strp, "num_cols")) {
            strp = strtok(NULL, " \n\t");
            if (strp) num_cols = atoi(strp);
          }
        }
        free(str);
      }

      // check num_cols and num_rows
      if ((num_cols > 0) && (num_rows > 0) && (num_cols * num_rows == num_elems)) {
        // Allocate vertex grid
        R3MeshVertex **vertex_grid = new R3MeshVertex * [num_elems];
        for (j = 0; j < num_elems; j++) vertex_grid[j] = NULL;

        // set up for getting range grid elements 
        for (j = 0; j < nprops; j++) {
          if (equal_strings("vertex_indices", plist[j]->name)) ply_get_property (ply, elem_name, &range_grid_props[0]);
        }

        // grab all the range grid vertices
        for (j = 0; j < num_elems; j++) {
          // Read face into local struct
          PlyRangeGrid ply_range_grid;
          ply_range_grid.nverts = 0;
          ply_range_grid.verts = NULL;
          ply_get_element(ply, (void *) &ply_range_grid);
          if (!ply_range_grid.verts) continue;
          if (ply_range_grid.nverts == 0) continue;
          vertex_grid[j] = vertices[ply_range_grid.verts[0]];
          free(ply_range_grid.verts);
        }

        // create faces
        for (int row = 0; row < num_rows-1; row++) {
          for (int col = 0; col < num_cols-1; col++) {
            R3MeshVertex *v00 = vertex_grid[(row)*num_cols + (col)];
            R3MeshVertex *v01 = vertex_grid[(row+1)*num_cols + (col)];
            R3MeshVertex *v10 = vertex_grid[(row)*num_cols + (col+1)];
            R3MeshVertex *v11 = vertex_grid[(row+1)*num_cols + (col+1)];
            if (v00) {
              if (v01) {
                if (v10) {
                  if (v11) {
                    CreatePlyRangeGridFace(this, v00, v10, v11);
                    CreatePlyRangeGridFace(this, v00, v11, v01);
                  }
                  else {
                    CreatePlyRangeGridFace(this, v00, v10, v01);
                  }
                }
                else {
                  if (v11) {
                    CreatePlyRangeGridFace(this, v00, v11, v01);
                  }
                }
              }
              else {
                if (v10) {
                  if (v11) {
                    CreatePlyRangeGridFace(this, v00, v10, v11);
                  }
                }
              }
            }
            else {
              if (v01) {
                if (v10) {
                  if (v11) {
                    CreatePlyRangeGridFace(this, v10, v11, v01);
                  }
                }
              }
            }
          }
        }

        // Delete vertex grid
        delete [] vertex_grid;
      }
    }
    else {
      ply_get_other_element (ply, elem_name, num_elems);
    }
  }

  // Free the memory
  free(ply);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x84(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
movq %r14, %rdi
callq 0x39c77
testq %rax, %rax
je 0x1e3f4
movq %rax, %r15
leaq 0xc8(%rsp), %rsi
leaq 0xcc(%rsp), %rdx
movq %rax, %rdi
callq 0x3af0c
leaq 0x8(%rbx), %rax
movq %rax, 0x78(%rsp)
leaq 0x28(%rbx), %rax
movq %rax, 0xa0(%rsp)
leaq 0x75d31(%rip), %rax     # 0x93606
xorl %ecx, %ecx
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq %rbx, 0x28(%rsp)
movq %rax, %rbx
movq %r15, 0x30(%rsp)
movslq 0x84(%rsp), %rax
cmpq %rax, %rcx
jge 0x1e3e7
movq 0xc0(%rsp), %rax
movq %rcx, 0xb8(%rsp)
movq (%rax,%rcx,8), %r13
movq %r15, %rdi
movq %r13, %rsi
leaq 0x4(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
callq 0x3a30e
movq %rax, %r12
leaq 0x75cb5(%rip), %rdi     # 0x935ef
movq %r13, %rsi
callq 0x3a099
testl %eax, %eax
movq %r13, 0x18(%rsp)
je 0x1dd03
movslq 0x4(%rsp), %r13
movq %r13, %rax
movl $0x98, %ecx
mulq %rcx
movq %rax, %r14
seto %al
addq $0x8, %r14
pushq $-0x1
popq %rcx
cmovbq %rcx, %r14
testb %al, %al
cmovneq %rcx, %r14
movq %r14, %rdi
callq 0xe030
leaq 0x8(%rax), %rbx
movq $0x0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, (%rax)
movl $0x0, %esi
testq %r13, %r13
je 0x1d9ce
imulq $-0x98, %r13, %rbp
movq %rbx, %r13
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x2108c
addq $-0x98, %r15
addq $0x98, %r13
cmpq %r15, %rbp
jne 0x1d9aa
movl 0x4(%rsp), %esi
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %rax
movq %rbx, 0x38(%rax)
movq %rax, %rbx
movq 0x78(%rsp), %rdi
callq 0x663f0
xorl %r14d, %r14d
movl $0x0, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x18(%rsp), %r13
movslq 0x3c(%rsp), %rax
cmpq %rax, %r14
jge 0x1dbe1
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x7e540(%rip), %rdi     # 0x9bf52
callq 0x3a099
leaq 0xbcab2(%rip), %rdx     # 0xda4d0
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x758e6(%rip), %rdi     # 0x9331a
callq 0x3a099
leaq 0xbcab8(%rip), %rdx     # 0xda4f8
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75b27(%rip), %rdi     # 0x9357d
callq 0x3a099
leaq 0xbcabe(%rip), %rdx     # 0xda520
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75afe(%rip), %rdi     # 0x93576
callq 0x3a099
leaq 0xbcac4(%rip), %rdx     # 0xda548
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75adf(%rip), %rdi     # 0x93579
callq 0x3a099
leaq 0xbcaca(%rip), %rdx     # 0xda570
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75ac0(%rip), %rdi     # 0x9357c
callq 0x3a099
leaq 0xbcad0(%rip), %rdx     # 0xda598
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75aa1(%rip), %rdi     # 0x9357f
callq 0x3a099
leaq 0xbcad6(%rip), %rdx     # 0xda5c0
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x7c046(%rip), %rdi     # 0x99b42
callq 0x3a099
leaq 0xbcae0(%rip), %rdx     # 0xda5e8
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75a68(%rip), %rdi     # 0x93582
callq 0x3a099
leaq 0xbcaea(%rip), %rdx     # 0xda610
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75a4e(%rip), %rdi     # 0x93586
callq 0x3a099
leaq 0xbcaf4(%rip), %rdx     # 0xda638
testl %eax, %eax
jne 0x1db66
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x75a36(%rip), %rdi     # 0x9358c
callq 0x3a099
leaq 0xbcafe(%rip), %rdx     # 0xda660
testl %eax, %eax
je 0x1db71
movq %r15, %rdi
movq %r13, %rsi
callq 0x3a4b6
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x759f7(%rip), %rdi     # 0x93576
callq 0x3a099
testl %eax, %eax
je 0x1db8d
pushq $0x1
popq %rbp
jmp 0x1dbd9
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x759e4(%rip), %rdi     # 0x9357f
callq 0x3a099
testl %eax, %eax
je 0x1dbb4
pushq $0x1
popq %r13
movl %r13d, 0x8(%rsp)
movq 0x18(%rsp), %r13
jmp 0x1dbd9
movq (%r12,%r14,8), %rax
movq (%rax), %rsi
leaq 0x759c0(%rip), %rdi     # 0x93582
callq 0x3a099
testl %eax, %eax
pushq $0x1
popq %rax
movq 0x10(%rsp), %rcx
cmovnel %eax, %ecx
movq %rcx, 0x10(%rsp)
incq %r14
jmp 0x1d9f6
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x4(%rsp), %rax
cmpq %rax, %r12
jge 0x1e0b2
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x3a53e
cvtss2sd 0x40(%rsp), %xmm0
cvtss2sd 0x44(%rsp), %xmm1
cvtss2sd 0x48(%rsp), %xmm2
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x37b4c
movq 0x38(%rbx), %rdx
addq %r15, %rdx
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x20(%rax)
movq %rax, %r14
testl %ebp, %ebp
je 0x1dc70
cvtss2sd 0x4c(%rsp), %xmm0
cvtss2sd 0x50(%rsp), %xmm1
cvtss2sd 0x54(%rsp), %xmm2
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
callq 0x3830c
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x21486
cmpl $0x0, 0x8(%rsp)
je 0x1dc9f
cvtss2sd 0x58(%rsp), %xmm0
cvtss2sd 0x5c(%rsp), %xmm1
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
callq 0x5f58c
leaq 0x48(%r14), %rdi
movq %r13, %rsi
callq 0x5f6c4
cmpl $0x0, 0x10(%rsp)
je 0x1dcf4
movzbl 0x60(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x75561(%rip), %xmm3    # 0x93218
divsd %xmm3, %xmm0
movzbl 0x61(%rsp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm3, %xmm1
movzbl 0x62(%rsp), %eax
cvtsi2sd %eax, %xmm2
divsd %xmm3, %xmm2
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
callq 0x66182
addq $0x58, %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x66212
incq %r12
addq $0x98, %r15
jmp 0x1dbe7
leaq 0x758ec(%rip), %rdi     # 0x935f6
movq %r13, %rsi
callq 0x3a099
testl %eax, %eax
je 0x1e0ce
movl 0x4(%rsp), %esi
movq 0xa0(%rsp), %rdi
callq 0x663f0
xorl %ebx, %ebx
movslq 0x3c(%rsp), %rax
cmpq %rax, %rbx
jge 0x1dde4
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75848(%rip), %rdi     # 0x93591
callq 0x3a099
leaq 0xbc93b(%rip), %rdx     # 0xda690
testl %eax, %eax
jne 0x1ddd1
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75839(%rip), %rdi     # 0x935a0
callq 0x3a099
leaq 0xbc945(%rip), %rdx     # 0xda6b8
testl %eax, %eax
jne 0x1ddd1
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75828(%rip), %rdi     # 0x935ad
callq 0x3a099
leaq 0xbc94f(%rip), %rdx     # 0xda6e0
testl %eax, %eax
jne 0x1ddd1
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75816(%rip), %rdi     # 0x935b9
callq 0x3a099
leaq 0xbc959(%rip), %rdx     # 0xda708
testl %eax, %eax
jne 0x1ddd1
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75803(%rip), %rdi     # 0x935c4
callq 0x3a099
leaq 0xbc963(%rip), %rdx     # 0xda730
testl %eax, %eax
je 0x1dddc
movq %r15, %rdi
movq %r13, %rsi
callq 0x3a4b6
incq %rbx
jmp 0x1dd2d
leaq 0x88(%rsp), %rdi
callq 0x6630a
movslq 0x4(%rsp), %rbx
leaq (,%rbx,4), %r14
testq %rbx, %rbx
pushq $-0x1
popq %rax
cmovsq %rax, %r14
movq %r14, %rdi
callq 0xe030
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0xe030
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0xe030
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
cmpl %ebx, %ebp
jge 0x1df77
movb $0x0, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
orq $-0x1, 0x50(%rsp)
orl $-0x1, 0x58(%rsp)
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
callq 0x3a53e
movl %ebp, 0x20(%rsp)
movq 0x48(%rsp), %rax
movslq (%rax), %rax
movq 0x78(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %r13
pushq $0x2
popq %r15
movq 0x28(%rsp), %rbx
movzbl 0x40(%rsp), %eax
movq 0x48(%rsp), %rdi
cmpq %rax, %r15
jae 0x1df5e
movslq -0x4(%rdi,%r15,4), %rcx
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rcx,8), %rbp
cmpq %rbp, %r13
je 0x1df56
movslq (%rdi,%r15,4), %rcx
movq (%rax,%rcx,8), %r12
cmpq %r12, %rbp
je 0x1df56
cmpq %r12, %r13
je 0x1df56
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1def9
movq 0x50(%rsp), %rcx
movq %rcx, 0x98(%rax)
movl 0x58(%rsp), %ecx
movl %ecx, 0xa0(%rax)
jmp 0x1df56
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x22bfc
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0x22bfc
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x22bfc
movl 0x50(%rsp), %eax
movslq %r14d, %r14
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
movl 0x54(%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
movl 0x58(%rsp), %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
incl %r14d
incq %r15
jmp 0x1de80
callq 0xe560
movl 0x20(%rsp), %ebp
incl %ebp
movl 0x4(%rsp), %ebx
movq 0x30(%rsp), %r15
jmp 0x1de34
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
pushq $0x10
popq %rcx
xorl %r15d, %r15d
movq 0x28(%rsp), %rdi
cmpq %r15, %r14
je 0x1e087
movq 0x88(%rsp), %rax
movq -0x10(%rax,%rcx), %rbp
movq -0x8(%rax,%rcx), %r12
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx), %r13
movq (%rdi), %rax
movq %rdi, %rbx
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
jne 0x1dfe6
movq %rbx, %rdi
movq (%rbx), %rax
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1e027
movq %rbx, %rdi
movq 0x10(%rsp), %rcx
movl (%rcx,%r15,4), %ecx
movl %ecx, 0x98(%rax)
movq 0x8(%rsp), %rcx
movl (%rcx,%r15,4), %ecx
movl %ecx, 0x9c(%rax)
movq 0x18(%rsp), %rcx
movl (%rcx,%r15,4), %ecx
movl %ecx, 0xa0(%rax)
incq %r15
movq 0x20(%rsp), %rcx
addq $0x18, %rcx
jmp 0x1df8e
addq $0x18, %rbp
movq (%rbx), %rax
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq %rax, %rbp
addq $0x18, %r12
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq %rax, %r12
addq $0x18, %r13
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq (%rbx), %r9
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq *0x48(%r9)
testq %rax, %rax
movq %rbx, %rdi
jne 0x1dfe9
jmp 0x1e016
movq 0x10(%rsp), %rdi
callq 0xe5d0
movq 0x8(%rsp), %rdi
callq 0xe5d0
movq 0x18(%rsp), %rdi
callq 0xe5d0
leaq 0x88(%rsp), %rdi
callq 0x66378
movq 0x30(%rsp), %r15
leaq 0x75548(%rip), %rbx     # 0x93606
movq 0xb8(%rsp), %rcx
incq %rcx
jmp 0x1d8f6
leaq 0x75526(%rip), %rdi     # 0x935fb
movq %r13, %rsi
callq 0x3a099
testl %eax, %eax
je 0x1e20b
andl $0x0, 0x88(%rsp)
movq %r15, %rdi
leaq 0x88(%rsp), %rsi
callq 0x3aa1b
movq %rax, %rbp
xorl %r15d, %r15d
movslq 0x88(%rsp), %rax
cmpq %rax, %r15
jge 0x1e1a9
movq (%rbp,%r15,8), %rdi
callq 0x68035
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0xe740
testq %rax, %rax
je 0x1e194
movq %rax, %r14
movq %rax, %rdi
leaq 0x754cc(%rip), %rsi     # 0x9360a
callq 0xe670
testl %eax, %eax
je 0x1e178
movq %r14, %rdi
leaq 0x754c2(%rip), %rsi     # 0x93613
callq 0xe670
testl %eax, %eax
jne 0x1e194
xorl %edi, %edi
movq %rbx, %rsi
callq 0xe740
testq %rax, %rax
je 0x1e194
movq %rax, %rdi
callq 0xe730
movq %rax, 0x68(%rsp)
jmp 0x1e194
xorl %edi, %edi
movq %rbx, %rsi
callq 0xe740
testq %rax, %rax
je 0x1e194
movq %rax, %rdi
callq 0xe730
movq %rax, 0x70(%rsp)
movq %r13, %rdi
callq 0xe560
incq %r15
movq 0x18(%rsp), %r13
jmp 0x1e103
cmpl $0x0, 0x68(%rsp)
setg %al
cmpl $0x0, 0x70(%rsp)
setg %cl
testb %cl, %al
je 0x1e3dd
movq 0x70(%rsp), %rax
imull 0x68(%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0x1e3dd
movl %eax, %ebx
leaq (,%rbx,8), %rdi
callq 0xe030
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq 0x30(%rsp), %r14
leaq 0xbc569(%rip), %r15     # 0xda760
cmpq %rax, %rbx
je 0x1e21f
movq 0x20(%rsp), %rcx
andq $0x0, (%rcx,%rax,8)
incq %rax
jmp 0x1e1f7
movl 0x4(%rsp), %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x3abd5
jmp 0x1e0be
xorl %ebx, %ebx
movslq 0x3c(%rsp), %rax
cmpq %rax, %rbx
jge 0x1e255
movq (%r12,%rbx,8), %rax
movq (%rax), %rsi
leaq 0x75358(%rip), %rdi     # 0x93591
callq 0x3a099
testl %eax, %eax
je 0x1e250
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3a4b6
incq %rbx
jmp 0x1e221
xorl %ebx, %ebx
movslq 0x4(%rsp), %rax
cmpq %rax, %rbx
jge 0x1e2ac
movb $0x0, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x3a53e
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1e2a7
cmpb $0x0, 0x40(%rsp)
je 0x1e2a7
movslq (%rdi), %rax
movq 0x78(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rax
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
callq 0xe560
incq %rbx
jmp 0x1e257
movq 0x70(%rsp), %rax
decl %eax
movq %rax, 0xb0(%rsp)
movq 0x68(%rsp), %rax
leal -0x1(%rax), %r14d
movl %eax, %eax
movq 0x20(%rsp), %r15
leaq (%r15,%rax,8), %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rsp)
shlq $0x3, %rax
movq %rax, 0xa8(%rsp)
addq $0x8, %r15
xorl %eax, %eax
movq %r14, 0x8(%rsp)
cmpq 0xb0(%rsp), %rax
je 0x1e3cc
incq %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x1e3b2
movq -0x8(%r15,%rbx,8), %rbp
movq (%r15,%rbx,8), %rdx
movq 0x10(%rsp), %rax
movq -0x8(%rax,%rbx,8), %r13
movq (%rax,%rbx,8), %r12
testq %rbp, %rbp
je 0x1e358
testq %r13, %r13
je 0x1e371
testq %rdx, %rdx
je 0x1e388
testq %r12, %r12
je 0x1e3a8
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
callq 0x1e480
movq %r14, %rdi
movq 0x8(%rsp), %r14
jmp 0x1e392
testq %r13, %r13
je 0x1e3a0
testq %rdx, %rdx
je 0x1e3a0
testq %r12, %r12
je 0x1e3a0
movq 0x28(%rsp), %rdi
movq %rdx, %rsi
jmp 0x1e395
testq %rdx, %rdx
je 0x1e3a0
testq %r12, %r12
je 0x1e3a0
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rcx
jmp 0x1e39b
testq %r12, %r12
je 0x1e3a0
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x1e480
incq %rbx
jmp 0x1e307
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
jmp 0x1e398
movq 0xa8(%rsp), %rax
addq %rax, 0x10(%rsp)
addq %rax, %r15
movq 0x18(%rsp), %rax
jmp 0x1e2ef
movq 0x20(%rsp), %rdi
callq 0xe5d0
leaq 0x75229(%rip), %rbx     # 0x93606
movq 0x30(%rsp), %r15
jmp 0x1e0be
movq %r15, %rdi
callq 0xe560
pushq $0x1
popq %rbx
jmp 0x1e40c
leaq 0x751d5(%rip), %rdi     # 0x935d0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x681ca
movq %r14, %rdi
callq 0xe440
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
jmp 0x1e468
movq %rax, %rbx
testq %r15, %r15
je 0x1e459
negq %r15
movq 0x8(%rsp), %r12
addq $-0x90, %r12
leaq (%r12,%r15), %rdi
callq 0x21124
addq $-0x98, %r15
jne 0x1e447
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xe8f0
jmp 0x1e478
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x66378
movq %rbx, %rdi
callq 0xe810