// File: tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::DrawSurfels(int) const
void R3SurfelViewer::
DrawSurfels(int color_scheme) const
{
  // Check surfel visibility
  if (!SurfelVisibility()) return;

  // Set default lighting
  glDisable(GL_LIGHTING);

  // Set point size
  if (color_scheme != R3_SURFEL_VIEWER_COLOR_BY_PICK_INDEX) glPointSize(surfel_size);
  else glPointSize(0.01 * Viewport().Width() + 1);

#if (R3_SURFEL_VIEWER_DRAW_METHOD == R3_SURFEL_VIEWER_DRAW_WITH_VBO)
  if (!shape_draw_flags[R3_SURFEL_DISC_DRAW_FLAG]) {
    // Draw with VBO
    DrawVBO(color_scheme);
    glPointSize(1);    
    return;
  }
#endif

  // Draw resident nodes
  switch (color_scheme) {
  case R3_SURFEL_VIEWER_COLOR_BY_PICK_INDEX:
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      LoadColor(color_scheme, NULL, NULL, node, NULL, NULL);
      DrawSurfels(node);
    }
    break;

  case R3_SURFEL_VIEWER_COLOR_BY_CURRENT_LABEL:
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      R3SurfelObject *object = node->Object(TRUE, TRUE);
      while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
      R3SurfelLabel *label = (object) ? object->CurrentLabel() : NULL;
      const RNRgb& rgb = (label) ? label->Color() : RNwhite_rgb;
      RNLoadRgb(rgb);
      DrawSurfels(node);
    }
    break;

  case R3_SURFEL_VIEWER_COLOR_BY_GROUND_TRUTH_LABEL:
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      R3SurfelObject *object = node->Object(TRUE, TRUE);
      while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
      R3SurfelLabel *label = (object) ? object->GroundTruthLabel() : NULL;
      const RNRgb& rgb = (label) ? label->Color() : RNwhite_rgb;
      RNLoadRgb(rgb);
      DrawSurfels(node);
    }
    break;

  case R3_SURFEL_VIEWER_COLOR_BY_SCAN:
    // Draw with colors based on nodes
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      R3SurfelScan *scan = node->Scan();
      int scan_index = (scan) ? scan->SceneIndex() : 0;
      LoadColor(scan_index);
      DrawSurfels(node);
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_OBJECT:
    // Draw with colors based on nodes
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      R3SurfelObject *object = node->Object(TRUE, TRUE);
      while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
      int object_index = (object) ? object->SceneIndex() : 0;
      LoadColor(object_index);
      DrawSurfels(node);
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_NODE:
    // Draw with colors based on nodes
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      LoadColor(i);
      DrawSurfels(node);
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_BLOCK:
    // Draw with colors based on blocks
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      if (!NodeVisibility(node)) continue;
      for (int j = 0; j < node->NBlocks(); j++) {
        R3SurfelBlock *block = node->Block(j);
        LoadColor(block->DatabaseIndex());
        block->Draw(shape_draw_flags, subsampling_factor);
      }
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_OBJECT_ATTRIBUTES:
    // Draw with colors based on flags encoding object attributes
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      if (!NodeVisibility(node)) continue;
      R3SurfelObject *object = node->Object(TRUE, TRUE);
      while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
      RNFlags flags = (object) ? object->Flags() : RNFlags(0);
      LoadColor((int) flags);
      DrawSurfels(node);
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_SHADING:
    // Draw with colors based on shading
    glEnable(GL_LIGHTING);
    RNLoadRgb(0.8, 0.8, 0.8);
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      DrawSurfels(node, R3_SURFEL_NORMAL_DRAW_FLAG);
    }
    glDisable(GL_LIGHTING);
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_NORMAL:
    // Draw with colors based on normals
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      if (!NodeVisibility(node)) continue;
      for (int j = 0; j < node->NBlocks(); j++) {
        R3SurfelBlock *block = node->Block(j);
        const R3Point& block_origin = block->PositionOrigin();
        glPushMatrix();
        glTranslated(block_origin.X(), block_origin.Y(), block_origin.Z());
        RNGrfxBegin(RN_GRFX_POINTS);
        for (int k = 0; k < block->NSurfels(); k += subsampling_factor) {
          const R3Surfel *surfel = block->Surfel(k);
          float r = 0.5F + 0.5F * surfel->NX();
          float g = 0.5F + 0.5F * surfel->NY();
          float b = 0.5F + 0.5F * surfel->NZ();
          RNLoadRgb(r, g, b);
          R3LoadPoint(surfel->PositionPtr());
        }
        RNGrfxEnd();
        glPopMatrix();
      }
    }
    break;
    
  case R3_SURFEL_VIEWER_COLOR_BY_Z:
  case R3_SURFEL_VIEWER_COLOR_BY_ELEVATION:
  case R3_SURFEL_VIEWER_COLOR_BY_SURFEL_LABEL:
  case R3_SURFEL_VIEWER_COLOR_BY_CONFIDENCE:
    // Draw with colors based on surfel attributes
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      if (!NodeVisibility(node)) continue;
      for (int j = 0; j < node->NBlocks(); j++) {
        R3SurfelBlock *block = node->Block(j);
        const R3Point& block_origin = block->PositionOrigin();
        glPushMatrix();
        glTranslated(block_origin.X(), block_origin.Y(), block_origin.Z());
        RNGrfxBegin(RN_GRFX_POINTS);
        for (int k = 0; k < block->NSurfels(); k += subsampling_factor) {
          const R3Surfel *surfel = block->Surfel(k);
          if (color_scheme == R3_SURFEL_VIEWER_COLOR_BY_Z) {
            double z = block_origin.Z() + surfel->Z();
            double dz = (z > center_point.Z()) ? z - center_point.Z() : 0;
            double value = 0.5 * sqrt(dz);
            LoadColor(value);
          }
          else if (color_scheme == R3_SURFEL_VIEWER_COLOR_BY_ELEVATION) {
            double elevation = surfel->Elevation();
            double value = (elevation > 0) ? 0.5 * sqrt(elevation) : 0;
            LoadColor(value);
          }
          else if (color_scheme == R3_SURFEL_VIEWER_COLOR_BY_SURFEL_LABEL) {
            int label_identifier = surfel->Attribute() & 0xFF;
            LoadColor(label_identifier);
          }
          else if (color_scheme == R3_SURFEL_VIEWER_COLOR_BY_CONFIDENCE) {
            double confidence = ((surfel->Attribute() >> 8) & 0xFF) / 255.0;
            LoadColor(confidence);
          }
          R3LoadPoint(surfel->PositionPtr());
        }
        RNGrfxEnd();
        glPopMatrix();
      }
    }
    break;
    
  default:
    // Draw with RGB surfel colors
    for (int i = 0; i < resident_nodes.NNodes(); i++) {
      R3SurfelNode *node = resident_nodes.Node(i);
      if (!NodeVisibility(node)) continue;
      DrawSurfels(node, R3_SURFEL_COLOR_DRAW_FLAG);
    }
    break;
  }

  // Reset point size
  glPointSize(1);    
}

