// File: tomfunkhouser[P]gaps/apps/scn2img/scn2img.cpp
// Function: DrawNodeWithOpenGL(gaps::R3Camera const&, gaps::R3Scene*, gaps::R3SceneNode*, int, int)
static void 
DrawNodeWithOpenGL(const R3Camera& camera, R3Scene *scene, R3SceneNode *node, int color_scheme, RNBoolean omit_objects = FALSE)
{
  // Check if should omit object
  if (omit_objects && node->Name() && !strncmp(node->Name(), "Object#", 7)) return;

  // Check if has elements and/or references
  if (node->NChildren() > 0) {
    // Recurse to children
    for (int i = 0; i < node->NChildren(); i++) {
      R3SceneNode *child = node->Child(i);
      DrawNodeWithOpenGL(camera, scene, child, color_scheme, omit_objects);
    }
  }
  else {
    // Check color scheme
    if ((color_scheme == RGB_COLOR_SCHEME) || (color_scheme == ALBEDO_COLOR_SCHEME)) {
      // Load lights for node
      if (color_scheme == RGB_COLOR_SCHEME) {
        int max_lights = 8 - headlight;
        if (scene->NLights() > max_lights) {
          scene->LoadLights(node->BBox(), headlight);
        }
      }

      // Draw node with shading
      node->Draw(R3_DEFAULT_DRAW_FLAGS);
    }
    else if ((color_scheme == NODE_COLOR_SCHEME) || (color_scheme == CATEGORY_COLOR_SCHEME) || (color_scheme == ROOM_SURFACE_COLOR_SCHEME)) {
      // Draw integer values per node
      if (color_scheme == NODE_COLOR_SCHEME) {
        LoadInteger(node->SceneIndex() + 1);
      }
      else if (color_scheme == CATEGORY_COLOR_SCHEME) {
        const char *model_index = NULL;
        R3SceneNode *ancestor = node;
        while (!model_index && ancestor) { model_index = ancestor->Info("index"); ancestor = ancestor->Parent(); }
        if (model_index) LoadInteger(atoi(model_index));
        else LoadInteger(0);
      }
      else if (color_scheme == ROOM_SURFACE_COLOR_SCHEME) {
        if (!node->Name()) LoadInteger(0);
        else if (!strncmp(node->Name(), "Wall#", 5)) LoadInteger(1);
        else if (!strncmp(node->Name(), "WallInside#", 11)) LoadInteger(1);
        else if (!strncmp(node->Name(), "WallOutside#", 12)) LoadInteger(1);
        else if (!strncmp(node->Name(), "Ceiling#", 8)) LoadInteger(2);
        else if (!strncmp(node->Name(), "Floor#", 6)) LoadInteger(3);
        else LoadInteger(0);
      }
      node->Draw(R3_SURFACES_DRAW_FLAG);
    }
    else if (color_scheme == MATERIAL_COLOR_SCHEME) {
      // Draw integer values per element
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        R3Material *material = element->Material();
        if (!material) LoadInteger(0);
        else LoadInteger(material->SceneIndex() + 1);
        element->Draw(R3_SURFACES_DRAW_FLAG);
      }
    }
    else if (color_scheme == BRDF_COLOR_SCHEME) {
      // Draw color values per element (NOTE: THIS IGNORES TEXTURE)
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        const R3Material *material = element->Material();
        const R3Brdf *brdf = (material) ? material->Brdf() : NULL;
        if (!brdf) brdf = &R3default_brdf;
        RNScalar kd = brdf->Diffuse().Luminance();
        RNScalar ks = brdf->Specular().Luminance();
        RNScalar kt = brdf->Transmission().Luminance();
        RNLoadRgb(kd, ks, kt);
        element->Draw(R3_SURFACES_DRAW_FLAG);
      }
    }
    else if (color_scheme == FACE_COLOR_SCHEME) {
      // Draw integer values per triangle
      int face_count = 0;
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        for (int j = 0; j < element->NShapes(); j++) {
          R3Shape *shape = element->Shape(j);
          if (shape->ClassID() == R3TriangleArray::CLASS_ID()) {
            R3TriangleArray *triangles = (R3TriangleArray *) shape;
            for (int k = 0; k < triangles->NTriangles(); k++) {
              R3Triangle *triangle = triangles->Triangle(k);
              LoadInteger(face_count + 1);
              triangle->Draw(R3_SURFACES_DRAW_FLAG);
              face_count++;
            }
          }
        }
      }
    }    
    else if ((color_scheme == ANGLE_COLOR_SCHEME) || 
      (color_scheme == XNORMAL_COLOR_SCHEME) || (color_scheme == YNORMAL_COLOR_SCHEME) || (color_scheme == ZNORMAL_COLOR_SCHEME)) {
      // Draw integer values per triangle
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        for (int j = 0; j < element->NShapes(); j++) {
          R3Shape *shape = element->Shape(j);
          if (shape->ClassID() == R3TriangleArray::CLASS_ID()) {
            R3TriangleArray *triangles = (R3TriangleArray *) shape;
            for (int k = 0; k < triangles->NTriangles(); k++) {
              R3Triangle *triangle = triangles->Triangle(k);
              R3Vector normal = triangle->Normal();
              if (R3SignedDistance(triangle->Plane(), camera.Origin()) < 0) normal.Flip();
              RNScalar value = 0;
              if (color_scheme == ANGLE_COLOR_SCHEME) value = (RN_PI - acos(normal.Y())) / RN_PI;
              else value = 0.5*normal[color_scheme - XNORMAL_COLOR_SCHEME] + 0.5;
              LoadInteger((int) (65535 * value));
              triangle->Draw(R3_SURFACES_DRAW_FLAG);
            }
          }
        }
      }
    }
    else if ((color_scheme == DEPTH_COLOR_SCHEME) || (color_scheme == NDOTV_COLOR_SCHEME) || (color_scheme == HEIGHT_COLOR_SCHEME)) {
      // Draw scalar values interpolated between triangle vertices
      RNScalar ground_y = (color_scheme == HEIGHT_COLOR_SCHEME) ? EstimateGroundY(camera, scene) : 0;
      RNGrfxBegin(RN_GRFX_TRIANGLES);
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        for (int j = 0; j < element->NShapes(); j++) {
          R3Shape *shape = element->Shape(j);
          if (shape->ClassID() == R3TriangleArray::CLASS_ID()) {
            R3TriangleArray *triangles = (R3TriangleArray *) shape;
            for (int k = 0; k < triangles->NTriangles(); k++) {
              R3Triangle *triangle = triangles->Triangle(k);
              for (int m = 0; m < 3; m++) {
                R3TriangleVertex *vertex = triangle->Vertex(m);
                const R3Point& position = vertex->Position();
                if (color_scheme == HEIGHT_COLOR_SCHEME) LoadScalar(position.Y() - ground_y, 6.5535);
                else if (color_scheme == DEPTH_COLOR_SCHEME) LoadScalar((position - camera.Origin()).Dot(camera.Towards()), 6.5535);
                else if (color_scheme == NDOTV_COLOR_SCHEME) {
                  R3Vector v = camera.Origin() - position; v.Normalize();
                  R3Vector normal = (vertex->Flags()[R3_VERTEX_NORMALS_DRAW_FLAG]) ? vertex->Normal() : triangle->Normal();
                  LoadScalar(fabs(normal.Dot(v)), 1.0);
                }
                R3LoadPoint(position);
              }
            }
          }
        }
      }
      RNGrfxEnd();
    }
    else if (color_scheme == VRGB_COLOR_SCHEME) {
      // Draw node with vertex colors
      node->Draw(R3_SURFACES_DRAW_FLAG | R3_VERTEX_COLORS_DRAW_FLAG);
    }
    else {
      // Draw without setting colors
      for (int i = 0; i < node->NElements(); i++) {
        R3SceneElement *element = node->Element(i);
        element->Draw(R3_SURFACES_DRAW_FLAG);
      }
    }
  }
}

