// File: tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::R3Scene::WriteObj(gaps::R3SceneNode*, gaps::R3Affine const&, int&, int&, int&, int&, _IO_FILE*) const
int R3Scene::
WriteObj(R3SceneNode *node, const R3Affine& transformation, int &ngroups, int& nvertices, int& nnormals, int& ntexture_coords, FILE *fp) const
{
  // Write group name
  if (node->Name()) fprintf(fp, "g %s\n", node->Name());
  else fprintf(fp, "g GROUP_%d\n", ++ngroups);
  
  // Write elements
  for (int i = 0; i < node->NElements(); i++) {
    R3SceneElement *element = node->Element(i);

    // Write material
    R3Material *material = element->Material();
    if (material) fprintf(fp, "usemtl %s\n", material->Name());
    else fprintf(fp, "usemtl _DEFAULT_\n");
      
    // Write shapes
    for (int j = 0; j < element->NShapes(); j++) {
      R3Shape *shape = element->Shape(j);
      if (shape->ClassID() == R3TriangleArray::CLASS_ID()) {
        R3TriangleArray *triangles = (R3TriangleArray *) shape;
        if (triangles->NVertices() == 0) continue;
        
        // Allocate indices for positions, texture coordinates, and normals
        int *pi = new int [ triangles->NVertices() ];
        for (int k = 0; k < triangles->NVertices(); k++) pi[k] = -1;
        int *ni = new int [ triangles->NVertices() ];
        for (int k = 0; k < triangles->NVertices(); k++) ni[k] = -1;
        int *ti = new int [ triangles->NVertices() ];
        for (int k = 0; k < triangles->NVertices(); k++) ti[k] = -1;

        // Write vertices
        for (int k = 0; k < triangles->NVertices(); k++) {
          R3TriangleVertex *v = triangles->Vertex(k);
          v->SetMark(k);
          if (TRUE) {
            R3Point p = v->Position();
            p.Transform(transformation);
            fprintf(fp, "v %g %g %g\n", p.X(), p.Y(), p.Z());
            pi[k] = ++nvertices;
          }
          if (v->Flags()[R3_VERTEX_NORMALS_DRAW_FLAG]) {
            R3Vector n = v->Normal();
            n.Transform(transformation);
            fprintf(fp, "vn %g %g %g\n", n.X(), n.Y(), n.Z());
            ni[k] = ++nnormals;
          }
          if (v->Flags()[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) {
            R2Point t = v->TextureCoords();
            fprintf(fp, "vt %g %g\n", t.X(), t.Y());
            ti[k] = ++ntexture_coords;
          }
        }
       
        // Write triangles
        for (int k = 0; k < triangles->NTriangles(); k++) {
          R3Triangle *triangle = triangles->Triangle(k);
          R3TriangleVertex *v0 = triangle->V0();
          R3TriangleVertex *v1 = triangle->V1();
          R3TriangleVertex *v2 = triangle->V2();
          unsigned int i0 = v0->Mark();
          unsigned int i1 = v1->Mark();
          unsigned int i2 = v2->Mark();
          if (triangle->Flags()[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG] && triangle->Flags()[R3_VERTEX_NORMALS_DRAW_FLAG]) {
            if (transformation.IsMirrored()) fprintf(fp, "f %u/%u/%u %u/%u/%u %u/%u/%u\n", pi[i2], ti[i2], ni[i2], pi[i1], ti[i1], ni[i1], pi[i0], ti[i0], ni[i0]);
            else fprintf(fp, "f %u/%u/%u %u/%u/%u %u/%u/%u\n", pi[i0], ti[i0], ni[i0], pi[i1], ti[i1], ni[i1], pi[i2], ti[i2], ni[i2]);
          }
          else if (triangle->Flags()[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) {
            if (transformation.IsMirrored()) fprintf(fp, "f %u/%u %u/%u %u/%u\n",  pi[i2], ti[i2],  pi[i1], ti[i1],  pi[i0], ti[i0]);
            else fprintf(fp, "f %u/%u %u/%u %u/%u\n",  pi[i0], ti[i0],  pi[i1], ti[i1],  pi[i2], ti[i2]);
          }
          else if (triangle->Flags()[R3_VERTEX_NORMALS_DRAW_FLAG]) {
            if (transformation.IsMirrored()) fprintf(fp, "f %u//%u %u//%u %u//%u\n",  pi[i2], ni[i2],  pi[i1], ni[i1],  pi[i0], ni[i0]);
            else fprintf(fp, "f %u//%u %u//%u %u//%u\n",  pi[i0], ni[i0],  pi[i1], ni[i1],  pi[i2], ni[i2]);
          }
          else {
            if (transformation.IsMirrored()) fprintf(fp, "f %u %u %u\n",  pi[i2], pi[i1], pi[i0]);
            else fprintf(fp, "f %u %u %u\n", pi[i0], pi[i1], pi[i2]);
          }
        }

        // Delete indices for positions, texture coordinates, and normals
        delete [] pi;
        delete [] ni;
        delete [] ti;
      }
    }
  }

  // Write children
  for (int i = 0; i < node->NChildren(); i++) {
    R3SceneNode *child = node->Child(i);

    // Update transformation
    R3Affine child_transformation = R3identity_affine;
    child_transformation.Transform(transformation);
    child_transformation.Transform(child->Transformation());

    // Write child
    if (!WriteObj(child, child_transformation, ngroups, nvertices, nnormals, ntexture_coords, fp)) return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
movq 0x3a8(%rsp), %rax
movq 0x3a0(%rsp), %rax
movq %rdi, 0x378(%rsp)
movq %rsi, 0x370(%rsp)
movq %rdx, 0x368(%rsp)
movq %rcx, 0x360(%rsp)
movq %r8, 0x358(%rsp)
movq %r9, 0x350(%rsp)
movq 0x378(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x370(%rsp), %rdi
callq 0x2b800
cmpq $0x0, %rax
je 0x3b484
movq 0x3a8(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x370(%rsp), %rdi
callq 0x2b800
movq 0xd0(%rsp), %rdi
movq %rax, %rdx
leaq 0x1543d7(%rip), %rsi    # 0x18f852
movb $0x0, %al
callq 0x22f30
jmp 0x3b4a9
movq 0x3a8(%rsp), %rdi
movq 0x360(%rsp), %rax
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
leaq 0x1532f3(%rip), %rsi    # 0x18e795
movb $0x0, %al
callq 0x22f30
movl $0x0, 0x34c(%rsp)
movl 0x34c(%rsp), %eax
movl %eax, 0xcc(%rsp)
movq 0x370(%rsp), %rdi
callq 0x2bba0
movl %eax, %ecx
movl 0xcc(%rsp), %eax
cmpl %ecx, %eax
jge 0x3c269
movq 0x370(%rsp), %rdi
movl 0x34c(%rsp), %esi
callq 0x2bbc0
movq %rax, 0x340(%rsp)
movq 0x340(%rsp), %rdi
callq 0x48b50
movq %rax, 0x338(%rsp)
cmpq $0x0, 0x338(%rsp)
je 0x3b554
movq 0x3a8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x338(%rsp), %rdi
callq 0x48250
movq 0xc0(%rsp), %rdi
movq %rax, %rdx
leaq 0x153256(%rip), %rsi    # 0x18e7a1
movb $0x0, %al
callq 0x22f30
jmp 0x3b56a
movq 0x3a8(%rsp), %rdi
leaq 0x153249(%rip), %rsi    # 0x18e7ac
movb $0x0, %al
callq 0x22f30
movl $0x0, 0x334(%rsp)
movl 0x334(%rsp), %eax
movl %eax, 0xbc(%rsp)
movq 0x340(%rsp), %rdi
callq 0x2bbf0
movl %eax, %ecx
movl 0xbc(%rsp), %eax
cmpl %ecx, %eax
jge 0x3c251
movq 0x340(%rsp), %rdi
movl 0x334(%rsp), %esi
callq 0x2bc10
movq %rax, 0x328(%rsp)
movq 0x328(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
movl %eax, 0xb8(%rsp)
callq 0xac600
movl %eax, %ecx
movl 0xb8(%rsp), %eax
cmpl %ecx, %eax
jne 0x3c239
movq 0x328(%rsp), %rax
movq %rax, 0x320(%rsp)
movq 0x320(%rsp), %rdi
callq 0x48b60
cmpl $0x0, %eax
jne 0x3b612
jmp 0x3c23b
movq 0x320(%rsp), %rdi
callq 0x48b60
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x22040
movq %rax, 0x318(%rsp)
movl $0x0, 0x314(%rsp)
movl 0x314(%rsp), %eax
movl %eax, 0xb4(%rsp)
movq 0x320(%rsp), %rdi
callq 0x48b60
movl %eax, %ecx
movl 0xb4(%rsp), %eax
cmpl %ecx, %eax
jge 0x3b6a7
movq 0x318(%rsp), %rax
movslq 0x314(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x314(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x314(%rsp)
jmp 0x3b655
movq 0x320(%rsp), %rdi
callq 0x48b60
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x22040
movq %rax, 0x308(%rsp)
movl $0x0, 0x304(%rsp)
movl 0x304(%rsp), %eax
movl %eax, 0xb0(%rsp)
movq 0x320(%rsp), %rdi
callq 0x48b60
movl %eax, %ecx
movl 0xb0(%rsp), %eax
cmpl %ecx, %eax
jge 0x3b73c
movq 0x308(%rsp), %rax
movslq 0x304(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x304(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x304(%rsp)
jmp 0x3b6ea
movq 0x320(%rsp), %rdi
callq 0x48b60
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x22040
movq %rax, 0x2f8(%rsp)
movl $0x0, 0x2f4(%rsp)
movl 0x2f4(%rsp), %eax
movl %eax, 0xac(%rsp)
movq 0x320(%rsp), %rdi
callq 0x48b60
movl %eax, %ecx
movl 0xac(%rsp), %eax
cmpl %ecx, %eax
jge 0x3b7d1
movq 0x2f8(%rsp), %rax
movslq 0x2f4(%rsp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x2f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2f4(%rsp)
jmp 0x3b77f
movl $0x0, 0x2f0(%rsp)
movl 0x2f0(%rsp), %eax
movl %eax, 0xa8(%rsp)
movq 0x320(%rsp), %rdi
callq 0x48b60
movl %eax, %ecx
movl 0xa8(%rsp), %eax
cmpl %ecx, %eax
jge 0x3baec
movq 0x320(%rsp), %rdi
movl 0x2f0(%rsp), %esi
callq 0x48b80
movq %rax, 0x2e8(%rsp)
movq 0x2e8(%rsp), %rdi
movl 0x2f0(%rsp), %esi
callq 0x48bb0
movq 0x2e8(%rsp), %rdi
callq 0x2bcf0
movq %rax, %rsi
leaq 0x2d0(%rsp), %rdi
callq 0xcc8b0
movq 0x368(%rsp), %rsi
leaq 0x2d0(%rsp), %rdi
callq 0xcd4e0
movq 0x3a8(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x2b820
movsd %xmm0, 0xa0(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x2b830
movsd %xmm0, 0x98(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x2b840
movq 0x90(%rsp), %rdi
movsd 0x98(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xa0(%rsp), %xmm0
leaq 0x152ee7(%rip), %rsi    # 0x18e7be
movb $0x3, %al
callq 0x22f30
movq 0x358(%rsp), %rax
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
movq 0x318(%rsp), %rax
movslq 0x2f0(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x2e8(%rsp), %rdi
callq 0x48bd0
movq %rax, 0x2c8(%rsp)
leaq 0x2c0(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2b520
movq 0x2c0(%rsp), %rsi
leaq 0x2c8(%rsp), %rdi
callq 0x2bdb0
cmpl $0x0, %eax
je 0x3ba07
movq 0x2e8(%rsp), %rdi
callq 0x2bd00
movq %rax, %rsi
leaq 0x2a8(%rsp), %rdi
callq 0xcda10
movq 0x368(%rsp), %rsi
leaq 0x2a8(%rsp), %rdi
callq 0xceb30
movq 0x3a8(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x2b910
movsd %xmm0, 0x88(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x2b920
movsd %xmm0, 0x80(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x2b930
movq 0x78(%rsp), %rdi
movsd 0x80(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x88(%rsp), %xmm0
leaq 0x152dec(%rip), %rsi    # 0x18e7ca
movb $0x3, %al
callq 0x22f30
movq 0x350(%rsp), %rax
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
movq 0x308(%rsp), %rax
movslq 0x2f0(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x2e8(%rsp), %rdi
callq 0x48bd0
movq %rax, 0x2a0(%rsp)
leaq 0x298(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2b520
movq 0x298(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
callq 0x2bdb0
cmpl $0x0, %eax
je 0x3bad4
movq 0x2e8(%rsp), %rdi
callq 0x48bf0
movq %rax, %rsi
leaq 0x288(%rsp), %rdi
callq 0xe3db0
movq 0x3a8(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x288(%rsp), %rdi
callq 0x48c00
movsd %xmm0, 0x70(%rsp)
leaq 0x288(%rsp), %rdi
callq 0x48c10
movq 0x68(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x70(%rsp), %xmm0
leaq 0x152d2c(%rip), %rsi    # 0x18e7d7
movb $0x2, %al
callq 0x22f30
movq 0x3a0(%rsp), %rax
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
movq 0x2f8(%rsp), %rax
movslq 0x2f0(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3bad6
movl 0x2f0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2f0(%rsp)
jmp 0x3b7dc
movl $0x0, 0x284(%rsp)
movl 0x284(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x320(%rsp), %rdi
callq 0x2bc40
movl %eax, %ecx
movl 0x64(%rsp), %eax
cmpl %ecx, %eax
jge 0x3c1e0
movq 0x320(%rsp), %rdi
movl 0x284(%rsp), %esi
callq 0x2bc60
movq %rax, 0x278(%rsp)
movq 0x278(%rsp), %rdi
callq 0x48c20
movq %rax, 0x270(%rsp)
movq 0x278(%rsp), %rdi
callq 0x48c30
movq %rax, 0x268(%rsp)
movq 0x278(%rsp), %rdi
callq 0x48c40
movq %rax, 0x260(%rsp)
movq 0x270(%rsp), %rdi
callq 0x48c50
movl %eax, 0x25c(%rsp)
movq 0x268(%rsp), %rdi
callq 0x48c50
movl %eax, 0x258(%rsp)
movq 0x260(%rsp), %rdi
callq 0x48c50
movl %eax, 0x254(%rsp)
movq 0x278(%rsp), %rdi
callq 0x48c60
movq %rax, 0x248(%rsp)
leaq 0x240(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2b520
movq 0x240(%rsp), %rsi
leaq 0x248(%rsp), %rdi
callq 0x2bdb0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x63(%rsp)
je 0x3bc43
movq 0x278(%rsp), %rdi
callq 0x48c60
movq %rax, 0x238(%rsp)
leaq 0x230(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2b520
movq 0x230(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x2bdb0
cmpl $0x0, %eax
setne %al
movb %al, 0x63(%rsp)
movb 0x63(%rsp), %al
testb $0x1, %al
jne 0x3bc50
jmp 0x3be13
movq 0x368(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0x0, %eax
je 0x3bd3d
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x2f8(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x308(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x2f8(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %ebp
movq 0x308(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %ebx
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r11d
movq 0x2f8(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x308(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x152ac5(%rip), %rsi    # 0x18e7e1
movl %ebp, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3be0e
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x2f8(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x308(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x2f8(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %ebp
movq 0x308(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %ebx
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r11d
movq 0x2f8(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x308(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x1529ef(%rip), %rsi    # 0x18e7e1
movl %ebp, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3c1c8
movq 0x278(%rsp), %rdi
callq 0x48c60
movq %rax, 0x228(%rsp)
leaq 0x220(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2b520
movq 0x220(%rsp), %rsi
leaq 0x228(%rsp), %rdi
callq 0x2bdb0
cmpl $0x0, %eax
je 0x3bf93
movq 0x368(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0x0, %eax
je 0x3bf01
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x2f8(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x2f8(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x2f8(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x152912(%rip), %rsi    # 0x18e7ff
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3bf8e
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x2f8(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x2f8(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x2f8(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x152880(%rip), %rsi    # 0x18e7ff
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3c1c6
movq 0x278(%rsp), %rdi
callq 0x48c60
movq %rax, 0x218(%rsp)
leaq 0x210(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2b520
movq 0x210(%rsp), %rsi
leaq 0x218(%rsp), %rdi
callq 0x2bdb0
cmpl $0x0, %eax
je 0x3c113
movq 0x368(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0x0, %eax
je 0x3c081
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x308(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x308(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x308(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x1527a7(%rip), %rsi    # 0x18e814
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3c10e
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x308(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r8d
movq 0x308(%rsp), %rax
movl 0x258(%rsp), %esi
movl (%rax,%rsi,4), %r9d
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r10d
movq 0x308(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %eax
leaq 0x152715(%rip), %rsi    # 0x18e814
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x22f30
jmp 0x3c1c4
movq 0x368(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0x0, %eax
je 0x3c175
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %esi
movl (%rax,%rsi,4), %r8d
leaq 0x1526c0(%rip), %rsi    # 0x18e82c
movb $0x0, %al
callq 0x22f30
jmp 0x3c1c2
movq 0x3a8(%rsp), %rdi
movq 0x318(%rsp), %rax
movl 0x25c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x318(%rsp), %rax
movl 0x258(%rsp), %ecx
movl (%rax,%rcx,4), %ecx
movq 0x318(%rsp), %rax
movl 0x254(%rsp), %esi
movl (%rax,%rsi,4), %r8d
leaq 0x152671(%rip), %rsi    # 0x18e82c
movb $0x0, %al
callq 0x22f30
jmp 0x3c1c4
jmp 0x3c1c6
jmp 0x3c1c8
jmp 0x3c1ca
movl 0x284(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x284(%rsp)
jmp 0x3baf7
movq 0x318(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x3c1fd
movq 0x58(%rsp), %rdi
callq 0x22da0
movq 0x308(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x3c21a
movq 0x50(%rsp), %rdi
callq 0x22da0
movq 0x2f8(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, %rax
je 0x3c237
movq 0x48(%rsp), %rdi
callq 0x22da0
jmp 0x3c239
jmp 0x3c23b
movl 0x334(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x334(%rsp)
jmp 0x3b575
jmp 0x3c253
movl 0x34c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34c(%rsp)
jmp 0x3b4b4
movl $0x0, 0x20c(%rsp)
movl 0x20c(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x370(%rsp), %rdi
callq 0x2baf0
movl %eax, %ecx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x3c3e3
movq 0x370(%rsp), %rdi
movl 0x20c(%rsp), %esi
callq 0x2bb10
movq %rax, 0x200(%rsp)
leaq 0x1c2713(%rip), %rsi    # 0x1fe9d0
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x48c80
movq 0x38(%rsp), %rdi
movq 0x368(%rsp), %rsi
callq 0xc1dd0
jmp 0x3c2e3
movq 0x200(%rsp), %rdi
callq 0x2bae0
movq %rax, 0x30(%rsp)
jmp 0x3c2f7
movq 0x30(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0xc1dd0
jmp 0x3c30b
movq 0xd8(%rsp), %rdi
movq 0x200(%rsp), %rsi
movq 0x360(%rsp), %rcx
movq 0x358(%rsp), %r8
movq 0x350(%rsp), %r9
movq 0x3a0(%rsp), %rdx
movq 0x3a8(%rsp), %r10
movq %rsp, %rax
movq %r10, 0x8(%rax)
movq %rdx, (%rax)
leaq 0xf0(%rsp), %rdx
callq 0x3b3e0
movl %eax, 0x2c(%rsp)
jmp 0x3c360
movl 0x2c(%rsp), %eax
cmpl $0x0, %eax
jne 0x3c3a4
movl $0x0, 0x384(%rsp)
movl $0x1, 0xe0(%rsp)
jmp 0x3c3af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe8(%rsp)
movl %eax, 0xe4(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xc1b00
jmp 0x3c3ff
movl $0x0, 0xe0(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xc1b00
movl 0xe0(%rsp), %eax
testl %eax, %eax
je 0x3c3cb
jmp 0x3c3c9
jmp 0x3c3ee
jmp 0x3c3cd
movl 0x20c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20c(%rsp)
jmp 0x3c274
movl $0x1, 0x384(%rsp)
movl 0x384(%rsp), %eax
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %rbp
retq
movq 0xe8(%rsp), %rdi
callq 0x23290
nopl (%rax)