// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: LoadSurfelsFromMesh(gaps::R3SurfelScene*, char const*, char const*, char const*, double)
static int
LoadSurfelsFromMesh(R3SurfelScene *scene, const char *mesh_filename, 
  const char *parent_object_name, const char *parent_node_name,
  RNLength surfel_spacing = 0.01)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  int surfel_count = 0;
  int node_count = 0;

  // Get surfel tree
  R3SurfelTree *tree = scene->Tree();
  if (!tree) {
    RNFail("Scene has no tree\n");
    return 0;
  }    

  // Get surfel database
  R3SurfelDatabase *database = tree->Database();
  if (!database) {
    RNFail("Scene has no database\n");
    return 0;
  }    

  // Find parent object
  R3SurfelObject *parent_object = scene->FindObjectByName(parent_object_name);
  if (!parent_object) {
    RNFail("Unable to find parent object with name %s\n", parent_object_name);
    return 0;
  }

  // Find parent node
  R3SurfelNode *parent_node = tree->FindNodeByName(parent_node_name);
  if (!parent_node) {
    RNFail("Unable to find parent node with name %s\n", parent_node_name);
    return 0;
  }

  // Read mesh file
  R3Mesh mesh;
  if (!mesh.ReadFile(mesh_filename)) {
    RNFail("Unable to read mesh from %s\n", mesh_filename);
    return 0;
  }

  // Create surfels for every mesh segment
  RNSeedRandomScalar();
  RNArray<R3SurfelLabel *> labels;
  RNArray<RNArray<R3Surfel *> *> surfels;
  R3Point mesh_centroid = mesh.Centroid();
  for (int i = 0; i < mesh.NFaces(); i++) {
    R3MeshFace *face = mesh.Face(i);
    int segment_index = mesh.FaceSegment(face);
    if (segment_index < 0) segment_index = mesh.FaceMaterial(face);
    if (segment_index < 0) segment_index = 0;

    // Get label
    int label_index = mesh.FaceCategory(face);
    if ((label_index >= 0) && (label_index < scene->NLabels())) {
      R3SurfelLabel *label = scene->Label(label_index);
      labels[segment_index] = label;
    }

    // Get/create array of surfels for segment
    while (labels.NEntries() <= segment_index) labels.Insert(NULL);
    while (surfels.NEntries() <= segment_index) surfels.Insert(NULL);
    RNArray<R3Surfel *> *segment_surfels = surfels[segment_index];
    if (!segment_surfels) {
      segment_surfels = new RNArray<R3Surfel *>();
      surfels[segment_index] = segment_surfels;
    }

    // Get vertex positions
    R3MeshVertex *v0 = mesh.VertexOnFace(face, 0);
    R3MeshVertex *v1 = mesh.VertexOnFace(face, 1);
    R3MeshVertex *v2 = mesh.VertexOnFace(face, 2);
    R3Point p0 = mesh.VertexPosition(v0);
    R3Point p1 = mesh.VertexPosition(v1);
    R3Point p2 = mesh.VertexPosition(v2);
    // const R3Vector& n0 = mesh.VertexNormal(v0);
    // const R3Vector& n1 = mesh.VertexNormal(v1);
    // const R3Vector& n2 = mesh.VertexNormal(v2);
    const RNRgb& c0 = mesh.VertexColor(v0);
    const RNRgb& c1 = mesh.VertexColor(v1);
    const RNRgb& c2 = mesh.VertexColor(v2);

    // Translate vertices by mesh centroid
    p0 -= mesh_centroid.Vector();
    p1 -= mesh_centroid.Vector();
    p2 -= mesh_centroid.Vector();

    // Determine number of surfels for face
    RNScalar surfels_per_area = 4.0 / (RN_PI * surfel_spacing * surfel_spacing);
    RNScalar ideal_face_nsurfels = surfels_per_area * mesh.FaceArea(face);
    int face_nsurfels = (int) ideal_face_nsurfels;
    RNScalar remainder = ideal_face_nsurfels - face_nsurfels;
    if (remainder > RNRandomScalar()) face_nsurfels++;

    // Get normal, tangent, etc.
    R3Vector normal = mesh.FaceNormal(face);
    R3MeshEdge *edge = mesh.LongestEdgeOnFace(face);
    R3Vector tangent = mesh.EdgeVector(edge); tangent.Normalize();
    RNLength radius = surfel_spacing;
    
    // Generate random surfels on face
    for (int j = 0; j < face_nsurfels; j++) {
      RNScalar r1 = sqrt(RNRandomScalar());
      RNScalar r2 = RNRandomScalar();
      RNScalar t0 = (1.0 - r1);
      RNScalar t1 = r1 * (1.0 - r2);
      RNScalar t2 = r1 * r2;
      R3Point position = t0*p0 + t1*p1 + t2*p2;
      RNRgb color = t0*c0 + t1*c1 + t2*c2;
      int category = label_index;
      if (category < 0) category = 0;
      if (category > 255) category = 255;
      double elevation = position.Z() - mesh.BBox().ZMin();
      int encoded_elevation = 400 * elevation + 32768;
      if (encoded_elevation < 0) encoded_elevation = 0;
      if (encoded_elevation > 65535) encoded_elevation = 65535;
      unsigned int attribute = category | (encoded_elevation << 16);
      R3Surfel *surfel = new R3Surfel();
      surfel->SetPosition(position.X(), position.Y(), position.Z());
      surfel->SetColor(255*color.R(), 255*color.G(), 255*color.B());
      surfel->SetNormal(normal.X(), normal.Y(), normal.Z());
      surfel->SetTangent(tangent.X(), tangent.Y(), tangent.Z());
      surfel->SetRadius(radius);
      surfel->SetIdentifier(surfel_count+1);
      surfel->SetAttribute(attribute);
      surfel->SetAerial(FALSE);
      segment_surfels->Insert(surfel);
      surfel_count++;
    }
  }

  // Create surfel blocks/nodes
  for (int i = 0; i < surfels.NEntries(); i++) {
    R3SurfelLabel *label = labels.Kth(i);
    RNArray<R3Surfel *> *segment_surfels = surfels.Kth(i);
    if (!segment_surfels) continue;

    // Compute segment name
    char segment_name[1024];
    sprintf(segment_name, "MESH_SEGMENT_%d", i);

    // Create object
    R3SurfelObject *object = new R3SurfelObject(segment_name);
     if (!object) {
      RNFail("Unable to allocate object\n");
      return 0;
    }
   
    // Insert object into scene
    scene->InsertObject(object, parent_object);

    // Create node
    R3SurfelNode *node = new R3SurfelNode(segment_name);
    if (!node) {
      RNFail("Unable to allocate node\n");
      return 0;
    }
            
    // Insert node into tree
    tree->InsertNode(node, parent_node);
          
    // Insert node into object
    object->InsertNode(node);

    // Create block
    RNArray<const R3Surfel *>& tmp = *((RNArray<const R3Surfel *> *) segment_surfels);
    R3SurfelBlock *block = new R3SurfelBlock(tmp, mesh_centroid);
    if (!block) {
      RNFail("Unable to allocate block\n");
      return 0;
    }
    
    // Update block properties
    block->UpdateProperties();
          
    // Insert block into database
    database->InsertBlock(block);
            
    // Insert block into node
    node->InsertBlock(block);
          
    // Update node properties
    node->UpdateProperties();
          
    // Update object properties
    object->UpdateProperties();

    // Create label assignment
    if (label) {
      int originator = R3_SURFEL_HUMAN_ORIGINATOR;
      R3SurfelLabelAssignment *assignment = new R3SurfelLabelAssignment(object, label, 1.0, originator);
      scene->InsertLabelAssignment(assignment);
    }

    // Release block
    database->ReleaseBlock(block);

    // Delete segment surfel arrays    
    for (int j = 0; j < segment_surfels->NEntries(); j++)
      delete segment_surfels->Kth(j);
    delete segment_surfels;

    // Increment statistics
    node_count++;
  }
  
  // Print statistics
  if (print_verbose) {
    printf("Loaded surfels from mesh %s ...\n", mesh_filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Objects = %d\n", node_count);
    printf("  # Surfels = %d\n", surfel_count);
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x718, %rsp            # imm = 0x718
movsd %xmm0, (%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbp
leaq 0x1c8(%rsp), %r12
movq %r12, %rdi
callq 0xc2368
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x15a20
movq %rbp, 0x20(%rsp)
movq 0x8(%rbp), %r12
testq %r12, %r12
je 0x1c10b
movq 0x10(%r12), %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0x1c114
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x42dac
movq %rax, 0x98(%rsp)
testq %rax, %rax
je 0x1c129
movq %r12, %rdi
movq %r14, %rsi
callq 0x3aaf0
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x1c137
leaq 0x1d8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6d060
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7a07e
testl %eax, %eax
je 0x1c14f
xorps %xmm0, %xmm0
callq 0xc4905
leaq 0x70(%rsp), %rdi
callq 0xc2904
leaq 0x38(%rsp), %rdi
callq 0xc2904
movq %r12, 0x88(%rsp)
movq %r13, 0x80(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x6d5ec
movl $0x0, 0x1c(%rsp)
cmpl $0x0, 0x20c(%rsp)
movl $0x0, %ebp
jle 0x1beea
leaq 0xf88c7(%rip), %rax     # 0x1140b8
movsd (%rax), %xmm0
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0xed836(%rip), %xmm2    # 0x109040
cvtsd2ss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd 0xed82e(%rip), %xmm1    # 0x109048
addsd 0xed82e(%rip), %xmm1    # 0x109050
divsd %xmm0, %xmm2
movsd %xmm2, 0xa0(%rsp)
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0xed8a2(%rip), %xmm1    # 0x1090e0
minss %xmm0, %xmm1
cvttss2si %xmm1, %eax
movl %eax, 0x54(%rsp)
xorl %ecx, %ecx
xorl %ebp, %ebp
movq 0x200(%rsp), %rax
movq %rcx, 0xa8(%rsp)
movq (%rax,%rcx,8), %r14
movl 0x9c(%r14), %r15d
testl %r15d, %r15d
jns 0x1b875
movl 0x98(%r14), %r15d
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
movslq 0xa0(%r14), %rcx
movl %r15d, %ebx
movq %rcx, 0x28(%rsp)
testq %rcx, %rcx
js 0x1b8bf
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpl 0x2c(%rax), %ecx
jge 0x1b8bf
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x70(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movl 0x7c(%rsp), %edx
cmpl %r15d, %edx
jg 0x1b8e2
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0xc299a
jmp 0x1b8bf
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0xc299a
movl 0x44(%rsp), %edx
cmpl %r15d, %edx
jle 0x1b8d6
movq 0x38(%rsp), %rax
movq (%rax,%rbx,8), %r15
testq %r15, %r15
jne 0x1b917
movl $0x10, %edi
callq 0x15610
movq %rax, %r15
movq %rax, %rdi
callq 0xc2904
movq 0x38(%rsp), %rax
movq %r15, (%rax,%rbx,8)
movq 0x8(%r14), %rax
movq 0x10(%r14), %rbx
movq 0x18(%r14), %r12
movq %rax, 0xb8(%rsp)
leaq 0x18(%rax), %rsi
leaq 0x310(%rsp), %rdi
callq 0x9d292
leaq 0x18(%rbx), %rsi
leaq 0x1b0(%rsp), %rdi
callq 0x9d292
movq %r15, 0xb0(%rsp)
leaq 0x18(%r12), %rsi
leaq 0x198(%rsp), %rdi
callq 0x9d292
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
leaq 0x150(%rsp), %r15
movq %r15, %rdi
callq 0x9dd1a
leaq 0x310(%rsp), %rdi
movq %r15, %rsi
callq 0x9dbf0
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movq %r15, %rdi
callq 0x9dd1a
leaq 0x1b0(%rsp), %rdi
movq %r15, %rsi
callq 0x9dbf0
movsd 0x58(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movq %r15, %rdi
callq 0x9dd1a
leaq 0x198(%rsp), %rdi
movq %r15, %rsi
callq 0x9dbf0
testb $0x2, 0xa8(%r14)
jne 0x1ba10
movq 0x1d8(%rsp), %rax
leaq 0x1d8(%rsp), %rdi
movq %r14, %rsi
callq *0x2c0(%rax)
movsd 0x90(%r14), %xmm0
movapd %xmm0, (%rsp)
callq 0xc4948
movapd (%rsp), %xmm2
mulsd 0xa0(%rsp), %xmm2
cvttpd2dq %xmm2, %xmm1
cvtdq2pd %xmm1, %xmm1
movapd %xmm2, (%rsp)
subsd %xmm1, %xmm2
xorl %r15d, %r15d
ucomisd %xmm0, %xmm2
seta %r13b
testb $0x4, 0xa8(%r14)
jne 0x1ba70
movq 0x1d8(%rsp), %rax
leaq 0x1d8(%rsp), %rdi
movq %r14, %rsi
callq *0x2c8(%rax)
leaq 0x38(%r14), %rsi
leaq 0x150(%rsp), %rdi
callq 0x9dd2a
leaq 0x1d8(%rsp), %rdi
movq %r14, %rsi
callq 0x6f65e
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
addq $0x18, %rsi
addq $0x18, %rdx
leaq 0x180(%rsp), %r14
movq %r14, %rdi
callq 0x9d4e4
movq %r14, %rdi
callq 0x9e03c
cvttsd2si (%rsp), %eax
movb %r13b, %r15b
addl %eax, %r15d
testl %r15d, %r15d
jle 0x1bece
movq 0x28(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
movl $0xff, %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movq %rcx, 0x28(%rsp)
leaq 0x118(%rsp), %r14
callq 0xc4948
ucomisd 0xed570(%rip), %xmm0    # 0x109070
jb 0x1bb08
sqrtsd %xmm0, %xmm0
jmp 0x1bb0d
callq 0x154d0
movsd %xmm0, (%rsp)
callq 0xc4948
movsd %xmm0, 0x30(%rsp)
movsd 0xed4eb(%rip), %xmm0    # 0x109010
subsd (%rsp), %xmm0
movq %r14, %rdi
leaq 0x310(%rsp), %rsi
movsd %xmm0, 0xc8(%rsp)
callq 0x9dccc
movsd 0xed4c5(%rip), %xmm0    # 0x109010
subsd 0x30(%rsp), %xmm0
mulsd (%rsp), %xmm0
leaq 0x100(%rsp), %r13
movq %r13, %rdi
leaq 0x1b0(%rsp), %rsi
movsd %xmm0, 0xc0(%rsp)
callq 0x9dccc
leaq 0xd0(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x9dc86
movsd (%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
leaq 0xe8(%rsp), %r13
movq %r13, %rdi
leaq 0x198(%rsp), %rsi
movsd %xmm0, (%rsp)
callq 0x9dccc
leaq 0x130(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
movq %r13, %rdx
callq 0x9dc86
movq 0xb8(%rsp), %rax
movsd 0x58(%rax), %xmm0
movsd 0xc8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%rax), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%rax), %xmm2
leaq 0x100(%rsp), %rdi
callq 0xc2778
movsd 0x58(%rbx), %xmm0
movsd 0xc0(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%rbx), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%rbx), %xmm2
leaq 0xe8(%rsp), %rdi
callq 0xc2778
movsd 0x100(%rsp), %xmm0
movsd 0x108(%rsp), %xmm1
addsd 0xe8(%rsp), %xmm0
addsd 0xf0(%rsp), %xmm1
movsd 0x110(%rsp), %xmm2
addsd 0xf8(%rsp), %xmm2
movq %r14, %rdi
callq 0xc2778
movsd 0x58(%r12), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%r12), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%r12), %xmm2
leaq 0x168(%rsp), %rdi
callq 0xc2778
movsd 0x118(%rsp), %xmm0
movsd 0x120(%rsp), %xmm1
addsd 0x168(%rsp), %xmm0
addsd 0x170(%rsp), %xmm1
movsd 0x128(%rsp), %xmm2
addsd 0x178(%rsp), %xmm2
leaq 0xd0(%rsp), %rdi
callq 0xc2778
movsd 0x140(%rsp), %xmm0
subsd 0x2e8(%rsp), %xmm0
mulsd 0xed362(%rip), %xmm0    # 0x109058
addsd 0xed362(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %r13d
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movl $0xffff, %eax           # imm = 0xFFFF
cmpl %eax, %r13d
cmovgel %eax, %r13d
movl $0x30, %edi
callq 0x15610
movq %rax, %r14
movq %rax, %rdi
callq 0x2db44
xorps %xmm0, %xmm0
cvtsd2ss 0x140(%rsp), %xmm0
cvtpd2ps 0x130(%rsp), %xmm1
movlpd %xmm1, (%r14)
movss %xmm0, 0x8(%r14)
movsd 0xd0(%rsp), %xmm0
movsd 0xed2d7(%rip), %xmm1    # 0x109038
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movsd 0xd8(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0xe0(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
movb %al, 0x2c(%r14)
movb %cl, 0x2d(%r14)
xorps %xmm0, %xmm0
cvtsd2ss 0x160(%rsp), %xmm0
cvtpd2ps 0x150(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
mulsd 0xed2b1(%rip), %xmm2    # 0x109068
addsd 0xed291(%rip), %xmm2    # 0x109050
cvttsd2si %xmm2, %eax
movb %dl, 0x2e(%r14)
cvtps2pd %xmm1, %xmm2
mulpd 0xed2be(%rip), %xmm2    # 0x109090
addpd 0xed2c6(%rip), %xmm2    # 0x1090a0
cvttpd2dq %xmm2, %xmm2
pshuflw $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,3,4,5,6,7]
movd %xmm2, 0x10(%r14)
movw %ax, 0x14(%r14)
xorps %xmm3, %xmm3
ucomiss %xmm3, %xmm1
jne 0x1be0a
jp 0x1be0a
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
ucomiss %xmm3, %xmm1
jne 0x1be0a
jp 0x1be0a
ucomiss %xmm3, %xmm0
jne 0x1be0a
jnp 0x1be0f
orb $0x40, 0x2f(%r14)
xorps %xmm0, %xmm0
cvtsd2ss 0x190(%rsp), %xmm0
cvtpd2ps 0x180(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
mulsd 0xed235(%rip), %xmm2    # 0x109068
addsd 0xed215(%rip), %xmm2    # 0x109050
cvttsd2si %xmm2, %eax
cvtps2pd %xmm1, %xmm2
mulpd 0xed246(%rip), %xmm2    # 0x109090
addpd 0xed24e(%rip), %xmm2    # 0x1090a0
cvttpd2dq %xmm2, %xmm2
pshuflw $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,3,4,5,6,7]
movd %xmm2, 0x16(%r14)
movw %ax, 0x1a(%r14)
ucomiss %xmm3, %xmm1
jne 0x1be7f
jp 0x1be7f
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
ucomiss %xmm3, %xmm1
jne 0x1be7f
jp 0x1be7f
ucomiss %xmm3, %xmm0
jne 0x1be7f
jnp 0x1be84
orb $0x1, 0x2f(%r14)
shll $0x10, %r13d
orl 0x28(%rsp), %r13d
movl 0x54(%rsp), %eax
movw %ax, 0x1c(%r14)
movw %ax, 0x1e(%r14)
incl %ebp
movl %ebp, 0x20(%r14)
movl %r13d, 0x24(%r14)
andb $-0x3, 0x2f(%r14)
movq 0xb0(%rsp), %rdi
movl 0xc(%rdi), %edx
movq %r14, %rsi
callq 0xc299a
decl %r15d
leaq 0x118(%rsp), %r14
jne 0x1baf3
movq 0xa8(%rsp), %rcx
incq %rcx
movslq 0x20c(%rsp), %rax
cmpq %rax, %rcx
jl 0x1b84e
cmpl $0x0, 0x44(%rsp)
setg %al
jle 0x1c16b
xorl %r12d, %r12d
movl $0x0, 0x1c(%rsp)
movb %al, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq (%rax,%r12,8), %r13
testq %r13, %r13
je 0x1c0e7
movq 0x70(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, (%rsp)
leaq 0x310(%rsp), %rdi
leaq 0xedb04(%rip), %rsi     # 0x109a39
movl %r12d, %edx
xorl %eax, %eax
callq 0x15110
movl $0xf8, %edi
callq 0x15610
movq %rax, %r15
movq %rax, %rdi
leaq 0x310(%rsp), %rsi
callq 0x40264
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movq 0x98(%rsp), %rdx
callq *0x18(%rax)
movl $0xd0, %edi
callq 0x15610
movq %rax, %rbx
movq %rax, %rdi
leaq 0x310(%rsp), %rsi
callq 0x38bbc
movq 0x88(%rsp), %rdi
movq %rbx, %rsi
movq 0x90(%rsp), %rdx
callq 0x3a9e6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x41532
movl $0xc8, %edi
callq 0x15610
movq %rax, %r14
xorps %xmm0, %xmm0
movq %rax, %rdi
movq %r13, %rsi
leaq 0x58(%rsp), %rdx
callq 0x2ede2
movq %r14, %rdi
callq 0x30960
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rax)
movq %rbx, %rdi
callq 0x39c62
movq %r15, %rdi
callq 0x41aa4
cmpq $0x0, (%rsp)
je 0x1c042
movl $0x50, %edi
callq 0x15610
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
movsd 0xecfe6(%rip), %xmm0    # 0x109010
xorl %ecx, %ecx
callq 0x425a0
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x80(%rax)
cmpl $0x1, 0xb4(%r14)
jne 0x1c068
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
movl 0x28(%rdi), %ecx
movq %r14, %rsi
callq *0x90(%rax)
testl %eax, %eax
je 0x1c09e
decl 0xb4(%r14)
jne 0x1c09e
testb $0x2, 0x89(%r14)
je 0x1c09e
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rdi
callq 0x2f42a
movl $0xc8, %esi
movq %r14, %rdi
callq 0x15620
cmpl $0x0, 0xc(%r13)
jle 0x1c0ca
xorl %ebx, %ebx
movq (%r13), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x1c0be
movl $0x30, %esi
callq 0x15620
incq %rbx
movslq 0xc(%r13), %rax
cmpq %rax, %rbx
jl 0x1c0a7
movq %r13, %rdi
callq 0xc296e
movl $0x10, %esi
movq %r13, %rdi
callq 0x15620
incl 0x1c(%rsp)
xorl %eax, %eax
jmp 0x1c0ec
movl $0xe, %eax
cmpl $0xe, %eax
je 0x1c0f5
testl %eax, %eax
jne 0x1c167
incq %r12
movslq 0x44(%rsp), %rax
cmpq %rax, %r12
setl %al
jl 0x1bf03
jmp 0x1c16b
leaq 0xed5ee(%rip), %rdi     # 0x109700
jmp 0x1c11d
leaq 0xed69d(%rip), %rdi     # 0x1097b8
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xc5782
jmp 0x1c200
leaq 0xed60c(%rip), %rdi     # 0x10973c
xorl %ebx, %ebx
movq %r15, %rsi
jmp 0x1c143
leaq 0xed5d5(%rip), %rdi     # 0x109713
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xc5782
jmp 0x1c200
xorl %ebx, %ebx
leaq 0xed8c4(%rip), %rdi     # 0x109a1c
movq %r13, %rsi
xorl %eax, %eax
callq 0xc5782
jmp 0x1c1f3
movb 0x30(%rsp), %al
testb $0x1, %al
jne 0x1c1da
cmpl $0x0, 0x152c56(%rip)    # 0x16edcc
je 0x1c1da
leaq 0xed8ca(%rip), %rdi     # 0x109a49
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0x15080
leaq 0x1c8(%rsp), %rdi
callq 0xc23ca
leaq 0xed417(%rip), %rdi     # 0x1095b9
movb $0x1, %al
callq 0x15080
leaq 0xed4ae(%rip), %rdi     # 0x10965e
movl 0x1c(%rsp), %esi
xorl %eax, %eax
callq 0x15080
leaq 0xed8a8(%rip), %rdi     # 0x109a6a
movl %ebp, %esi
xorl %eax, %eax
callq 0x15080
movq 0x151d8e(%rip), %rax    # 0x16df60
movq (%rax), %rdi
callq 0x15760
leaq 0x38(%rsp), %rdi
callq 0xc296e
leaq 0x70(%rsp), %rdi
callq 0xc296e
movl $0x1, %ebx
leaq 0x1d8(%rsp), %rdi
callq 0x6d58e
movl %ebx, %eax
addq $0x718, %rsp            # imm = 0x718
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
jmp 0x1c2b6
jmp 0x1c223
jmp 0x1c2a9
movq %rax, %r12
jmp 0x1c2c0
movq %rax, %r12
movl $0x50, %esi
jmp 0x1c249
jmp 0x1c2a9
movq %rax, %r12
movl $0x10, %esi
jmp 0x1c256
movq %rax, %r12
movl $0xd0, %esi
movq %rbx, %rdi
jmp 0x1c294
movq %rax, %r12
movl $0xf8, %esi
movq %r15, %rdi
jmp 0x1c294
movq %rax, %r12
movl $0xc8, %esi
jmp 0x1c291
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
movq %rax, %r12
movl $0x30, %esi
movq %r14, %rdi
callq 0x15620
jmp 0x1c2ac
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
jmp 0x1c2a9
movq %rax, %r12
leaq 0x38(%rsp), %rdi
callq 0xc296e
leaq 0x70(%rsp), %rdi
callq 0xc296e
leaq 0x1d8(%rsp), %rdi
callq 0x6d58e
movq %r12, %rdi
callq 0x15ae0