// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
testl %r8d, %r8d
je 0x2a2d9
movq 0x1a0(%r12), %rdi
testq %rdi, %rdi
je 0x2a2d9
leaq 0xc203d(%rip), %rsi     # 0xec308
movl $0x7, %edx
callq 0x223c0
testl %eax, %eax
je 0x2a30b
cmpl $0x0, 0x2c(%r12)
jle 0x2a31d
xorl %r15d, %r15d
movq 0x20(%r12), %rax
movq (%rax,%r15,8), %rdx
movq %r13, %rdi
movq %rbx, %rsi
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x2a292
incq %r15
movslq 0x2c(%r12), %rax
cmpq %rax, %r15
jl 0x2a2e4
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x9, %r14d
je 0x2a35b
cmpl $0x1, %r14d
jne 0x2a37b
movzbl 0x12f560(%rip), %eax    # 0x159890
movl $0x8, %ecx
subl %eax, %ecx
cmpl %ecx, 0x24(%rbx)
jle 0x2a35b
movq %r12, %rdi
callq 0x3ee78
movzbl 0x12f545(%rip), %edx    # 0x159890
movq %rbx, %rdi
movq %rax, %rsi
movl $0x7, %ecx
callq 0x2bf70
movl $0x772, %esi            # imm = 0x772
movq %r12, %rdi
xorl %edx, %edx
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3fbec
leal -0xd(%r14), %eax
cmpl $0x2, %eax
movq %r12, 0x20(%rsp)
ja 0x2a44f
cmpl $0xd, %r14d
je 0x2a55d
cmpl $0xf, %r14d
jne 0x2a57a
movq 0x1a0(%r12), %rbx
testq %rbx, %rbx
je 0x2a43e
leaq 0xc1f57(%rip), %rsi     # 0xec310
movl $0x5, %edx
movq %rbx, %rdi
callq 0x223c0
testl %eax, %eax
je 0x2a8ee
leaq 0xc1f41(%rip), %rsi     # 0xec316
movl $0xb, %edx
movq %rbx, %rdi
callq 0x223c0
testl %eax, %eax
je 0x2a8ee
leaq 0xc1f31(%rip), %rsi     # 0xec322
movl $0xc, %edx
movq %rbx, %rdi
callq 0x223c0
testl %eax, %eax
je 0x2a8ee
leaq 0xc1f22(%rip), %rsi     # 0xec32f
movl $0x8, %edx
movq %rbx, %rdi
callq 0x223c0
testl %eax, %eax
je 0x2ab7d
leaq 0xc1f0f(%rip), %rsi     # 0xec338
movl $0x6, %edx
movq %rbx, %rdi
callq 0x223c0
testl %eax, %eax
je 0x2ab8e
movq %rsp, %rdi
movw $0x0, (%rdi)
movb $0x0, 0x2(%rdi)
jmp 0x2a8fa
cmpl $0xa, %r14d
je 0x2a683
cmpl $0xb, %r14d
je 0x2a614
cmpl $0xc, %r14d
jne 0x2a766
movl 0x3c(%r12), %eax
testl %eax, %eax
jle 0x2a30b
xorl %edx, %edx
movq %rsp, %rbx
xorl %r15d, %r15d
movq 0x30(%r12), %rcx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x28(%rsp)
cmpl $0x0, 0x1c(%rcx)
jle 0x2a549
movq %rdx, 0x38(%rsp)
xorl %r13d, %r13d
movq 0x28(%rsp), %r12
movq 0x10(%r12), %rax
movq (%rax,%r13,8), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0xb8(%rax)
movl %eax, %ebp
callq 0x6a290
cmpl %eax, %ebp
jne 0x2a529
cmpl $0x0, 0x24(%r14)
jle 0x2a529
movl %r15d, 0x30(%rsp)
movl %r15d, %r12d
xorl %ebp, %ebp
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %r15
leaq (%r12,%rbp), %rax
incq %rax
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, (%rsp)
movb %ah, 0x1(%rsp)
movb %al, 0x2(%rsp)
movq %rbx, %rdi
callq 0x22b80
movq (%r15), %rax
movl $0x2, %esi
movq %r15, %rdi
callq *0xa8(%rax)
incq %rbp
movslq 0x24(%r14), %rax
cmpq %rax, %rbp
jl 0x2a4d8
movl 0x30(%rsp), %r15d
addl %ebp, %r15d
movq 0x28(%rsp), %r12
incq %r13
movslq 0x1c(%r12), %rax
cmpq %rax, %r13
jl 0x2a4a7
movq 0x20(%rsp), %r12
movl 0x3c(%r12), %eax
movq 0x38(%rsp), %rdx
incq %rdx
movslq %eax, %rcx
cmpq %rcx, %rdx
jl 0x2a482
jmp 0x2a30b
movl 0x8(%r12), %eax
incl %eax
movl %eax, %ecx
shrl $0x10, %ecx
movq %rsp, %rdi
movb %cl, (%rdi)
movb %ah, 0x1(%rsp)
movb %al, 0x2(%rdi)
jmp 0x2a8fa
leaq 0x10(%rsp), %r13
leaq 0xd1663(%rip), %rbx     # 0xfbbe9
leaq 0xd1661(%rip), %r14     # 0xfbbee
movq %rsp, %r15
movq 0x20(%rsp), %rbp
movq %r13, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2b026
movq 0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x2ac68
movq 0x50(%rbp), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x2a5c6
movq 0x40(%rax), %r12
jmp 0x2a5c9
xorl %r12d, %r12d
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2a5df
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x228b0
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
je 0x2a5ed
testq %r12, %r12
je 0x2a595
testq %r12, %r12
je 0x2a924
movq %r12, %rdi
callq 0x22ec0
movl %eax, %ecx
shrl $0x10, %ecx
movq %rsp, %rdi
movb %cl, (%rdi)
movb %ah, 0x1(%rsp)
movb %al, 0x2(%rdi)
jmp 0x2a930
cmpl $0x0, 0x3c(%r12)
jle 0x2a30b
xorl %r15d, %r15d
movq %rsp, %rbx
movq 0x30(%r12), %rax
movq (%rax,%r15,8), %r14
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x2a64f
movl 0x8(%rax), %eax
incl %eax
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, (%rsp)
movb %ah, 0x1(%rsp)
movb %al, 0x2(%rsp)
jmp 0x2a65a
movw $0x0, (%rsp)
movb $0x0, 0x2(%rsp)
movq %rbx, %rdi
callq 0x22b80
movl $0x2, %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x405d0
incq %r15
movslq 0x3c(%r12), %rax
cmpq %rax, %r15
jl 0x2a626
jmp 0x2a30b
cmpl $0x0, 0x3c(%r12)
jle 0x2a30b
xorl %r14d, %r14d
leaq 0x12fbc7(%rip), %r15    # 0x15a260
movq 0x30(%r12), %rax
movq (%rax,%r14,8), %rbx
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x2a6b1
movq 0x18(%rax), %rax
jmp 0x2a6b3
xorl %eax, %eax
testq %rax, %rax
jne 0x2a6bb
movq %r15, %rax
movsd 0x40(%rax), %xmm0
movsd 0xc1988(%rip), %xmm3    # 0xec050
mulsd %xmm3, %xmm0
movsd 0x38(%rax), %xmm1
movsd 0xc197f(%rip), %xmm4    # 0xec058
mulsd %xmm4, %xmm1
addsd %xmm0, %xmm1
movsd 0x48(%rax), %xmm0
movsd 0xc1972(%rip), %xmm5    # 0xec060
mulsd %xmm5, %xmm0
addsd %xmm1, %xmm0
movsd 0x58(%rax), %xmm1
mulsd %xmm3, %xmm1
movsd 0x50(%rax), %xmm2
mulsd %xmm4, %xmm2
addsd %xmm1, %xmm2
movsd 0x60(%rax), %xmm1
mulsd %xmm5, %xmm1
addsd %xmm2, %xmm1
movsd 0x70(%rax), %xmm2
mulsd %xmm3, %xmm2
movsd 0x68(%rax), %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
movsd 0x78(%rax), %xmm2
mulsd %xmm5, %xmm2
addsd %xmm3, %xmm2
callq 0x22e50
movl $0x2, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x405d0
incq %r14
movslq 0x3c(%r12), %rax
cmpq %rax, %r14
jl 0x2a699
jmp 0x2a30b
movl %r14d, %eax
andl $-0x4, %eax
cmpl $0x4, %eax
movq %r13, 0x28(%rsp)
jne 0x2a901
movl 0x3c(%r12), %eax
testl %eax, %eax
jle 0x2a30b
leal -0x5(%r14), %ecx
movslq %ecx, %rcx
movq %rcx, 0x30(%rsp)
leaq 0xc602e(%rip), %rcx     # 0xf07c8
movsd (%rcx), %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %edx, %edx
movq 0x30(%r12), %rcx
movq (%rcx,%rdx,8), %rcx
cmpl $0x0, 0x1c(%rcx)
jle 0x2a8da
movq %rdx, 0x40(%rsp)
xorl %r12d, %r12d
movq %rcx, 0x48(%rsp)
movq 0x10(%rcx), %rax
movq (%rax,%r12,8), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0xb8(%rax)
movl %eax, %ebp
callq 0x6a290
cmpl %eax, %ebp
jne 0x2a8b6
cmpl $0x0, 0x24(%r13)
jle 0x2a8b6
xorl %r15d, %r15d
movq 0x18(%r13), %rax
movq (%rax,%r15,8), %rbp
leaq 0x20(%rbp), %rbx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x78812
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x50c8b
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x2a82e
movq %rsp, %rdi
callq 0x78b70
cmpl $0x4, %r14d
jne 0x2a853
movsd 0x8(%rsp), %xmm0
callq 0x22810
movsd 0x38(%rsp), %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
jmp 0x2a86d
movq 0x30(%rsp), %rax
movsd (%rsp,%rax,8), %xmm1
movsd 0xc17cb(%rip), %xmm0    # 0xec030
mulsd %xmm0, %xmm1
addsd %xmm0, %xmm1
mulsd 0xc179b(%rip), %xmm1    # 0xec010
cvttsd2si %xmm1, %eax
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x70(%rsp)
movb %ah, 0x71(%rsp)
movb %al, 0x72(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x22b80
movq (%rbp), %rax
movl $0x2, %esi
movq %rbp, %rdi
callq *0xa8(%rax)
incq %r15
movslq 0x24(%r13), %rax
cmpq %rax, %r15
jl 0x2a7f8
incq %r12
movq 0x48(%rsp), %rcx
movslq 0x1c(%rcx), %rax
cmpq %rax, %r12
jl 0x2a7c6
movq 0x20(%rsp), %r12
movl 0x3c(%r12), %eax
movq 0x40(%rsp), %rdx
incq %rdx
movslq %eax, %rcx
cmpq %rcx, %rdx
jl 0x2a7a6
jmp 0x2a30b
movq %rsp, %rdi
movw $0x0, (%rdi)
movb $0x1, 0x2(%rdi)
callq 0x22b80
jmp 0x2a93a
leal -0x2(%r14), %eax
cmpl $0x2, %eax
jb 0x2a94e
cmpl $0x8, %r14d
je 0x2a94e
cmpl $0x10, %r14d
jne 0x2ab48
movl $0x402, %esi            # imm = 0x402
jmp 0x2a360
movq %rsp, %rdi
movw $0x0, (%rdi)
movb $0x0, 0x2(%rdi)
callq 0x22b80
movq 0x20(%rsp), %r12
movl $0x2, %esi
movq %r12, %rdi
xorl %edx, %edx
callq 0x3fbec
jmp 0x2a30b
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
cmpl $0x3, %r14d
jne 0x2a96f
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2abc0
movsd %xmm0, 0x30(%rsp)
movl $0x4, %edi
callq 0x22180
movl 0x3c(%r12), %eax
testl %eax, %eax
jle 0x2ab3e
movq 0x28(%rsp), %rcx
addq $0x48, %rcx
movq %rcx, 0x48(%rsp)
xorl %edx, %edx
movq %rsp, %r13
movq 0x20(%rsp), %rcx
movq 0x30(%rcx), %rcx
movq (%rcx,%rdx,8), %rcx
cmpl $0x0, 0x1c(%rcx)
jle 0x2ab2f
movq %rdx, 0x50(%rsp)
xorl %edx, %edx
movq %rcx, 0x58(%rsp)
movq 0x10(%rcx), %rax
movq %rdx, 0x60(%rsp)
movq (%rax,%rdx,8), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
callq 0x6a290
cmpl %eax, %ebx
jne 0x2ab08
cmpl $0x0, 0x24(%r15)
jle 0x2ab08
xorl %ecx, %ecx
movq %r15, 0x68(%rsp)
movq 0x18(%r15), %rax
movq %rcx, 0x40(%rsp)
movq (%rax,%rcx,8), %r15
leaq 0x20(%r15), %rax
movq %rax, 0x38(%rsp)
movl $0x1, %ebp
movq (%r15,%rbp,8), %rbx
cmpl $0x3, %r14d
jne 0x2aa28
movsd 0x8(%rbx), %xmm0
subsd 0x30(%rsp), %xmm0
jmp 0x2aa61
cmpl $0x8, %r14d
je 0x2aa99
cmpl $0x2, %r14d
jne 0x2aa82
movq %r13, %rdi
movq %rbx, %rsi
movq 0x28(%rsp), %rdx
callq 0x77fca
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq 0x48(%rsp), %rsi
callq 0x7943c
movq %r13, %rdi
movq %r12, %rsi
callq 0x78a8e
movsd 0xc164f(%rip), %xmm1    # 0xec0b8
movapd %xmm1, %xmm2
minsd %xmm0, %xmm2
divsd %xmm1, %xmm2
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x22e50
movq %rbx, %rdi
callq 0x221a0
incq %rbp
cmpq $0x4, %rbp
jne 0x2aa11
jmp 0x2aaee
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x77fca
movq %r13, %rdi
callq 0x78b18
leaq 0x18(%rbx), %rsi
btl $0x8, 0x58(%rbx)
cmovaeq 0x38(%rsp), %rsi
leaq 0x70(%rsp), %r12
movq %r12, %rdi
callq 0x78812
movq %r12, %rdi
movq %r13, %rsi
callq 0x78a8e
andpd 0xc1610(%rip), %xmm0    # 0xec0f0
movsd 0xc1588(%rip), %xmm2    # 0xec070
minsd %xmm0, %xmm2
jmp 0x2aa75
movq 0x40(%rsp), %rcx
incq %rcx
movq 0x68(%rsp), %r15
movslq 0x24(%r15), %rax
cmpq %rax, %rcx
jl 0x2a9f6
movq 0x60(%rsp), %rdx
incq %rdx
movq 0x58(%rsp), %rcx
movslq 0x1c(%rcx), %rax
cmpq %rax, %rdx
jl 0x2a9bc
movq 0x20(%rsp), %rax
movl 0x3c(%rax), %eax
movq 0x50(%rsp), %rdx
incq %rdx
movslq %eax, %rcx
cmpq %rcx, %rdx
jl 0x2a999
callq 0x22c30
jmp 0x2a30b
cmpl $0x0, 0x3c(%r12)
jle 0x2a30b
xorl %ebx, %ebx
movq 0x30(%r12), %rax
movq (%rax,%rbx,8), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x405d0
incq %rbx
movslq 0x3c(%r12), %rax
cmpq %rax, %rbx
jl 0x2ab56
jmp 0x2a30b
movq %rsp, %rdi
movw $0x0, (%rdi)
movb $0x2, 0x2(%rdi)
jmp 0x2a8fa
movq %rsp, %rdi
movw $0x0, (%rdi)
movb $0x3, 0x2(%rdi)
jmp 0x2a8fa
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2abb8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x228b0
movq %rbx, %rdi
callq 0x230a0