// File: /workspace/github_cpp_makefile_star2_O3/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 $0x728, %rsp            # imm = 0x728
movsd %xmm0, (%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbp
leaq 0x1d8(%rsp), %r12
movq %r12, %rdi
callq 0xc0cf4
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x15a10
movq %rbp, 0x20(%rsp)
movq 0x8(%rbp), %r12
testq %r12, %r12
je 0x1bef1
movq 0x10(%r12), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x1befa
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x428ca
movq %rax, 0x98(%rsp)
testq %rax, %rax
je 0x1bf0c
movq %r12, %rdi
movq %r14, %rsi
callq 0x3a6a0
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x1bf1a
leaq 0x1e8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6c174
movq %rbx, %rdi
movq %r13, %rsi
callq 0x79168
testl %eax, %eax
je 0x1bf2f
xorps %xmm0, %xmm0
callq 0xc3029
leaq 0x68(%rsp), %rdi
callq 0xc1290
leaq 0x30(%rsp), %rdi
callq 0xc1290
movq %r12, 0x88(%rsp)
movq %r13, 0x80(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x6c710
movl $0x0, 0x1c(%rsp)
cmpl $0x0, 0x21c(%rsp)
movl $0x0, %ebp
jle 0x1bc5f
leaq 0xf6b65(%rip), %rax     # 0x1120a8
movsd (%rax), %xmm0
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0xebae4(%rip), %xmm2    # 0x107040
cvtsd2ss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd 0xebadc(%rip), %xmm1    # 0x107048
addsd 0xebadc(%rip), %xmm1    # 0x107050
divsd %xmm0, %xmm2
movsd %xmm2, 0xa0(%rsp)
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss 0xebb50(%rip), %xmm1    # 0x1070e0
minss %xmm0, %xmm1
cvttss2si %xmm1, %eax
movl %eax, 0x4c(%rsp)
xorl %ecx, %ecx
xorl %ebp, %ebp
movq 0x210(%rsp), %rax
movq %rcx, 0xb0(%rsp)
movq (%rax,%rcx,8), %r14
movl 0x9c(%r14), %r15d
testl %r15d, %r15d
jns 0x1b5c7
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 0x1b611
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpl 0x2c(%rax), %ecx
jge 0x1b611
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x68(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movl 0x74(%rsp), %edx
cmpl %r15d, %edx
jg 0x1b634
leaq 0x68(%rsp), %rdi
xorl %esi, %esi
callq 0xc1326
jmp 0x1b611
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0xc1326
movl 0x3c(%rsp), %edx
cmpl %r15d, %edx
jle 0x1b628
movq 0x30(%rsp), %rax
movq (%rax,%rbx,8), %r15
testq %r15, %r15
jne 0x1b669
movl $0x10, %edi
callq 0x15610
movq %rax, %r15
movq %rax, %rdi
callq 0xc1290
movq 0x30(%rsp), %rax
movq %r15, (%rax,%rbx,8)
movq 0x8(%r14), %rax
movq 0x10(%r14), %rbx
movq 0x18(%r14), %r12
movq %rax, 0xc8(%rsp)
leaq 0x18(%rax), %rsi
leaq 0x320(%rsp), %rdi
callq 0x9bee2
leaq 0x18(%rbx), %rsi
leaq 0x1c0(%rsp), %rdi
callq 0x9bee2
movq %r15, 0xb8(%rsp)
leaq 0x18(%r12), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x9bee2
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
leaq 0x130(%rsp), %r15
movq %r15, %rdi
callq 0x9c966
leaq 0x320(%rsp), %rdi
movq %r15, %rsi
callq 0x9c83a
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movq %r15, %rdi
callq 0x9c966
leaq 0x1c0(%rsp), %rdi
movq %r15, %rsi
callq 0x9c83a
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movq %r15, %rdi
callq 0x9c966
leaq 0x1a8(%rsp), %rdi
movq %r15, %rsi
callq 0x9c83a
testb $0x2, 0xa8(%r14)
jne 0x1b762
movq 0x1e8(%rsp), %rax
leaq 0x1e8(%rsp), %rdi
movq %r14, %rsi
callq *0x2c0(%rax)
movq %rbx, 0xc0(%rsp)
movsd 0x90(%r14), %xmm0
movapd %xmm0, (%rsp)
callq 0xc306c
movapd (%rsp), %xmm2
mulsd 0xa0(%rsp), %xmm2
cvttpd2dq %xmm2, %xmm1
cvtdq2pd %xmm1, %xmm1
movapd %xmm2, (%rsp)
subsd %xmm1, %xmm2
xorl %r13d, %r13d
ucomisd %xmm0, %xmm2
seta %r15b
testb $0x4, 0xa8(%r14)
jne 0x1b7ca
movq 0x1e8(%rsp), %rax
leaq 0x1e8(%rsp), %rdi
movq %r14, %rsi
callq *0x2c8(%rax)
leaq 0x38(%r14), %rsi
leaq 0x130(%rsp), %rdi
callq 0x9c976
leaq 0x1e8(%rsp), %rdi
movq %r14, %rsi
callq 0x6e802
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
addq $0x18, %rsi
addq $0x18, %rdx
leaq 0x190(%rsp), %r14
movq %r14, %rdi
callq 0x9c12e
movq %r14, %rdi
callq 0x9cc7c
cvttsd2si (%rsp), %edx
movb %r15b, %r13b
leal (%rdx,%r13), %r15d
testl %r15d, %r15d
jle 0x1bc43
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)
addl %ebp, %edx
addl %r13d, %edx
movq %rdx, 0xa8(%rsp)
incl %ebp
callq 0xc306c
leaq 0x178(%rsp), %r14
leaq 0x160(%rsp), %r13
ucomisd 0xeb7fe(%rip), %xmm0    # 0x107070
jb 0x1b87a
sqrtsd %xmm0, %xmm0
jmp 0x1b87f
callq 0x154d0
movsd %xmm0, (%rsp)
callq 0xc306c
movsd %xmm0, 0x78(%rsp)
movsd 0xeb779(%rip), %xmm0    # 0x107010
subsd (%rsp), %xmm0
movq %r14, %rdi
leaq 0x320(%rsp), %rsi
movsd %xmm0, 0xd8(%rsp)
callq 0x9c916
movsd 0xeb753(%rip), %xmm0    # 0x107010
subsd 0x78(%rsp), %xmm0
mulsd (%rsp), %xmm0
movq %r13, %rdi
leaq 0x1c0(%rsp), %rsi
movsd %xmm0, 0xd0(%rsp)
callq 0x9c916
leaq 0xe0(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x9c8d0
movsd (%rsp), %xmm0
mulsd 0x78(%rsp), %xmm0
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1a8(%rsp), %rsi
movsd %xmm0, (%rsp)
callq 0x9c916
leaq 0x110(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movq %rbx, %rdx
callq 0x9c8d0
movq 0xc8(%rsp), %rax
movsd 0x58(%rax), %xmm0
movsd 0xd8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%rax), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%rax), %xmm2
movq %r13, %rdi
callq 0xc1104
movq 0xc0(%rsp), %rax
movsd 0x58(%rax), %xmm0
movsd 0xd0(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%rax), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%rax), %xmm2
leaq 0xf8(%rsp), %rdi
callq 0xc1104
movsd 0x160(%rsp), %xmm0
movsd 0x168(%rsp), %xmm1
addsd 0xf8(%rsp), %xmm0
addsd 0x100(%rsp), %xmm1
movsd 0x170(%rsp), %xmm2
addsd 0x108(%rsp), %xmm2
movq %r14, %rdi
callq 0xc1104
movsd 0x58(%r12), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x60(%r12), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x68(%r12), %xmm2
leaq 0x148(%rsp), %rdi
callq 0xc1104
movsd 0x178(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
addsd 0x148(%rsp), %xmm0
addsd 0x150(%rsp), %xmm1
movsd 0x188(%rsp), %xmm2
addsd 0x158(%rsp), %xmm2
leaq 0xe0(%rsp), %rdi
callq 0xc1104
movsd 0x120(%rsp), %xmm0
subsd 0x2f8(%rsp), %xmm0
mulsd 0xeb5f5(%rip), %xmm0    # 0x107058
addsd 0xeb5f5(%rip), %xmm0    # 0x107060
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 0x2d638
xorps %xmm0, %xmm0
cvtsd2ss 0x120(%rsp), %xmm0
cvtpd2ps 0x110(%rsp), %xmm1
movlpd %xmm1, (%r14)
movss %xmm0, 0x8(%r14)
movsd 0xe0(%rsp), %xmm0
movsd 0xeb56a(%rip), %xmm1    # 0x107038
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movsd 0xe8(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0xf0(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
movb %al, 0x2c(%r14)
movb %cl, 0x2d(%r14)
xorps %xmm0, %xmm0
cvtsd2ss 0x140(%rsp), %xmm0
cvtpd2ps 0x130(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
mulsd 0xeb544(%rip), %xmm2    # 0x107068
addsd 0xeb524(%rip), %xmm2    # 0x107050
cvttsd2si %xmm2, %eax
movb %dl, 0x2e(%r14)
cvtps2pd %xmm1, %xmm2
mulpd 0xeb551(%rip), %xmm2    # 0x107090
addpd 0xeb559(%rip), %xmm2    # 0x1070a0
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 0x1bb77
jp 0x1bb77
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
ucomiss %xmm3, %xmm1
jne 0x1bb77
jp 0x1bb77
ucomiss %xmm3, %xmm0
jne 0x1bb77
jnp 0x1bb7c
orb $0x40, 0x2f(%r14)
xorps %xmm0, %xmm0
cvtsd2ss 0x1a0(%rsp), %xmm0
cvtpd2ps 0x190(%rsp), %xmm1
cvtps2pd %xmm1, %xmm2
mulpd 0xeb4f4(%rip), %xmm2    # 0x107090
addpd 0xeb4fc(%rip), %xmm2    # 0x1070a0
cvttpd2dq %xmm2, %xmm2
pshuflw $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,3,4,5,6,7]
movd %xmm2, 0x16(%r14)
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
mulsd 0xeb4a6(%rip), %xmm2    # 0x107068
addsd 0xeb486(%rip), %xmm2    # 0x107050
cvttsd2si %xmm2, %eax
movw %ax, 0x1a(%r14)
ucomiss %xmm3, %xmm1
movb 0x2f(%r14), %al
jne 0x1bbf0
jp 0x1bbf0
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
ucomiss %xmm3, %xmm1
jne 0x1bbf0
jp 0x1bbf0
ucomiss %xmm3, %xmm0
jne 0x1bbf0
jnp 0x1bbf6
orb $0x1, %al
movb %al, 0x2f(%r14)
shll $0x10, %r13d
orl 0x28(%rsp), %r13d
movl 0x4c(%rsp), %ecx
movw %cx, 0x1c(%r14)
movw %cx, 0x1e(%r14)
movl %ebp, 0x20(%r14)
movl %r13d, 0x24(%r14)
andb $-0x3, %al
movb %al, 0x2f(%r14)
movq 0xb8(%rsp), %rdi
movl 0xc(%rdi), %edx
movq %r14, %rsi
callq 0xc1326
incl %ebp
decl %r15d
jne 0x1b855
movq 0xa8(%rsp), %rax
movl %eax, %ebp
movq 0xb0(%rsp), %rcx
incq %rcx
movslq 0x21c(%rsp), %rax
cmpq %rax, %rcx
jl 0x1b5a0
movl 0x3c(%rsp), %eax
testl %eax, %eax
jle 0x1be6b
xorl %r12d, %r12d
movl $0x0, 0x1c(%rsp)
movq 0x30(%rsp), %rcx
movq (%rcx,%r12,8), %r13
testq %r13, %r13
je 0x1be5c
movq 0x68(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, (%rsp)
leaq 0x320(%rsp), %rdi
leaq 0xebd8e(%rip), %rsi     # 0x107a32
movl %r12d, %edx
xorl %eax, %eax
callq 0x15110
movl $0xf8, %edi
callq 0x15610
movq %rax, %r14
movq %rax, %rdi
leaq 0x320(%rsp), %rsi
callq 0x3fe08
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq 0x98(%rsp), %rdx
callq *0x18(%rax)
movl $0xd0, %edi
callq 0x15610
movq %rax, %rbx
movq %rax, %rdi
leaq 0x320(%rsp), %rsi
callq 0x387f0
movq 0x88(%rsp), %rdi
movq %rbx, %rsi
movq 0x90(%rsp), %rdx
callq 0x3a596
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41076
movl $0xc8, %edi
callq 0x15610
movq %rax, %r15
xorps %xmm0, %xmm0
movq %rax, %rdi
movq %r13, %rsi
leaq 0x50(%rsp), %rdx
callq 0x2e8c4
movq %r15, %rdi
callq 0x304d8
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x28(%rax)
movq %rbx, %rdi
callq 0x39820
movq %r14, %rdi
callq 0x415c4
cmpq $0x0, (%rsp)
je 0x1bdb1
movl $0x50, %edi
callq 0x15610
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
movsd 0xeb277(%rip), %xmm0    # 0x107010
xorl %ecx, %ecx
callq 0x420bc
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x80(%rax)
movl 0xb4(%r15), %eax
cmpl $0x1, %eax
jne 0x1bde0
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
movl 0x28(%rdi), %ecx
movq %r15, %rsi
callq *0x90(%rax)
testl %eax, %eax
je 0x1be18
movl 0xb4(%r15), %eax
decl %eax
movl %eax, 0xb4(%r15)
jne 0x1be18
testb $0x2, 0x89(%r15)
je 0x1be18
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x18(%rax)
movq %r15, %rdi
callq 0x2ef26
movl $0xc8, %esi
movq %r15, %rdi
callq 0x15620
cmpl $0x0, 0xc(%r13)
jle 0x1be3f
xorl %ebx, %ebx
movq (%r13), %rax
movq (%rax,%rbx,8), %rdi
movl $0x30, %esi
callq 0x15620
incq %rbx
movslq 0xc(%r13), %rax
cmpq %rax, %rbx
jl 0x1be21
movq %r13, %rdi
callq 0xc12fa
movl $0x10, %esi
movq %r13, %rdi
callq 0x15620
incl 0x1c(%rsp)
movl 0x3c(%rsp), %eax
incq %r12
movslq %eax, %rcx
cmpq %rcx, %r12
jl 0x1bc76
cmpl $0x0, 0x150f4a(%rip)    # 0x16cdbc
je 0x1bed6
leaq 0xebbc7(%rip), %rdi     # 0x107a42
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0x15080
leaq 0x1d8(%rsp), %rdi
callq 0xc0d56
leaq 0xeb714(%rip), %rdi     # 0x1075b2
movb $0x1, %al
callq 0x15080
leaq 0xeb7ab(%rip), %rdi     # 0x107657
movl 0x1c(%rsp), %esi
xorl %eax, %eax
callq 0x15080
leaq 0xebba5(%rip), %rdi     # 0x107a63
movl %ebp, %esi
xorl %eax, %eax
callq 0x15080
movq 0x150092(%rip), %rax    # 0x16bf60
movq (%rax), %rdi
callq 0x15750
leaq 0x30(%rsp), %rdi
callq 0xc12fa
leaq 0x68(%rsp), %rdi
callq 0xc12fa
movl $0x1, %ebx
jmp 0x1bf42
leaq 0xeb801(%rip), %rdi     # 0x1076f9
jmp 0x1bf03
leaq 0xeb8b0(%rip), %rdi     # 0x1077b1
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xc3e02
jmp 0x1bf4f
leaq 0xeb822(%rip), %rdi     # 0x107735
xorl %ebx, %ebx
movq %r15, %rsi
jmp 0x1bf26
leaq 0xeb7eb(%rip), %rdi     # 0x10770c
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xc3e02
jmp 0x1bf4f
xorl %ebx, %ebx
leaq 0xebadd(%rip), %rdi     # 0x107a15
movq %r13, %rsi
xorl %eax, %eax
callq 0xc3e02
leaq 0x1e8(%rsp), %rdi
callq 0x6c6b2
movl %ebx, %eax
addq $0x728, %rsp            # imm = 0x728
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
jmp 0x1c005
jmp 0x1bf72
jmp 0x1bff8
movq %rax, %r12
jmp 0x1c00f
jmp 0x1bff8
movq %rax, %r12
movl $0x10, %esi
jmp 0x1bfa4
movq %rax, %r12
movl $0x50, %esi
jmp 0x1bfb1
jmp 0x1bff8
movq %rax, %r12
movl $0xf8, %esi
jmp 0x1bfe0
movq %rax, %r12
movl $0xc8, %esi
movq %r15, %rdi
jmp 0x1bfe3
movq %rax, %r12
movl $0xd0, %esi
movq %rbx, %rdi
jmp 0x1bfe3
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
movq %rax, %r12
movl $0x30, %esi
movq %r14, %rdi
callq 0x15620
jmp 0x1bffb
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
jmp 0x1bff8
movq %rax, %r12
leaq 0x30(%rsp), %rdi
callq 0xc12fa
leaq 0x68(%rsp), %rdi
callq 0xc12fa
leaq 0x1e8(%rsp), %rdi
callq 0x6c6b2
movq %r12, %rdi
callq 0x15ad0