// Assembly:
subq $0x318, %rsp            # imm = 0x318
movq %rdi, 0x310(%rsp)
movq %rsi, 0x308(%rsp)
movq %rdx, 0x300(%rsp)
movl %ecx, 0x2fc(%rsp)
movl %r8d, 0x2f8(%rsp)
cmpl $0x0, 0x2f8(%rsp)
je 0x2c916
movq 0x300(%rsp), %rdi
callq 0x2f070
cmpq $0x0, %rax
je 0x2c916
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x1809d6(%rip), %rsi    # 0x1ad2d8
movl $0x7, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2c916
jmp 0x2d92c
movq 0x300(%rsp), %rdi
callq 0x2f090
cmpl $0x0, %eax
jle 0x2c9c2
movl $0x0, 0x2f4(%rsp)
movl 0x2f4(%rsp), %eax
movl %eax, 0xd4(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f090
movl %eax, %ecx
movl 0xd4(%rsp), %eax
cmpl %ecx, %eax
jge 0x2c9bd
movq 0x300(%rsp), %rdi
movl 0x2f4(%rsp), %esi
callq 0x2f0b0
movq %rax, 0x2e8(%rsp)
movq 0x310(%rsp), %rdi
movq 0x308(%rsp), %rsi
movq 0x2e8(%rsp), %rdx
movl 0x2fc(%rsp), %ecx
movl 0x2f8(%rsp), %r8d
callq 0x2c8a0
movl 0x2f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2f4(%rsp)
jmp 0x2c937
jmp 0x2d92c
cmpl $0x1, 0x2fc(%rsp)
je 0x2c9da
cmpl $0x9, 0x2fc(%rsp)
jne 0x2ca86
cmpl $0x1, 0x2fc(%rsp)
jne 0x2ca46
movl $0x8, %eax
subl 0x1f21f1(%rip), %eax    # 0x21ebe0
movl %eax, 0x2e4(%rsp)
movq 0x308(%rsp), %rdi
callq 0x2f0e0
cmpl 0x2e4(%rsp), %eax
jle 0x2ca44
movq 0x308(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x300(%rsp), %rdi
callq 0x5a400
movq 0xc8(%rsp), %rdi
movq %rax, %rsi
movl 0x1f21a6(%rip), %edx    # 0x21ebe0
movl $0x7, %ecx
callq 0x321b0
jmp 0x2ca46
movq 0x300(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0x2d8(%rsp), %rdi
movl $0x772, %esi            # imm = 0x772
callq 0x2f100
movq 0xc0(%rsp), %rdi
movq 0x2d8(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5b830
jmp 0x2d92a
cmpl $0xd, 0x2fc(%rsp)
je 0x2caa8
cmpl $0xe, 0x2fc(%rsp)
je 0x2caa8
cmpl $0xf, 0x2fc(%rsp)
jne 0x2cd10
cmpl $0xd, 0x2fc(%rsp)
jne 0x2cace
movq 0x300(%rsp), %rdi
callq 0x2f120
movl %eax, %edi
addl $0x1, %edi
callq 0x2d940
jmp 0x2ccd0
cmpl $0xe, 0x2fc(%rsp)
jne 0x2cb8c
movq $0x0, 0x2d0(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0x2c8(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x2d0(%rsp)
movb %al, 0xbf(%rsp)
jne 0x2cb1f
cmpq $0x0, 0x2c8(%rsp)
setne %al
movb %al, 0xbf(%rsp)
movb 0xbf(%rsp), %al
testb $0x1, %al
jne 0x2cb2c
jmp 0x2cb5f
movq 0x2c8(%rsp), %rdi
leaq 0x1902fa(%rip), %rsi    # 0x1bce35
callq 0x2f130
movq %rax, 0x2d0(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x2f230
movq %rax, 0x2c8(%rsp)
jmp 0x2caf8
cmpq $0x0, 0x2d0(%rsp)
je 0x2cb80
movq 0x2d0(%rsp), %rdi
callq 0x24070
movl %eax, %edi
callq 0x2d940
jmp 0x2cb87
xorl %edi, %edi
callq 0x2d940
jmp 0x2ccce
cmpl $0xf, 0x2fc(%rsp)
jne 0x2cccc
movq 0x300(%rsp), %rdi
callq 0x2f070
cmpq $0x0, %rax
jne 0x2cbb9
xorl %edi, %edi
callq 0x2d940
jmp 0x2ccca
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x180710(%rip), %rsi    # 0x1ad2e0
movl $0x5, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2cbee
movl $0x1, %edi
callq 0x2d940
jmp 0x2ccc8
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x1806e1(%rip), %rsi    # 0x1ad2e6
movl $0xb, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2cc23
movl $0x1, %edi
callq 0x2d940
jmp 0x2ccc6
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x1806b8(%rip), %rsi    # 0x1ad2f2
movl $0xc, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2cc55
movl $0x1, %edi
callq 0x2d940
jmp 0x2ccc4
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x180693(%rip), %rsi    # 0x1ad2ff
movl $0x8, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2cc87
movl $0x2, %edi
callq 0x2d940
jmp 0x2ccc2
movq 0x300(%rsp), %rdi
callq 0x2f070
movq %rax, %rdi
leaq 0x18066a(%rip), %rsi    # 0x1ad308
movl $0x6, %edx
callq 0x23440
cmpl $0x0, %eax
jne 0x2ccb9
movl $0x3, %edi
callq 0x2d940
jmp 0x2ccc0
xorl %edi, %edi
callq 0x2d940
jmp 0x2ccc2
jmp 0x2ccc4
jmp 0x2ccc6
jmp 0x2ccc8
jmp 0x2ccca
jmp 0x2cccc
jmp 0x2ccce
jmp 0x2ccd0
movq 0x300(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x2c0(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0xb0(%rsp), %rdi
movq 0x2c0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5b830
jmp 0x2d928
cmpl $0xb, 0x2fc(%rsp)
jne 0x2ce07
movl $0x0, 0x2bc(%rsp)
movl 0x2bc(%rsp), %eax
movl %eax, 0xac(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0xac(%rsp), %eax
cmpl %ecx, %eax
jge 0x2ce02
movq 0x300(%rsp), %rdi
movl 0x2bc(%rsp), %esi
callq 0x2f260
movq %rax, 0x2b0(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x2f290
movq %rax, 0x2a8(%rsp)
cmpq $0x0, 0x2a8(%rsp)
jne 0x2cd9a
xorl %edi, %edi
callq 0x2d940
jmp 0x2cdb1
movq 0x2a8(%rsp), %rdi
callq 0x2f2a0
movl %eax, %edi
addl $0x1, %edi
callq 0x2d940
movq 0x2b0(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x2a0(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0xa0(%rsp), %rdi
movq 0x2a0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5d010
movl 0x2bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2bc(%rsp)
jmp 0x2cd29
jmp 0x2d926
cmpl $0xa, 0x2fc(%rsp)
jne 0x2cfa5
movl $0x0, 0x29c(%rsp)
movl 0x29c(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0x9c(%rsp), %eax
cmpl %ecx, %eax
jge 0x2cfa0
movq 0x300(%rsp), %rdi
movl 0x29c(%rsp), %esi
callq 0x2f260
movq %rax, 0x290(%rsp)
movq 0x290(%rsp), %rdi
callq 0x2f290
movq %rax, 0x288(%rsp)
cmpq $0x0, 0x288(%rsp)
je 0x2ce9f
movq 0x288(%rsp), %rdi
callq 0x2ee90
movq %rax, 0x90(%rsp)
jmp 0x2ceab
xorl %eax, %eax
movq %rax, 0x90(%rsp)
jmp 0x2ceab
movq 0x90(%rsp), %rax
movq %rax, 0x280(%rsp)
cmpq $0x0, 0x280(%rsp)
jne 0x2ced5
leaq 0x1f26f3(%rip), %rax    # 0x21f5c0
movq %rax, 0x280(%rsp)
movq 0x280(%rsp), %rdi
callq 0x2eea0
movq %rax, %rdi
callq 0x2eeb0
movsd %xmm0, 0x278(%rsp)
movq 0x280(%rsp), %rdi
callq 0x2ef00
movq %rax, %rdi
callq 0x2eeb0
movsd %xmm0, 0x270(%rsp)
movq 0x280(%rsp), %rdi
callq 0x2ef10
movq %rax, %rdi
callq 0x2eeb0
movsd %xmm0, 0x268(%rsp)
movsd 0x278(%rsp), %xmm0
movsd 0x270(%rsp), %xmm1
movsd 0x268(%rsp), %xmm2
callq 0x2f030
movq 0x290(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x260(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0x88(%rsp), %rdi
movq 0x260(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5d010
movl 0x29c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x29c(%rsp)
jmp 0x2ce20
jmp 0x2d924
cmpl $0xc, 0x2fc(%rsp)
jne 0x2d18b
movl $0x0, 0x25c(%rsp)
movl $0x0, 0x258(%rsp)
movl 0x258(%rsp), %eax
movl %eax, 0x84(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0x84(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d186
movq 0x300(%rsp), %rdi
movl 0x258(%rsp), %esi
callq 0x2f260
movq %rax, 0x250(%rsp)
movl $0x0, 0x24c(%rsp)
movl 0x24c(%rsp), %eax
movl %eax, 0x80(%rsp)
movq 0x250(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0x80(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d16e
movq 0x250(%rsp), %rdi
movl 0x24c(%rsp), %esi
callq 0x2f2d0
movq %rax, 0x240(%rsp)
movq 0x240(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movl %eax, 0x7c(%rsp)
callq 0xafdc0
movl %eax, %ecx
movl 0x7c(%rsp), %eax
cmpl %ecx, %eax
jne 0x2d156
movq 0x240(%rsp), %rax
movq %rax, 0x238(%rsp)
movl $0x0, 0x234(%rsp)
movl 0x234(%rsp), %eax
movl %eax, 0x78(%rsp)
movq 0x238(%rsp), %rdi
callq 0x2f300
movl %eax, %ecx
movl 0x78(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d154
movq 0x238(%rsp), %rdi
movl 0x234(%rsp), %esi
callq 0x2f320
movq %rax, 0x228(%rsp)
movl 0x25c(%rsp), %edi
addl $0x1, %edi
callq 0x2d940
movq 0x228(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x220(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0x70(%rsp), %rdi
movq 0x220(%rsp), %rsi
movq (%rdi), %rax
callq *0xa8(%rax)
movl 0x25c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25c(%rsp)
movl 0x234(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x234(%rsp)
jmp 0x2d0a7
jmp 0x2d156
jmp 0x2d158
movl 0x24c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x2d01c
jmp 0x2d170
movl 0x258(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x258(%rsp)
jmp 0x2cfc9
jmp 0x2d922
cmpl $0x4, 0x2fc(%rsp)
je 0x2d1b7
cmpl $0x5, 0x2fc(%rsp)
je 0x2d1b7
cmpl $0x6, 0x2fc(%rsp)
je 0x2d1b7
cmpl $0x7, 0x2fc(%rsp)
jne 0x2d464
movl $0x0, 0x21c(%rsp)
movl 0x21c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0x6c(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d45f
movq 0x300(%rsp), %rdi
movl 0x21c(%rsp), %esi
callq 0x2f260
movq %rax, 0x210(%rsp)
movl $0x0, 0x20c(%rsp)
movl 0x20c(%rsp), %eax
movl %eax, 0x68(%rsp)
movq 0x210(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0x68(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d447
movq 0x210(%rsp), %rdi
movl 0x20c(%rsp), %esi
callq 0x2f2d0
movq %rax, 0x200(%rsp)
movq 0x200(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movl %eax, 0x64(%rsp)
callq 0xafdc0
movl %eax, %ecx
movl 0x64(%rsp), %eax
cmpl %ecx, %eax
jne 0x2d42f
movq 0x200(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movl $0x0, 0x1f4(%rsp)
movl 0x1f4(%rsp), %eax
movl %eax, 0x60(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x2f300
movl %eax, %ecx
movl 0x60(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d42d
movq 0x1f8(%rsp), %rdi
movl 0x1f4(%rsp), %esi
callq 0x2f320
movq %rax, 0x1e8(%rsp)
movq 0x1e8(%rsp), %rdi
callq 0x2f350
movq %rax, %rsi
leaq 0x1d0(%rsp), %rdi
callq 0xd11d0
movq 0x1e8(%rsp), %rdi
callq 0x2f370
movq %rax, 0x58(%rsp)
movq 0x310(%rsp), %rdi
callq 0x2f380
movq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x7b4d0
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2d338
leaq 0x1d0(%rsp), %rdi
callq 0xd1970
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c8(%rsp)
cmpl $0x4, 0x2fc(%rsp)
jne 0x2d394
leaq 0x184133(%rip), %rax    # 0x1b1488
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x2f390
callq 0x23910
movaps %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
subsd %xmm1, %xmm0
leaq 0x184103(%rip), %rax    # 0x1b1488
divsd (%rax), %xmm0
movsd %xmm0, 0x1c8(%rsp)
jmp 0x2d3c8
movl 0x2fc(%rsp), %esi
subl $0x5, %esi
leaq 0x1d0(%rsp), %rdi
callq 0x2f3a0
movsd (%rax), %xmm0
movsd 0x17fc79(%rip), %xmm1   # 0x1ad030
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movsd 0x17fc40(%rip), %xmm0   # 0x1ad010
mulsd 0x1c8(%rsp), %xmm0
cvttsd2si %xmm0, %edi
callq 0x2d940
movq 0x1e8(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x1c0(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0x48(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movq (%rdi), %rax
callq *0xa8(%rax)
movl 0x1f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f4(%rsp)
jmp 0x2d294
jmp 0x2d42f
jmp 0x2d431
movl 0x20c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20c(%rsp)
jmp 0x2d20f
jmp 0x2d449
movl 0x21c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x21c(%rsp)
jmp 0x2d1c2
jmp 0x2d920
cmpl $0x2, 0x2fc(%rsp)
je 0x2d486
cmpl $0x8, 0x2fc(%rsp)
je 0x2d486
cmpl $0x3, 0x2fc(%rsp)
jne 0x2d842
cmpl $0x3, 0x2fc(%rsp)
jne 0x2d4ad
movq 0x310(%rsp), %rdi
movq 0x308(%rsp), %rsi
callq 0x2d980
movsd %xmm0, 0x40(%rsp)
jmp 0x2d4b8
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
jmp 0x2d4b8
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x1b8(%rsp)
movl $0x4, %edi
callq 0x2f3c0
movl $0x0, 0x1b4(%rsp)
movl 0x1b4(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d838
movq 0x300(%rsp), %rdi
movl 0x1b4(%rsp), %esi
callq 0x2f260
movq %rax, 0x1a8(%rsp)
movl $0x0, 0x1a4(%rsp)
movl 0x1a4(%rsp), %eax
movl %eax, 0x38(%rsp)
movq 0x1a8(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0x38(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d820
movq 0x1a8(%rsp), %rdi
movl 0x1a4(%rsp), %esi
callq 0x2f2d0
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movl %eax, 0x34(%rsp)
callq 0xafdc0
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jne 0x2d808
movq 0x198(%rsp), %rax
movq %rax, 0x190(%rsp)
movl $0x0, 0x18c(%rsp)
movl 0x18c(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x190(%rsp), %rdi
callq 0x2f300
movl %eax, %ecx
movl 0x30(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d806
movq 0x190(%rsp), %rdi
movl 0x18c(%rsp), %esi
callq 0x2f320
movq %rax, 0x180(%rsp)
movl $0x0, 0x17c(%rsp)
cmpl $0x3, 0x17c(%rsp)
jge 0x2d7ee
movq 0x180(%rsp), %rdi
movl 0x17c(%rsp), %esi
callq 0x2f3e0
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rdi
callq 0x2f400
movq %rax, 0x168(%rsp)
cmpl $0x3, 0x2fc(%rsp)
jne 0x2d66c
movq 0x168(%rsp), %rdi
callq 0x2f410
subsd 0x1b8(%rsp), %xmm0
movsd 0x17fa46(%rip), %xmm1   # 0x1ad0a8
callq 0x2da90
jmp 0x2d7cb
cmpl $0x2, 0x2fc(%rsp)
jne 0x2d6e1
movq 0x168(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x310(%rsp), %rdi
callq 0x2f380
movq 0x28(%rsp), %rsi
movq %rax, %rdx
leaq 0x150(%rsp), %rdi
callq 0xd0390
movq 0x310(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x2f420
leaq 0x150(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xd17a0
movsd 0x17f9d1(%rip), %xmm1   # 0x1ad0a8
callq 0x2da90
jmp 0x2d7c9
cmpl $0x8, 0x2fc(%rsp)
jne 0x2d7c7
movq 0x310(%rsp), %rdi
callq 0x2f380
movq %rax, %rsi
movq 0x168(%rsp), %rdx
leaq 0x120(%rsp), %rdi
callq 0xd0390
leaq 0x120(%rsp), %rdi
callq 0xd18f0
movq 0x170(%rsp), %rdi
callq 0x2f470
movq %rax, 0x100(%rsp)
leaq 0xf8(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2f100
movq 0xf8(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0x2f490
cmpl $0x0, %eax
je 0x2d776
movq 0x170(%rsp), %rdi
callq 0x2f4c0
movq %rax, 0x20(%rsp)
jmp 0x2d788
movq 0x180(%rsp), %rdi
callq 0x2f350
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rsi
leaq 0x108(%rsp), %rdi
callq 0xd11d0
leaq 0x108(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0xd17a0
movaps 0x17f90a(%rip), %xmm1   # 0x1ad0c0
pand %xmm1, %xmm0
movsd 0x17f886(%rip), %xmm1   # 0x1ad048
callq 0x2da90
jmp 0x2d7c9
jmp 0x2d7cb
movq 0x168(%rsp), %rdi
callq 0x2f4d0
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x2d5fb
jmp 0x2d7f0
movl 0x18c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18c(%rsp)
jmp 0x2d5ae
jmp 0x2d808
jmp 0x2d80a
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0x2d529
jmp 0x2d822
movl 0x1b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b4(%rsp)
jmp 0x2d4dc
callq 0x2f4f0
jmp 0x2d91e
cmpl $0x10, 0x2fc(%rsp)
jne 0x2d886
movq 0x300(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xf0(%rsp), %rdi
movl $0x402, %esi            # imm = 0x402
callq 0x2f100
movq 0x18(%rsp), %rdi
movq 0xf0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5b830
jmp 0x2d91c
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x300(%rsp), %rdi
callq 0x2f240
movl %eax, %ecx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jge 0x2d91a
movq 0x300(%rsp), %rdi
movl 0xec(%rsp), %esi
callq 0x2f260
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xd8(%rsp), %rdi
movl $0x2, %esi
callq 0x2f100
movq 0x8(%rsp), %rdi
movq 0xd8(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5d010
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x2d891
jmp 0x2d91c
jmp 0x2d91e
jmp 0x2d920
jmp 0x2d922
jmp 0x2d924
jmp 0x2d926
jmp 0x2d928
jmp 0x2d92a
jmp 0x2d92c
addq $0x318, %rsp            # imm = 0x318
retq
nopw %cs:(%rax,%rax)