// File: /workspace/github_cpp_makefile_star2_O1/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 $0x9b8, %rsp            # imm = 0x9B8
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8d5bb(%rip), %rsi     # 0xabd93
movq %r15, %rdi
callq 0xe530
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x1f485
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x14(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x30, %edi
callq 0xe440
leaq 0x8(%rax), %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
movupd %xmm0, 0x20(%rax)
movupd %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x48(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x705ec
leaq 0xc0(%rsp), %rdi
callq 0x705ec
leaq 0xf0(%rsp), %rdi
callq 0x705ec
leaq 0x30(%rsp), %rdi
callq 0x705ec
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
xorl %eax, %eax
movq %rax, 0x80(%rsp)
movq %rax, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
leaq 0x5b0(%rsp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq 0x90(%rsp), %rdx
callq 0xe730
testq %rax, %rax
je 0x1f35e
leaq 0x150(%rsp), %r12
movl $0x0, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
leaq 0x5af(%rsp), %rbp
movsbl 0x1(%rbp), %ebx
incq %rbp
movl %ebx, %edi
callq 0xe080
testl %eax, %eax
jne 0x1e8c3
movzbl %bl, %eax
incl 0x18(%rsp)
movl $0x2, %r13d
testl %eax, %eax
je 0x1e9bc
cmpl $0x23, %eax
movq 0x20(%rsp), %rbx
je 0x1ef8c
movq %rbp, %rdi
leaq 0x895b2(%rip), %rsi     # 0xa7eb4
leaq 0x160(%rsp), %rdx
xorl %eax, %eax
callq 0xe420
cmpl $0x1, %eax
jne 0x1e9c6
movzwl 0x160(%rsp), %eax
cmpl $0x76, %eax
jne 0x1e9e6
movq %rbp, %rdi
leaq 0x83ac2(%rip), %rsi     # 0xa23f7
leaq 0x160(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
leaq 0x100(%rsp), %r8
leaq 0xe0(%rsp), %r9
xorl %eax, %eax
callq 0xe420
movl %eax, %ebp
cmpl $0x4, %eax
jne 0x1eddb
movsd 0xa0(%rsp), %xmm0
movsd 0x100(%rsp), %xmm1
movsd 0xe0(%rsp), %xmm2
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x3ca26
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq *0x20(%rax)
movl 0xfc(%rsp), %edx
leaq 0xf0(%rsp), %rdi
movq %rax, %rsi
callq 0x70682
jmp 0x1edf0
movq 0x20(%rsp), %rbx
jmp 0x1ef8c
movl $0x1, %r13d
leaq 0x83a01(%rip), %rdi     # 0xa23d4
movl 0x18(%rsp), %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x72a1e
jmp 0x1ef8c
movl 0x160(%rsp), %ecx
movl $0x7476, %edx           # imm = 0x7476
xorl %edx, %ecx
movzbl 0x162(%rsp), %edx
orw %cx, %dx
je 0x1ee04
movl 0x160(%rsp), %ecx
movl $0x6e76, %edx           # imm = 0x6E76
xorl %edx, %ecx
movzbl 0x162(%rsp), %edx
orw %cx, %dx
je 0x1ee7b
cmpl $0x66, %eax
jne 0x1ef0b
movl $0x200, %edx            # imm = 0x200
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0xe260
leaq 0x330(%rsp), %rax
movq %rax, (%rsp)
movq %rbp, %rdi
leaq 0x839dc(%rip), %rsi     # 0xa2436
leaq 0x160(%rsp), %rdx
movq %r14, %rcx
leaq 0x230(%rsp), %r8
leaq 0x2b0(%rsp), %r9
xorl %eax, %eax
callq 0xe420
movl $0x4, %ecx
movq %rcx, 0x40(%rsp)
movl %eax, 0x9c(%rsp)
cmpl $0x5, %eax
je 0x1ead1
movq %rbp, %rdi
leaq 0x8399c(%rip), %rsi     # 0xa2438
leaq 0x160(%rsp), %rdx
movq %r14, %rcx
leaq 0x230(%rsp), %r8
leaq 0x2b0(%rsp), %r9
xorl %eax, %eax
callq 0xe420
movl $0x3, %ecx
movq %rcx, 0x40(%rsp)
cmpl $0x4, %eax
jne 0x1f105
movq %r15, 0x138(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
xorl %ebp, %ebp
movq %r14, %rdi
movl $0x2f, %esi
callq 0xe1a0
testq %rax, %rax
je 0x1eb0e
movq %rax, %r12
incq %r12
movb $0x0, (%rax)
jmp 0x1eb11
xorl %r12d, %r12d
testq %r12, %r12
je 0x1eb28
movq %r12, %rdi
movl $0x2f, %esi
callq 0xe1a0
movq %rax, %r15
jmp 0x1eb2b
xorl %r15d, %r15d
testq %r15, %r15
je 0x1eb39
movb $0x0, (%r15)
incq %r15
jmp 0x1eb3c
xorl %r15d, %r15d
testq %r15, %r15
je 0x1eb47
cmpb $0x0, (%r15)
jne 0x1eb4a
xorl %r15d, %r15d
testq %r12, %r12
je 0x1eb56
cmpb $0x0, (%r12)
jne 0x1eb59
xorl %r12d, %r12d
movq %r14, 0x28(%rsp)
movq %r14, %rdi
callq 0xe700
movl %eax, %ebx
xorl %r13d, %r13d
movl $0x0, %r14d
testq %r12, %r12
je 0x1eb81
movq %r12, %rdi
callq 0xe700
movl %eax, %r14d
testq %r15, %r15
je 0x1eb91
movq %r15, %rdi
callq 0xe700
movl %eax, %r13d
movq 0xf0(%rsp), %rax
movslq %ebx, %rcx
movq -0x8(%rax,%rcx,8), %r12
movq %r12, 0xa0(%rsp,%rbp,8)
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
leaq 0xe0(%rsp), %rdi
callq 0x68e2e
xorpd %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x100(%rsp), %rdi
callq 0x3d4be
movq 0x20(%rsp), %rbx
testl %r14d, %r14d
jle 0x1ec05
cmpl 0xdc(%rsp), %r14d
jg 0x1ec05
movq 0xd0(%rsp), %rax
movl %r14d, %ecx
movq -0x8(%rax,%rcx,8), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x68f66
testl %r13d, %r13d
jle 0x1ec31
cmpl 0xcc(%rsp), %r13d
jg 0x1ec31
movq 0xc0(%rsp), %rax
movl %r13d, %ecx
movq -0x8(%rax,%rcx,8), %rsi
leaq 0x100(%rsp), %rdi
callq 0x3dc6a
testl %r14d, %r14d
jle 0x1ec4c
leaq 0x48(%r12), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x579d5
testl %eax, %eax
je 0x1ec7e
testl %r13d, %r13d
jle 0x1ecb0
testb $0x2, 0x78(%r12)
jne 0x1ec68
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x2b0(%rax)
leaq 0x30(%r12), %rsi
leaq 0x100(%rsp), %rdi
callq 0x46db8
testl %eax, %eax
jne 0x1ecb0
addq $0x18, %r12
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x100(%rsp), %rdx
leaq 0xc6e36(%rip), %rcx     # 0xe5ad0
leaq 0xe0(%rsp), %r8
xorl %r9d, %r9d
callq *0x38(%rax)
movq %rax, 0xa0(%rsp,%rbp,8)
incq %rbp
movq 0x28(%rsp), %r14
subq $-0x80, %r14
cmpq %rbp, 0x40(%rsp)
jne 0x1eaf1
movq 0xa0(%rsp), %rbp
movq 0xa8(%rsp), %r12
movl $0x2, %r13d
cmpq %r12, %rbp
je 0x1f271
movq 0xb0(%rsp), %rcx
cmpq %rcx, %r12
sete %al
movq %rcx, 0x28(%rsp)
cmpq %rcx, %rbp
sete %cl
orb %al, %cl
jne 0x1f271
movb $0x1, %r15b
cmpl $0x5, 0x9c(%rsp)
jne 0x1ed36
movq 0xb8(%rsp), %rax
cmpq %rbp, %rax
sete %cl
cmpq %r12, %rax
sete %dl
orb %cl, %dl
cmpq 0x28(%rsp), %rax
sete %r15b
orb %dl, %r15b
leaq 0x18(%rbp), %rdi
leaq 0x18(%r12), %rbx
movq %rdi, 0x40(%rsp)
movq %rbx, %rsi
callq 0x49efc
leaq 0xc6e45(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
jbe 0x1f203
movq 0x28(%rsp), %rax
leaq 0x18(%rax), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49efc
leaq 0xc6e20(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
jbe 0x1f203
movq %r14, %rdi
movq 0x40(%rsp), %rsi
callq 0x49efc
leaq 0xc6e02(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
jbe 0x1f203
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1f173
movl 0x1c(%rsp), %ecx
movl %ecx, 0x9c(%rax)
movl 0x14(%rsp), %ecx
movl %ecx, 0x98(%rax)
jmp 0x1f203
leaq 0x835f2(%rip), %rdi     # 0xa23d4
movl 0x18(%rsp), %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x72a1e
movl $0x1, %r13d
cmpl $0x4, %ebp
je 0x1ef89
jmp 0x1ef8c
movq %rbp, %rdi
leaq 0x835f8(%rip), %rsi     # 0xa2406
leaq 0x160(%rsp), %rdx
leaq 0x1b0(%rsp), %rcx
leaq 0xa0(%rsp), %r8
xorl %eax, %eax
callq 0xe420
movl %eax, %ebp
cmpl $0x3, %eax
jne 0x1ef6c
movl $0x10, %edi
callq 0xe440
movq %rax, %r14
movsd 0x1b0(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
movq %rax, %rdi
callq 0x68e2e
movl 0xdc(%rsp), %edx
leaq 0xd0(%rsp), %rdi
movq %r14, %rsi
callq 0x70682
jmp 0x1ef7e
movq %rbp, %rdi
leaq 0x83572(%rip), %rsi     # 0xa23f7
leaq 0x160(%rsp), %rdx
leaq 0x1b0(%rsp), %rcx
leaq 0xa0(%rsp), %r8
leaq 0x100(%rsp), %r9
xorl %eax, %eax
callq 0xe420
movl %eax, %ebp
cmpl $0x4, %eax
jne 0x1efbe
movl $0x18, %edi
callq 0xe440
movq %rax, %r14
movsd 0x1b0(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
movsd 0x100(%rsp), %xmm2
movq %rax, %rdi
callq 0x3d4be
movq %r14, %rdi
callq 0x3d7e0
movl 0xcc(%rsp), %edx
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x70682
jmp 0x1edf0
movl 0x160(%rsp), %ecx
movl $0x6d657375, %edx       # imm = 0x6D657375
xorl %edx, %ecx
movl 0x163(%rsp), %edx
movl $0x6c746d, %esi         # imm = 0x6C746D
xorl %esi, %edx
orl %ecx, %edx
je 0x1efd5
orl $0x8, %eax
cmpl $0x6f, %eax
jne 0x1ef89
movq %rbp, %rdi
leaq 0x8373e(%rip), %rsi     # 0xa267f
leaq 0x160(%rsp), %rdx
leaq 0x1b0(%rsp), %rcx
xorl %eax, %eax
callq 0xe420
movl %eax, %ebx
cmpl $0x2, %eax
jne 0x1f122
incl 0x1c(%rsp)
jmp 0x1f134
leaq 0x8349c(%rip), %rdi     # 0xa240f
movl 0x18(%rsp), %esi
xorl %eax, %eax
callq 0x72a1e
movl $0x1, %r13d
cmpl $0x3, %ebp
jne 0x1ef8c
xorl %r13d, %r13d
testb $0x1, %r13b
jne 0x1f49a
leaq 0x5b0(%rsp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq 0x90(%rsp), %rdx
callq 0xe730
testq %rax, %rax
jne 0x1e8bb
jmp 0x1f35e
leaq 0x8344a(%rip), %rdi     # 0xa240f
movl 0x18(%rsp), %esi
xorl %eax, %eax
callq 0x72a1e
jmp 0x1edf0
movq %rbp, %rdi
leaq 0x836a0(%rip), %rsi     # 0xa267f
leaq 0x160(%rsp), %rdx
leaq 0x1b0(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0xe420
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x1f14d
movq %r12, 0x140(%rsp)
movq %r14, %rdi
callq 0xe1e0
leaq (%rsp,%rax), %rdx
addq $0x1b0, %rdx            # imm = 0x1B0
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26502
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x26144
movq %rax, %rbx
movq 0x48(%rsp), %r14
addq $0x8, %r14
cmpq %r14, %rax
je 0x1f057
movl 0x40(%rbx), %eax
movl %eax, 0x14(%rsp)
movq 0x140(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f074
movq 0x150(%rsp), %rsi
incq %rsi
callq 0xe450
cmpq %r14, %rbx
movq 0x20(%rsp), %rbx
jne 0x1f15f
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0x1b0(%rsp), %rbx
movq %rbx, %rdi
callq 0xe1e0
leaq (%rsp,%rax), %rdx
addq $0x1b0, %rdx            # imm = 0x1B0
leaq 0x118(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x26502
movl 0x14(%rsp), %ebx
incl %ebx
movl %ebx, 0x14(%rsp)
movq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x26592
movl %ebx, (%rax)
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
movq 0x20(%rsp), %rbx
je 0x1f15f
movq 0x128(%rsp), %rsi
incq %rsi
callq 0xe450
jmp 0x1f15f
movl $0x1, %r13d
leaq 0x832fd(%rip), %rdi     # 0xa240f
movl 0x18(%rsp), %esi
xorl %eax, %eax
callq 0x72a1e
jmp 0x1f281
leaq 0x832e6(%rip), %rdi     # 0xa240f
movl 0x18(%rsp), %esi
xorl %eax, %eax
callq 0x72a1e
movl $0x1, %r13d
cmpl $0x2, %ebx
movq 0x20(%rsp), %rbx
je 0x1ef89
jmp 0x1ef8c
leaq 0x832bb(%rip), %rdi     # 0xa240f
movl 0x18(%rsp), %esi
xorl %eax, %eax
callq 0x72a1e
movl $0x1, %r13d
cmpl $0x2, %ebp
je 0x1ef89
jmp 0x1ef8c
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x70682
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x70682
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x70682
movq 0x78(%rsp), %rsi
cmpq 0x80(%rsp), %rsi
je 0x1f1c8
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x78(%rsp)
jmp 0x1f1d7
leaq 0x70(%rsp), %rdi
leaq 0x14(%rsp), %rdx
callq 0x26008
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x1f1f4
movl 0x1c(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x1f203
leaq 0x50(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
callq 0x26008
xorl %r13d, %r13d
testb %r15b, %r15b
jne 0x1f26c
movq 0x28(%rsp), %rax
leaq 0x18(%rax), %rbx
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x49efc
leaq 0xc6970(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
jbe 0x1f26c
movq 0xb8(%rsp), %r14
leaq 0x18(%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x49efc
leaq 0xc694c(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
jbe 0x1f26c
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x49efc
leaq 0xc6932(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm0
ja 0x1f28f
movq 0x20(%rsp), %rbx
movq 0x138(%rsp), %r15
leaq 0x150(%rsp), %r12
testl %r13d, %r13d
jne 0x1ef8c
jmp 0x1ef89
movq 0x20(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x28(%rsp), %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq *0x48(%rax)
testq %rax, %rax
je 0x1f2c6
movl 0x1c(%rsp), %ecx
movl %ecx, 0x9c(%rax)
movl 0x14(%rsp), %ecx
movl %ecx, 0x98(%rax)
jmp 0x1f271
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x70682
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x70682
movl 0x3c(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x70682
movq 0x78(%rsp), %rsi
cmpq 0x80(%rsp), %rsi
je 0x1f31b
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x78(%rsp)
jmp 0x1f32a
leaq 0x70(%rsp), %rdi
leaq 0x14(%rsp), %rdx
callq 0x26008
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x1f34a
movl 0x1c(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x1f271
leaq 0x50(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
callq 0x26008
jmp 0x1f271
cmpl $0x3, 0x3c(%rsp)
jl 0x1f471
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x30(%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 0x1f40d
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 0x1f40d
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)
movq %r15, %rbx
testq %rax, %rax
je 0x1f458
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x1f435
movl (%rcx,%r13,4), %ecx
movl %ecx, 0x98(%rax)
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0x1f458
movl (%rcx,%r13,4), %ecx
movl %ecx, 0x9c(%rax)
addq $0x3, %rbp
movslq 0x3c(%rsp), %rax
addq $-0x3, %rax
incq %r13
cmpq %rax, %rbp
jle 0x1f36e
movq 0x90(%rsp), %rdi
callq 0xe430
movl $0x1, %ebx
jmp 0x1f49c
leaq 0x82f31(%rip), %rdi     # 0xa23bd
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x72a1e
jmp 0x1f508
xorl %ebx, %ebx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1f4b3
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1f4cd
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
leaq 0x30(%rsp), %rdi
callq 0x70656
leaq 0xf0(%rsp), %rdi
callq 0x70656
leaq 0xc0(%rsp), %rdi
callq 0x70656
leaq 0xd0(%rsp), %rdi
callq 0x70656
leaq 0x48(%rsp), %rdi
callq 0x248d4
movl %ebx, %eax
addq $0x9b8, %rsp            # imm = 0x9B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f5bc
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x1f5bf
movq 0x128(%rsp), %rsi
jmp 0x1f565
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
movq %rax, %rbx
movq 0x140(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f5bf
movq 0x150(%rsp), %rsi
incq %rsi
jmp 0x1f589
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
movq %rax, %rbx
movl $0x18, %esi
jmp 0x1f586
jmp 0x1f5bc
jmp 0x1f5bc
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
callq 0xe450
jmp 0x1f5bf
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
movq %rax, %rbx
jmp 0x1f5fa
movq %rax, %rbx
jmp 0x1f607
movq %rax, %rbx
jmp 0x1f614
movq %rax, %rbx
jmp 0x1f621
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
jmp 0x1f5bc
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1f5d6
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1f5f0
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
leaq 0x30(%rsp), %rdi
callq 0x70656
leaq 0xf0(%rsp), %rdi
callq 0x70656
leaq 0xc0(%rsp), %rdi
callq 0x70656
leaq 0xd0(%rsp), %rdi
callq 0x70656
leaq 0x48(%rsp), %rdi
callq 0x248d4
movq %rbx, %rdi
callq 0xe7e0
nop