// Assembly:
subq $0x398, %rsp            # imm = 0x398
movq %rdi, 0x390(%rsp)
movl %esi, 0x38c(%rsp)
movq 0x390(%rsp), %rdi
movq %rdi, 0x168(%rsp)
callq 0x3df20
cmpl $0x0, %eax
jne 0x328b5
jmp 0x33de5
movl $0xb50, %edi            # imm = 0xB50
callq 0x28240
cmpl $0xe, 0x38c(%rsp)
je 0x328e4
movq 0x168(%rsp), %rax
movsd 0x2e8(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x280b0
jmp 0x3291e
movq 0x168(%rsp), %rdi
callq 0x3df40
movq %rax, %rdi
callq 0x3df10
cvtsi2sd %eax, %xmm0
movsd 0x20e723(%rip), %xmm1   # 0x241028
mulsd %xmm1, %xmm0
movsd 0x20e6ff(%rip), %xmm1   # 0x241010
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x280b0
movq 0x168(%rsp), %rax
addq $0x458, %rax            # imm = 0x458
movq %rax, 0x160(%rsp)
leaq 0x380(%rsp), %rdi
movl $0x10, %esi
callq 0x2f310
movq 0x160(%rsp), %rdi
movq 0x380(%rsp), %rsi
callq 0x3df60
cmpl $0x0, %eax
jne 0x3298a
movq 0x168(%rsp), %rdi
movl 0x38c(%rsp), %esi
movq (%rdi), %rax
callq *0x370(%rax)
movss 0x20f0ac(%rip), %xmm0   # 0x241a2c
callq 0x280b0
jmp 0x33de5
movl 0x38c(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x158(%rsp)
subl $0xd, %eax
ja 0x33d12
movq 0x158(%rsp), %rax
leaq 0x20ec7b(%rip), %rcx    # 0x241630
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, 0x37c(%rsp)
movq 0x168(%rsp), %rdi
movl 0x37c(%rsp), %eax
movl %eax, 0x154(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x154(%rsp), %eax
cmpl %ecx, %eax
jge 0x32aa4
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x37c(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x370(%rsp)
movl 0x38c(%rsp), %esi
movq 0x370(%rsp), %r8
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %r9d
movq %r9, %rdx
movq %r9, %rcx
movq $0x0, (%rsp)
callq *0x228(%rax)
movq 0x370(%rsp), %rax
movq %rax, 0x148(%rsp)
leaq 0x368(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq 0x368(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x37c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x37c(%rsp)
jmp 0x329c9
jmp 0x33dd8
movl $0x0, 0x364(%rsp)
movq 0x168(%rsp), %rdi
movl 0x364(%rsp), %eax
movl %eax, 0x144(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x144(%rsp), %eax
cmpl %ecx, %eax
jge 0x32ca1
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x364(%rsp), %esi
callq 0x3dfb0
movq %rax, 0x358(%rsp)
movq 0x358(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x58f70
movq %rax, 0x350(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x350(%rsp)
movb %al, 0x143(%rsp)
je 0x32b94
movq 0x350(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x143(%rsp)
je 0x32b94
movq 0x350(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
movq 0x168(%rsp), %rax
movq %rcx, 0x138(%rsp)
movq 0x8(%rax), %rdi
callq 0x3d2f0
movq %rax, %rcx
movq 0x138(%rsp), %rax
cmpq %rcx, %rax
setne %al
movb %al, 0x143(%rsp)
movb 0x143(%rsp), %al
testb $0x1, %al
jne 0x32ba1
jmp 0x32bbb
movq 0x350(%rsp), %rdi
callq 0x3d2e0
movq %rax, 0x350(%rsp)
jmp 0x32b20
cmpq $0x0, 0x350(%rsp)
je 0x32bdd
movq 0x350(%rsp), %rdi
callq 0x662c0
movq %rax, 0x130(%rsp)
jmp 0x32be9
xorl %eax, %eax
movq %rax, 0x130(%rsp)
jmp 0x32be9
movq 0x130(%rsp), %rax
movq %rax, 0x348(%rsp)
cmpq $0x0, 0x348(%rsp)
je 0x32c1b
movq 0x348(%rsp), %rdi
callq 0x3d5d0
movq %rax, 0x128(%rsp)
jmp 0x32c2c
leaq 0x6a3ebe(%rip), %rax    # 0x6d6ae0
movq %rax, 0x128(%rsp)
jmp 0x32c2c
movq 0x128(%rsp), %rax
movq %rax, 0x340(%rsp)
movq 0x340(%rsp), %rdi
callq 0x3dfe0
movq 0x358(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x338(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0x120(%rsp), %rsi
movq 0x338(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x364(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x364(%rsp)
jmp 0x32ab4
jmp 0x33dd8
movl $0x0, 0x334(%rsp)
movq 0x168(%rsp), %rdi
movl 0x334(%rsp), %eax
movl %eax, 0x11c(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x11c(%rsp), %eax
cmpl %ecx, %eax
jge 0x32e9e
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x334(%rsp), %esi
callq 0x3dfb0
movq %rax, 0x328(%rsp)
movq 0x328(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x58f70
movq %rax, 0x320(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x320(%rsp)
movb %al, 0x11b(%rsp)
je 0x32d91
movq 0x320(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x11b(%rsp)
je 0x32d91
movq 0x320(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
movq 0x168(%rsp), %rax
movq %rcx, 0x110(%rsp)
movq 0x8(%rax), %rdi
callq 0x3d2f0
movq %rax, %rcx
movq 0x110(%rsp), %rax
cmpq %rcx, %rax
setne %al
movb %al, 0x11b(%rsp)
movb 0x11b(%rsp), %al
testb $0x1, %al
jne 0x32d9e
jmp 0x32db8
movq 0x320(%rsp), %rdi
callq 0x3d2e0
movq %rax, 0x320(%rsp)
jmp 0x32d1d
cmpq $0x0, 0x320(%rsp)
je 0x32dda
movq 0x320(%rsp), %rdi
callq 0x661d0
movq %rax, 0x108(%rsp)
jmp 0x32de6
xorl %eax, %eax
movq %rax, 0x108(%rsp)
jmp 0x32de6
movq 0x108(%rsp), %rax
movq %rax, 0x318(%rsp)
cmpq $0x0, 0x318(%rsp)
je 0x32e18
movq 0x318(%rsp), %rdi
callq 0x3d5d0
movq %rax, 0x100(%rsp)
jmp 0x32e29
leaq 0x6a3cc1(%rip), %rax    # 0x6d6ae0
movq %rax, 0x100(%rsp)
jmp 0x32e29
movq 0x100(%rsp), %rax
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rdi
callq 0x3dfe0
movq 0x328(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0x308(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movq 0x308(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x334(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x334(%rsp)
jmp 0x32cb1
jmp 0x33dd8
movl $0x0, 0x304(%rsp)
movq 0x168(%rsp), %rdi
movl 0x304(%rsp), %eax
movl %eax, 0xf4(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0xf4(%rsp), %eax
cmpl %ecx, %eax
jge 0x32fc2
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x304(%rsp), %esi
callq 0x3dfb0
movq %rax, 0x2f8(%rsp)
movq 0x2f8(%rsp), %rdi
movl $0x1, %esi
callq 0x590e0
movq %rax, 0x2f0(%rsp)
cmpq $0x0, 0x2f0(%rsp)
je 0x32f39
movq 0x2f0(%rsp), %rdi
callq 0x3d610
movl %eax, 0xf0(%rsp)
jmp 0x32f44
xorl %eax, %eax
movl %eax, 0xf0(%rsp)
jmp 0x32f44
movq 0x168(%rsp), %rdi
movl 0xf0(%rsp), %eax
movl %eax, 0x2ec(%rsp)
movl 0x2ec(%rsp), %esi
movq (%rdi), %rax
callq *0x218(%rax)
movq 0x2f8(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0x2e0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x2e0(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x304(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x32eae
jmp 0x33dd8
movl $0x0, 0x2dc(%rsp)
movq 0x168(%rsp), %rdi
movl 0x2dc(%rsp), %eax
movl %eax, 0xe4(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0xe4(%rsp), %eax
cmpl %ecx, %eax
jge 0x33183
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x2dc(%rsp), %esi
callq 0x3dfb0
movq %rax, 0x2d0(%rsp)
movq 0x2d0(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x58f70
movq %rax, 0x2c8(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x2c8(%rsp)
movb %al, 0xe3(%rsp)
je 0x330b2
movq 0x2c8(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0xe3(%rsp)
je 0x330b2
movq 0x2c8(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
movq 0x168(%rsp), %rax
movq %rcx, 0xd8(%rsp)
movq 0x8(%rax), %rdi
callq 0x3d2f0
movq %rax, %rcx
movq 0xd8(%rsp), %rax
cmpq %rcx, %rax
setne %al
movb %al, 0xe3(%rsp)
movb 0xe3(%rsp), %al
testb $0x1, %al
jne 0x330bf
jmp 0x330d9
movq 0x2c8(%rsp), %rdi
callq 0x3d2e0
movq %rax, 0x2c8(%rsp)
jmp 0x3303e
cmpq $0x0, 0x2c8(%rsp)
je 0x330fa
movq 0x2c8(%rsp), %rdi
callq 0x3d620
movl %eax, 0xd4(%rsp)
jmp 0x33105
xorl %eax, %eax
movl %eax, 0xd4(%rsp)
jmp 0x33105
movq 0x168(%rsp), %rdi
movl 0xd4(%rsp), %eax
movl %eax, 0x2c4(%rsp)
movl 0x2c4(%rsp), %esi
movq (%rdi), %rax
callq *0x218(%rax)
movq 0x2d0(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x2b8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0x2b8(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x2dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2dc(%rsp)
jmp 0x32fd2
jmp 0x33dd8
movl $0x0, 0x2b4(%rsp)
movq 0x168(%rsp), %rdi
movl 0x2b4(%rsp), %eax
movl %eax, 0xc4(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0xc4(%rsp), %eax
cmpl %ecx, %eax
jge 0x33253
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x2b4(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x2a8(%rsp)
movl 0x2b4(%rsp), %esi
movq (%rdi), %rax
callq *0x218(%rax)
movq 0x2a8(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x2a0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0x2a0(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x2b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2b4(%rsp)
jmp 0x33193
jmp 0x33dd8
movl $0x0, 0x29c(%rsp)
movq 0x168(%rsp), %rdi
movl 0x29c(%rsp), %eax
movl %eax, 0xb4(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0xb4(%rsp), %eax
cmpl %ecx, %eax
jge 0x333a5
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x29c(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x290(%rsp)
movq 0x290(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x332d2
jmp 0x3338f
movl $0x0, 0x28c(%rsp)
movl 0x28c(%rsp), %eax
movl %eax, 0xb0(%rsp)
movq 0x290(%rsp), %rdi
callq 0x2f200
movl %eax, %ecx
movl 0xb0(%rsp), %eax
cmpl %ecx, %eax
jge 0x3338d
movq 0x290(%rsp), %rdi
movl 0x28c(%rsp), %esi
callq 0x2f280
movq %rax, 0x280(%rsp)
movq 0x280(%rsp), %rdi
callq 0x3d630
movq 0x168(%rsp), %rdi
movl %eax, %esi
movq (%rdi), %rax
callq *0x218(%rax)
movq 0x168(%rsp), %rax
movq 0x280(%rsp), %rdi
movq 0x458(%rax), %rcx
movq %rcx, 0x278(%rsp)
movl 0x48c(%rax), %edx
movq 0x278(%rsp), %rsi
callq 0x47280
movl 0x28c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28c(%rsp)
jmp 0x332dd
jmp 0x3338f
movl 0x29c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x29c(%rsp)
jmp 0x33263
jmp 0x33dd8
movl $0x0, 0x274(%rsp)
movq 0x168(%rsp), %rdi
movl 0x274(%rsp), %eax
movl %eax, 0xac(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0xac(%rsp), %eax
cmpl %ecx, %eax
jge 0x33586
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x274(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x268(%rsp)
movq 0x268(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x33424
jmp 0x33570
movq 0x268(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x58f70
movq %rax, 0x260(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x260(%rsp)
movb %al, 0xab(%rsp)
je 0x334b4
movq 0x260(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0xab(%rsp)
je 0x334b4
movq 0x260(%rsp), %rdi
callq 0x3d2e0
movq %rax, %rcx
movq 0x168(%rsp), %rax
movq %rcx, 0xa0(%rsp)
movq 0x8(%rax), %rdi
callq 0x3d2f0
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
setne %al
movb %al, 0xab(%rsp)
movb 0xab(%rsp), %al
testb $0x1, %al
jne 0x334c1
jmp 0x334db
movq 0x260(%rsp), %rdi
callq 0x3d2e0
movq %rax, 0x260(%rsp)
jmp 0x33440
cmpq $0x0, 0x260(%rsp)
je 0x334fd
movq 0x260(%rsp), %rdi
callq 0x3d310
movq %rax, 0x258(%rsp)
jmp 0x3350e
leaq 0x258(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
leaq 0x258(%rsp), %rdi
callq 0x3d4b0
movq 0x168(%rsp), %rdi
movl %eax, %esi
movq (%rdi), %rax
callq *0x218(%rax)
movq 0x268(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x250(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x250(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x274(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x274(%rsp)
jmp 0x333b5
jmp 0x33dd8
movl $0xb50, %edi            # imm = 0xB50
callq 0x28960
movsd 0x20dfc3(%rip), %xmm2   # 0x241560
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x2f2e0
movl $0x0, 0x24c(%rsp)
movq 0x168(%rsp), %rdi
movl 0x24c(%rsp), %eax
movl %eax, 0x94(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x94(%rsp), %eax
cmpl %ecx, %eax
jge 0x33658
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x24c(%rsp), %esi
callq 0x3dfb0
movq %rax, 0x240(%rsp)
movq 0x240(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x238(%rsp), %rdi
movl $0x2, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x238(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x24c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x335b3
movl $0xb50, %edi            # imm = 0xB50
callq 0x28240
jmp 0x33dd8
movl $0x0, 0x234(%rsp)
movq 0x168(%rsp), %rdi
movl 0x234(%rsp), %eax
movl %eax, 0x84(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x84(%rsp), %eax
cmpl %ecx, %eax
jge 0x338e9
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x234(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x228(%rsp)
movq 0x228(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x336e1
jmp 0x338d3
movl $0x0, 0x224(%rsp)
movl 0x224(%rsp), %eax
movl %eax, 0x80(%rsp)
movq 0x228(%rsp), %rdi
callq 0x2f200
movl %eax, %ecx
movl 0x80(%rsp), %eax
cmpl %ecx, %eax
jge 0x338d1
movq 0x228(%rsp), %rdi
movl 0x224(%rsp), %esi
callq 0x2f280
movq %rax, 0x218(%rsp)
movq 0x218(%rsp), %rdi
callq 0x3d6b0
movq %rax, 0x210(%rsp)
callq 0x29170
movq 0x210(%rsp), %rdi
callq 0x2ee70
movsd %xmm0, 0x78(%rsp)
movq 0x210(%rsp), %rdi
callq 0x2ee80
movsd %xmm0, 0x70(%rsp)
movq 0x210(%rsp), %rdi
callq 0x2ee90
movsd 0x70(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x78(%rsp), %xmm0
callq 0x28af0
xorl %edi, %edi
callq 0x3e030
movl $0x0, 0x20c(%rsp)
movl 0x20c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq 0x218(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0x6c(%rsp), %eax
cmpl %ecx, %eax
jge 0x338b1
movq 0x218(%rsp), %rdi
movl 0x20c(%rsp), %esi
callq 0x3e050
movq %rax, 0x200(%rsp)
movq 0x200(%rsp), %rdi
callq 0x3d650
movss 0x20e232(%rip), %xmm1   # 0x241a30
mulss %xmm1, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1fc(%rsp)
movq 0x200(%rsp), %rdi
callq 0x3d670
movss 0x20e20c(%rip), %xmm1   # 0x241a30
mulss %xmm1, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1f8(%rsp)
movq 0x200(%rsp), %rdi
callq 0x3d690
movss 0x20e1e6(%rip), %xmm1   # 0x241a30
mulss %xmm1, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1f4(%rsp)
movss 0x1fc(%rsp), %xmm0
movss 0x1f8(%rsp), %xmm1
movss 0x1f4(%rsp), %xmm2
callq 0x2f570
movq 0x200(%rsp), %rdi
callq 0x3e080
movq %rax, %rdi
callq 0x3e070
movq 0x168(%rsp), %rax
movl 0x48c(%rax), %eax
addl 0x20c(%rsp), %eax
movl %eax, 0x20c(%rsp)
jmp 0x337a7
callq 0x3e090
callq 0x293f0
movl 0x224(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x224(%rsp)
jmp 0x336ec
jmp 0x338d3
movl 0x234(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x234(%rsp)
jmp 0x33672
jmp 0x33dd8
movl $0x0, 0x1f0(%rsp)
movq 0x168(%rsp), %rdi
movl 0x1f0(%rsp), %eax
movl %eax, 0x68(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x68(%rsp), %eax
cmpl %ecx, %eax
jge 0x33d0d
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x1f0(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x1e8(%rsp)
movq 0x1e8(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x33962
jmp 0x33cf7
movl $0x0, 0x1e4(%rsp)
movl 0x1e4(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x1e8(%rsp), %rdi
callq 0x2f200
movl %eax, %ecx
movl 0x64(%rsp), %eax
cmpl %ecx, %eax
jge 0x33cf5
movq 0x1e8(%rsp), %rdi
movl 0x1e4(%rsp), %esi
callq 0x2f280
movq %rax, 0x1d8(%rsp)
movq 0x1d8(%rsp), %rdi
callq 0x3d6b0
movq %rax, 0x1d0(%rsp)
callq 0x29170
movq 0x1d0(%rsp), %rdi
callq 0x2ee70
movsd %xmm0, 0x58(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x2ee80
movsd %xmm0, 0x50(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x2ee90
movsd 0x50(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x58(%rsp), %xmm0
callq 0x28af0
xorl %edi, %edi
callq 0x3e030
movl $0x0, 0x1cc(%rsp)
movl 0x1cc(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0x1d8(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0x4c(%rsp), %eax
cmpl %ecx, %eax
jge 0x33cd5
movq 0x1d8(%rsp), %rdi
movl 0x1cc(%rsp), %esi
callq 0x3e050
movq %rax, 0x1c0(%rsp)
cmpl $0x2, 0x38c(%rsp)
jne 0x33b75
movq 0x1d0(%rsp), %rdi
callq 0x2ee90
movsd %xmm0, 0x38(%rsp)
movq 0x1c0(%rsp), %rdi
callq 0x3d6c0
movq 0x168(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x38(%rsp), %xmm0
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x1b8(%rsp)
movsd 0x1b8(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0x2b0, %rdi            # imm = 0x2B0
callq 0x2ee90
movaps %xmm0, %xmm1
movsd 0x40(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x33b16
movq 0x168(%rsp), %rdi
movsd 0x1b8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x2b0, %rdi            # imm = 0x2B0
callq 0x2ee90
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x33b21
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x33b21
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x1b0(%rsp)
movsd 0x1b0(%rsp), %xmm0
callq 0x287c0
movq 0x168(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x20d4e7(%rip), %xmm0   # 0x241038
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1a8(%rsp)
movsd 0x1a8(%rsp), %xmm0
movq (%rdi), %rax
callq *0x220(%rax)
jmp 0x33c9f
cmpl $0xc, 0x38c(%rsp)
jne 0x33c0d
movq 0x1c0(%rsp), %rdi
callq 0x3d750
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x1a0(%rsp)
movsd 0x1a0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x33bd4
movsd 0x1a0(%rsp), %xmm0
callq 0x287c0
movaps %xmm0, %xmm1
movsd 0x20d470(%rip), %xmm0   # 0x241038
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x33bdf
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x33bdf
movq 0x168(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x198(%rsp)
movsd 0x198(%rsp), %xmm0
movq (%rdi), %rax
callq *0x220(%rax)
jmp 0x33c9d
cmpl $0xa, 0x38c(%rsp)
jne 0x33c4a
movq 0x1c0(%rsp), %rdi
callq 0x3d780
movq 0x168(%rsp), %rdi
andl $0xff, %eax
movl %eax, 0x194(%rsp)
movl 0x194(%rsp), %esi
movq (%rdi), %rax
callq *0x218(%rax)
jmp 0x33c9b
cmpl $0xb, 0x38c(%rsp)
jne 0x33c99
movq 0x1c0(%rsp), %rdi
callq 0x3d780
movq 0x168(%rsp), %rdi
movb %ah, %al
movzbl %al, %eax
cvtsi2sd %eax, %xmm0
movsd 0x20d88e(%rip), %xmm1   # 0x241508
divsd %xmm1, %xmm0
movsd %xmm0, 0x188(%rsp)
movsd 0x188(%rsp), %xmm0
movq (%rdi), %rax
callq *0x220(%rax)
jmp 0x33c9b
jmp 0x33c9d
jmp 0x33c9f
movq 0x1c0(%rsp), %rdi
callq 0x3e080
movq %rax, %rdi
callq 0x3e070
movq 0x168(%rsp), %rax
movl 0x48c(%rax), %eax
addl 0x1cc(%rsp), %eax
movl %eax, 0x1cc(%rsp)
jmp 0x33a22
callq 0x3e090
callq 0x293f0
movl 0x1e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e4(%rsp)
jmp 0x3396d
jmp 0x33cf7
movl 0x1f0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f0(%rsp)
jmp 0x338f9
jmp 0x33dd8
movl $0x0, 0x184(%rsp)
movq 0x168(%rsp), %rdi
movl 0x184(%rsp), %eax
movl %eax, 0x1c(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x1c(%rsp), %eax
cmpl %ecx, %eax
jge 0x33dd6
movq 0x168(%rsp), %rdi
addq $0x10, %rdi
movl 0x184(%rsp), %esi
callq 0x3dfb0
movq 0x168(%rsp), %rdi
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x33d83
jmp 0x33dc0
movq 0x178(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x170(%rsp), %rdi
movl $0x1, %esi
callq 0x2f310
movq 0x168(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x170(%rsp), %rdx
movq (%rdi), %rax
callq *0x278(%rax)
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x33d1d
jmp 0x33dd8
movss 0x20dc4c(%rip), %xmm0   # 0x241a2c
callq 0x280b0
addq $0x398, %rsp            # imm = 0x398
retq
nopl (%rax)