// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::ReadObjFile(char const*)
int R3Mesh::
ReadObjFile(const char *filename)
{
  // Open file
  FILE *fp;
  if (!(fp = fopen(filename, "r"))) {
    RNFail("Unable to open file %s", filename);
    return 0;
  }

  // Read body
  char buffer[1024];
  int line_count = 0;
  int material_index = -1;
  int segment_index = -1;
  RNSymbolTable<int> material_table;
  RNArray<R2Point *> texture_coords;
  RNArray<R3Vector *> normals;
  RNArray<R3MeshVertex *> verts;
  RNArray<R3MeshVertex *> degenerate_triangle_vertices;
  std::vector<int> degenerate_triangle_materials;
  std::vector<int> degenerate_triangle_segments;
  while (fgets(buffer, 1023, fp)) {
    // Increment line counter
    line_count++;

    // Skip white space
    char *bufferp = buffer;
    while (isspace(*bufferp)) bufferp++;

    // Skip blank lines and comments
    if (*bufferp == '#') continue;
    if (*bufferp == '\0') continue;

    // Get keyword
    char keyword[80];
    if (sscanf(bufferp, "%s", keyword) != 1) {
      RNFail("Syntax error on line %d in file %s", line_count, filename);
      return 0;
    }

    // Check keyword
    if (!strcmp(keyword, "v")) {
      // Read vertex coordinates
      double x, y, z;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &x, &y, &z) != 4) {
        RNFail("Syntax error on line %d in file %s", line_count, filename);
        return 0;
      }

      // Create vertex
      R3MeshVertex *v = CreateVertex(R3Point(x, y, z));
      verts.Insert(v);
    }
    else if (!strcmp(keyword, "vt")) {
      // Read texture coordinates
      double u, v;
      if (sscanf(bufferp, "%s%lf%lf", keyword, &u, &v) != 3) {
        RNFail("Syntax error on line %d in OBJ file", line_count);
        return 0;
      }

      // Create texture coordinates
      R2Point *vt = new R2Point(u, v);
      texture_coords.Insert(vt);
    }
    else if (!strcmp(keyword, "vn")) {
      // Read texture coordinates
      double x, y, z;
      if (sscanf(bufferp, "%s%lf%lf%lf", keyword, &x, &y, &z) != 4) {
        RNFail("Syntax error on line %d in OBJ file", line_count);
        return 0;
      }

      // Create normal
      R3Vector *vn = new R3Vector(x, y, z);
      vn->Normalize();
      normals.Insert(vn);
    }
    else if (!strcmp(keyword, "f")) {
      // Read vertex indices
      int quad = 1;
      char s[4][128] = { { '\0' }, { '\0' }, { '\0' },{ '\0' } }; 
      if (sscanf(bufferp, "%s%s%s%s%s", keyword, s[0], s[1], s[2], s[3]) != 5) {
        quad = 0;;
        if (sscanf(bufferp, "%s%s%s%s", keyword, s[0], s[1], s[2]) != 4) {
          RNFail("Syntax error on line %d in OBJ file", line_count);
          return 0;
        }
      }

      // Parse vertex indices
      int n = (quad) ? 4 : 3;
      R3MeshVertex *v[4] = { NULL, NULL, NULL, NULL };
      for (int i = 0; i < n; i++) {
        char *sv = s[i];
        char *st = strchr(sv, '/');
        if (st) *(st++) = 0;
        char *sn = (st) ? strchr(st, '/') : NULL;
        if (sn) *(sn++) = 0;
        if (sn && (strlen(sn) == 0)) sn = NULL; 
        if (st && (strlen(st) == 0)) st = NULL;
        int vi = (sv) ? atoi(sv) : 0;
        int ti = (st) ? atoi(st) : 0;
        int ni = (sn) ? atoi(sn) : 0;
        v[i] = verts.Kth(vi-1);
        R2Point texcoords(0,0);
        R3Vector normal(0, 0, 0);
        if ((ti > 0) && ((ti-1) < texture_coords.NEntries())) texcoords = *(texture_coords.Kth(ti-1));
        if ((ni > 0) && ((ni-1) < normals.NEntries())) normal = *(normals.Kth(ni-1));
        if (((ti > 0) && !R2Contains(texcoords, VertexTextureCoords(v[i]))) ||
            ((ni > 0) && !R3Contains(normal, VertexNormal(v[i])))) {
          v[i] = CreateVertex(VertexPosition(v[i]), normal, RNgray_rgb, texcoords);
        }
      }

      // Check vertices
      if ((v[0] == v[1]) || (v[1] == v[2]) || (v[0] == v[2])) continue;
      if ((quad) && ((v[3] == v[0]) || (v[3] == v[1]) || (v[3] == v[2]))) quad = 0;

      // Create first triangle
      if (RNIsPositive(R3Distance(VertexPosition(v[0]), VertexPosition(v[1]))) &&
          RNIsPositive(R3Distance(VertexPosition(v[1]), VertexPosition(v[2]))) &&
          RNIsPositive(R3Distance(VertexPosition(v[2]), VertexPosition(v[0])))) {
        R3MeshFace *face = CreateFace(v[0], v[1], v[2]);
        if (face) {
          // Set segment and face
          SetFaceSegment(face, segment_index);
          SetFaceMaterial(face, material_index);
        }
        else {
          // Must have been degeneracy (e.g., flips or three faces sharing an edge)
          // Remember for later processing (to preserve vertex indices)
          degenerate_triangle_vertices.Insert(v[0]);
          degenerate_triangle_vertices.Insert(v[1]);
          degenerate_triangle_vertices.Insert(v[2]);
          degenerate_triangle_materials.push_back(material_index);
          degenerate_triangle_segments.push_back(segment_index);
        }
      }

      // Create second triangle
      if (quad) {
        if (RNIsPositive(R3Distance(VertexPosition(v[0]), VertexPosition(v[2]))) &&
            RNIsPositive(R3Distance(VertexPosition(v[2]), VertexPosition(v[3]))) &&
            RNIsPositive(R3Distance(VertexPosition(v[0]), VertexPosition(v[3])))) {
          R3MeshFace *face = CreateFace(v[0], v[2], v[3]);
          if (face) {
            // Set segment and face
            SetFaceSegment(face, segment_index);
            SetFaceMaterial(face, material_index);
          }
          else {
            // Must have been degeneracy (e.g., flips or three faces sharing an edge)
            // Remember for later processing (to preserve vertex indices)
            degenerate_triangle_vertices.Insert(v[0]);
            degenerate_triangle_vertices.Insert(v[2]);
            degenerate_triangle_vertices.Insert(v[3]);
            degenerate_triangle_materials.push_back(material_index);
            degenerate_triangle_segments.push_back(segment_index);
          }
        }
      }
    }
    else if (!strcmp(keyword, "usemtl")) {
      // Read fields
      char mtlname[1024];
      if (sscanf(bufferp, "%s%s", keyword, mtlname) != 2) {
        RNFail("Syntax error on line %d in OBJ file", line_count);
        return 0;
      }

      // Find/insert material index
      if (!material_table.Find(mtlname, &material_index)) {
        material_table.Insert(mtlname, ++material_index);
      }
    }
    else if (!strcmp(keyword, "g") || !strcmp(keyword, "o")) {
      // Read name
      char name[1024];
      if (sscanf(bufferp, "%s%s", keyword, name) != 2) {
        RNFail("Syntax error on line %d in OBJ file", line_count);
        return 0;
      }

      // Increment the segment index
      segment_index++;
    }
  }

  // Create degenerate triangles
  for (int i = 0; i <= degenerate_triangle_vertices.NEntries()-3; i+=3) {
    // Get vertices
    R3MeshVertex *v1 = degenerate_triangle_vertices.Kth(i+0);
    R3MeshVertex *v2 = degenerate_triangle_vertices.Kth(i+1);
    R3MeshVertex *v3 = degenerate_triangle_vertices.Kth(i+2);

    // Create face
    R3MeshFace *face = CreateFace(v1, v2, v3);
    if (!face) {
      face = CreateFace(v1, v3, v2);
      if (!face) {
        // 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));
        face = CreateFace(v1a, v2a, v3a);
      }
    }

    // Set material and segment
    if (face) {
      if ((int) degenerate_triangle_materials.size() > i/3) 
        SetFaceMaterial(face, degenerate_triangle_materials[i/3]);
      if ((int) degenerate_triangle_segments.size() > i/3) 
        SetFaceSegment(face, degenerate_triangle_segments[i/3]);
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x9a8, %rsp            # imm = 0x9A8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8064d(%rip), %rsi     # 0x9caf3
movq %r14, %rdi
callq 0xe550
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x1ce1e
orl $-0x1, 0x8(%rsp)
orl $-0x1, 0xc(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x23aec
leaq 0x98(%rsp), %rdi
callq 0x6630a
leaq 0x88(%rsp), %rdi
callq 0x6630a
leaq 0xc0(%rsp), %rdi
callq 0x6630a
movq %r14, 0x68(%rsp)
movq %rbx, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x6630a
leaq 0xf0(%rsp), %rax
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rax)
leaq 0xd0(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %r13d, %r13d
leaq 0x5a0(%rsp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq 0x70(%rsp), %rdx
callq 0xe760
leaq 0x59f(%rsp), %r12
testq %rax, %rax
je 0x1ccee
movsbl 0x1(%r12), %ebx
incq %r12
movl %ebx, %edi
callq 0xe080
testl %eax, %eax
jne 0x1c55c
movzbl %bl, %eax
incl %r13d
testl %eax, %eax
je 0x1c534
cmpl $0x23, %eax
je 0x1c534
movq %r12, %rdi
leaq 0x7c8d7(%rip), %rsi     # 0x98e60
leaq 0x110(%rsp), %rdx
xorl %eax, %eax
callq 0xe430
cmpl $0x1, %eax
jne 0x1ce36
movzwl 0x110(%rsp), %ebx
cmpl $0x76, %ebx
jne 0x1c62c
movq %r12, %rdi
leaq 0x76dec(%rip), %rsi     # 0x933a4
leaq 0x110(%rsp), %rdx
leaq 0x40(%rsp), %rcx
leaq 0xa8(%rsp), %r8
leaq 0x78(%rsp), %r9
xorl %eax, %eax
callq 0xe430
cmpl $0x4, %eax
jne 0x1ce4e
movsd 0x40(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
leaq 0x1a0(%rsp), %rbx
movq %rbx, %rdi
callq 0x37b4c
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
xorl %edx, %edx
callq *0x20(%rax)
leaq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0x22bfc
jmp 0x1c534
leaq 0x110(%rsp), %r14
movq %r14, %rdi
leaq 0x76d72(%rip), %rsi     # 0x933b0
pushq $0x3
popq %r15
movq %r15, %rdx
callq 0xe480
testl %eax, %eax
je 0x1c8ca
movq %r14, %rdi
leaq 0x76d84(%rip), %rsi     # 0x933e0
movq %r15, %rdx
callq 0xe480
testl %eax, %eax
je 0x1c92b
cmpl $0x66, %ebx
jne 0x1c9a5
movl $0x200, %edx            # imm = 0x200
leaq 0x1a0(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0xe270
leaq 0x320(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
leaq 0x76d41(%rip), %rsi     # 0x933e3
leaq 0x110(%rsp), %r15
movq %r15, %rdx
movq %rbp, %rcx
leaq 0x220(%rsp), %rbx
movq %rbx, %r8
leaq 0x2a0(%rsp), %r14
movq %r14, %r9
xorl %eax, %eax
callq 0xe430
movl %eax, %ecx
pushq $0x4
popq %rax
movq %rax, 0x18(%rsp)
movl %ecx, 0x60(%rsp)
cmpl $0x5, %ecx
je 0x1c70e
movq %r12, %rdi
leaq 0x76cfb(%rip), %rsi     # 0x933e5
movq %r15, %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0xe430
pushq $0x3
popq %rcx
movq %rcx, 0x18(%rsp)
cmpl $0x4, %eax
jne 0x1ce8c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
movq %rbp, %r15
xorl %r12d, %r12d
movl %r13d, 0x64(%rsp)
cmpq %r12, 0x18(%rsp)
je 0x1ca06
movq %r15, %rdi
pushq $0x2f
popq %rbx
movl %ebx, %esi
callq 0xe1a0
testq %rax, %rax
je 0x1c779
movq %rax, %r14
incq %r14
movb $0x0, (%rax)
movq %r14, %rdi
movl %ebx, %esi
callq 0xe1a0
testq %rax, %rax
je 0x1c76f
movq %rax, %rbp
movb $0x0, (%rax)
cmpb $0x0, 0x1(%rax)
je 0x1c76f
incq %rbp
jmp 0x1c771
xorl %ebp, %ebp
cmpb $0x0, (%r14)
je 0x1c77b
jmp 0x1c77e
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0xe730
movl %eax, %ebx
xorl %r15d, %r15d
movl $0x0, %r13d
testq %r14, %r14
je 0x1c7a6
movq %r14, %rdi
callq 0xe730
movl %eax, %r13d
testq %rbp, %rbp
je 0x1c7b6
movq %rbp, %rdi
callq 0xe730
movl %eax, %r15d
movq 0xc0(%rsp), %rax
movslq %ebx, %rcx
movq -0x8(%rax,%rcx,8), %r14
movq %r14, 0x40(%rsp,%r12,8)
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
leaq 0x78(%rsp), %rdi
callq 0x5f58c
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0xa8(%rsp), %rdi
callq 0x3830c
movq 0x20(%rsp), %rbx
testl %r13d, %r13d
jle 0x1c821
cmpl 0xa4(%rsp), %r13d
jg 0x1c821
movq 0x98(%rsp), %rax
movl %r13d, %ecx
movq -0x8(%rax,%rcx,8), %rsi
leaq 0x78(%rsp), %rdi
callq 0x5f6c4
testl %r15d, %r15d
jle 0x1c84d
cmpl 0x94(%rsp), %r15d
jg 0x1c84d
movq 0x88(%rsp), %rax
movl %r15d, %ecx
movq -0x8(%rax,%rcx,8), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x3887c
testl %r13d, %r13d
jle 0x1c864
leaq 0x48(%r14), %rsi
leaq 0x78(%rsp), %rdi
callq 0x4f809
testl %eax, %eax
je 0x1c888
testl %r15d, %r15d
jle 0x1c8b4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21234
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x40d74
testl %eax, %eax
jne 0x1c8b4
addq $0x18, %r14
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
leaq 0xa8(%rsp), %rdx
leaq 0xbe23c(%rip), %rcx     # 0xdaae0
leaq 0x78(%rsp), %r8
xorl %r9d, %r9d
callq *0x38(%rax)
movq %rax, 0x40(%rsp,%r12,8)
incq %r12
movq 0x10(%rsp), %r15
subq $-0x80, %r15
movl 0x64(%rsp), %r13d
jmp 0x1c729
movq %r12, %rdi
leaq 0x76adf(%rip), %rsi     # 0x933b3
movq %r14, %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x40(%rsp), %r8
xorl %eax, %eax
callq 0xe430
cmpl $0x3, %eax
jne 0x1ce66
pushq $0x10
popq %rdi
callq 0xe450
movq %rax, %r14
movsd 0x1a0(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movq %rax, %rdi
callq 0x5f58c
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
callq 0x22bfc
jmp 0x1c534
movq %r12, %rdi
leaq 0x76a6f(%rip), %rsi     # 0x933a4
movq %r14, %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0xa8(%rsp), %r9
xorl %eax, %eax
callq 0xe430
cmpl $0x4, %eax
jne 0x1ce79
pushq $0x18
popq %rdi
callq 0xe450
movq %rax, %r14
movsd 0x1a0(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm2
movq %rax, %rdi
callq 0x3830c
movq %r14, %rdi
callq 0x3860e
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x22bfc
jmp 0x1c534
leaq 0x110(%rsp), %r14
movq %r14, %rdi
leaq 0x76a37(%rip), %rsi     # 0x933ee
pushq $0x7
popq %rdx
callq 0xe480
testl %eax, %eax
je 0x1cb03
orl $0x8, %ebx
cmpl $0x6f, %ebx
jne 0x1c534
movq %r12, %rdi
leaq 0x76c4f(%rip), %rsi     # 0x9362c
leaq 0x110(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
xorl %eax, %eax
callq 0xe430
cmpl $0x2, %eax
jne 0x1ce9f
incl 0xc(%rsp)
jmp 0x1c534
movq 0x40(%rsp), %r12
movq 0x48(%rsp), %r14
cmpq %r14, %r12
je 0x1c534
movq 0x50(%rsp), %rsi
cmpq %rsi, %r14
sete %al
cmpq %rsi, %r12
sete %cl
orb %al, %cl
jne 0x1c534
movb $0x1, %bpl
cmpl $0x5, 0x60(%rsp)
jne 0x1ca59
movq 0x58(%rsp), %rax
cmpq %r12, %rax
sete %cl
cmpq %r14, %rax
sete %dl
orb %cl, %dl
cmpq %rsi, %rax
sete %bpl
orb %dl, %bpl
movq %rsi, 0x10(%rsp)
leaq 0x18(%r12), %rdi
leaq 0x18(%r14), %rbx
movq %rdi, 0x18(%rsp)
movq %rbx, %rsi
callq 0x4321a
leaq 0xbe12d(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1cbf2
movq 0x10(%rsp), %rax
leaq 0x18(%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4321a
leaq 0xbe108(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1cbf2
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x4321a
leaq 0xbe0ea(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1cbf2
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1cba5
movl 0xc(%rsp), %ecx
movl %ecx, 0x9c(%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x98(%rax)
jmp 0x1cbf2
movq %r12, %rdi
leaq 0x76b1f(%rip), %rsi     # 0x9362c
movq %r14, %rdx
leaq 0x1a0(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0xe430
cmpl $0x2, %eax
jne 0x1ceb2
leaq 0x180(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x40(%rsp), %rdx
callq 0x22314
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
leaq 0x8(%rsp), %rdx
callq 0x222da
leaq 0x160(%rsp), %r12
movl %eax, %ebx
movq %r15, %rdi
callq 0xe200
testl %ebx, %ebx
jne 0x1c534
movq %r12, %rdi
movq %r14, %rsi
leaq 0x40(%rsp), %rdx
callq 0x22314
movl 0x8(%rsp), %ebx
incl %ebx
movl %ebx, 0x8(%rsp)
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x23f1a
movl %ebx, (%rax)
movq %r12, %rdi
callq 0xe200
jmp 0x1c534
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x22bfc
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x22bfc
leaq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x22bfc
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x222bc
leaq 0xd0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x222bc
testb %bpl, %bpl
jne 0x1c534
movq 0x10(%rsp), %rax
leaq 0x18(%rax), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x4321a
leaq 0xbdf90(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1c534
movq 0x58(%rsp), %r14
leaq 0x18(%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4321a
leaq 0xbdf6b(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1c534
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x4321a
leaq 0xbdf4d(%rip), %rax     # 0xdaba8
ucomisd (%rax), %xmm0
jbe 0x1c534
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1cc9c
movl 0xc(%rsp), %ecx
movl %ecx, 0x9c(%rax)
movl 0x8(%rsp), %ecx
movl %ecx, 0x98(%rax)
jmp 0x1c534
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x22bfc
leaq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x22bfc
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x22bfc
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x222bc
leaq 0xd0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x222bc
jmp 0x1c534
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x20(%rsp), %rbx
movslq 0x34(%rsp), %rax
addq $-0x3, %rax
cmpq %rax, %rbp
jg 0x1ce0c
movq 0x28(%rsp), %rax
movq (%rax,%rbp,8), %r12
movq 0x8(%rax,%rbp,8), %r15
movq 0x10(%rax,%rbp,8), %r14
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
jne 0x1cdae
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
jne 0x1cdae
addq $0x18, %r12
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq %rax, %r12
addq $0x18, %r15
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq %rbx, %r15
movq %rax, %rbx
addq $0x18, %r14
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movq (%r15), %r9
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq *0x48(%r9)
testq %rax, %rax
movq %r15, %rbx
je 0x1ce00
movq 0xf0(%rsp), %rcx
movq 0xf8(%rsp), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x1cdd7
movl (%rcx,%r13,4), %ecx
movl %ecx, 0x98(%rax)
movq 0xd0(%rsp), %rcx
movq 0xd8(%rsp), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x1ce00
movl (%rcx,%r13,4), %ecx
movl %ecx, 0x9c(%rax)
addq $0x3, %rbp
incq %r13
jmp 0x1ccf8
movq 0x70(%rsp), %rdi
callq 0xe440
pushq $0x1
popq %rbx
jmp 0x1cec5
leaq 0x76545(%rip), %rdi     # 0x9336a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x681ca
jmp 0x1cf1a
leaq 0x76544(%rip), %rdi     # 0x93381
movl %r13d, %esi
movq 0x68(%rsp), %rdx
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x7652c(%rip), %rdi     # 0x93381
movl %r13d, %esi
movq 0x68(%rsp), %rdx
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x7654f(%rip), %rdi     # 0x933bc
movl %r13d, %esi
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x7653c(%rip), %rdi     # 0x933bc
movl %r13d, %esi
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x76529(%rip), %rdi     # 0x933bc
movl %r13d, %esi
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x76516(%rip), %rdi     # 0x933bc
movl %r13d, %esi
xorl %eax, %eax
callq 0x681ca
jmp 0x1cec3
leaq 0x76503(%rip), %rdi     # 0x933bc
movl %r13d, %esi
xorl %eax, %eax
callq 0x681ca
xorl %ebx, %ebx
leaq 0xd0(%rsp), %rdi
callq 0x23b1a
leaq 0xf0(%rsp), %rdi
callq 0x23b1a
leaq 0x28(%rsp), %rdi
callq 0x66378
leaq 0xc0(%rsp), %rdi
callq 0x66378
leaq 0x88(%rsp), %rdi
callq 0x66378
leaq 0x98(%rsp), %rdi
callq 0x66378
leaq 0x38(%rsp), %rdi
callq 0x22350
movl %ebx, %eax
addq $0x9a8, %rsp            # imm = 0x9A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0x1cf5a
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0xe200
jmp 0x1cfa5
jmp 0x1cfa2
jmp 0x1cfa2
movq %rax, %rbx
pushq $0x18
jmp 0x1cf85
movq %rax, %rbx
jmp 0x1cfc9
movq %rax, %rbx
jmp 0x1cfd6
movq %rax, %rbx
jmp 0x1cfe3
movq %rax, %rbx
jmp 0x1cff0
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0xe460
jmp 0x1cfa5
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
jmp 0x1cfa2
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x23b1a
leaq 0xf0(%rsp), %rdi
callq 0x23b1a
leaq 0x28(%rsp), %rdi
callq 0x66378
leaq 0xc0(%rsp), %rdi
callq 0x66378
leaq 0x88(%rsp), %rdi
callq 0x66378
leaq 0x98(%rsp), %rdi
callq 0x66378
leaq 0x38(%rsp), %rdi
callq 0x22350
movq %rbx, %rdi
callq 0xe810