// File: srajangarg[P]raytracer/src/main.cpp
// Function: importSceneToWorld(SceneInstance*, Mat4, int)
void
importSceneToWorld(SceneInstance * inst, Mat4 localToWorld, int time)
{
  if (inst == NULL)
    return;

  Mat4 nodeXform;
  inst->computeTransform(nodeXform, time);
  localToWorld = localToWorld * nodeXform;
  SceneGroup * g = inst->getChild();

  if (g == NULL)   // for example if the whole scene fails to load
  {
    std::cout << "ERROR: We arrived at an instance with no child?!" << std::endl;
    return;
  }

  int ccount = g->getChildCount();

  for (int i = 0; i < ccount; i++)
  {
    importSceneToWorld(g->getChild(i), localToWorld, 0);
  }

  CameraInfo f;

  if (g->computeCamera(f, time))
  {
    viewToWorld = localToWorld;

    if (view != NULL)
      delete view;

    Vec3 eye(0.0, 0.0, 0.0);
    Vec3 LL(f.sides[FRUS_LEFT], f.sides[FRUS_BOTTOM], -f.sides[FRUS_NEAR]);
    Vec3 UL(f.sides[FRUS_LEFT], f.sides[FRUS_TOP], -f.sides[FRUS_NEAR]);
    Vec3 LR(f.sides[FRUS_RIGHT], f.sides[FRUS_BOTTOM], -f.sides[FRUS_NEAR]);
    Vec3 UR(f.sides[FRUS_RIGHT], f.sides[FRUS_TOP], -f.sides[FRUS_NEAR]);
    view = new View(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, RAYS_PER_PIXEL_EDGE);
  }

  LightInfo l;

  if (g->computeLight(l, time))
  {
    if (l.type == LIGHT_AMBIENT)
    {
      RGB amb = world->getAmbientLightColor();
      world->setAmbientLightColor(amb + l.color);
    }
    else if (l.type == LIGHT_DIRECTIONAL)
    {
      DirectionalLight * li = new DirectionalLight(l.color);
      Vec3 dir(0, 0, -1);
      li->setDirection(localToWorld * dir);
      world->addLight(li);
    }
    else if (l.type == LIGHT_POINT)
    {
      PointLight * li = new PointLight(l.color, l.falloff, l.deadDistance);
      Vec3 pos(0, 0, 0);
      li->setPosition(localToWorld * pos);
      world->addLight(li);
    }
    else if (l.type == LIGHT_AREA)
    { 
      AreaLight * li = new AreaLight(l.color, l.falloff, l.deadDistance, l.offset);
      Vec3 pos(0, 0, 0);
      li->setPosition(localToWorld * pos);
      world->addLight(li);
    }
    else if (l.type == LIGHT_SPOT)
    {
      throw "oh no";
    }
  }

  double r;
  MaterialInfo m;

  if (g->computeSphere(r, m, time))
  {
    Material mat(m.k[0], m.k[1], m.k[2], m.k[3], m.k[4], m.k[MAT_MS], m.k[5], m.k[6]);
    Sphere * sph = new Sphere(r, m.color, mat, localToWorld);
    world->addPrimitive(sph);
  }

  TriangleMesh * t;
  unordered_map<MeshVertex*, vector<pair<Triangle*, int>> > vertexToTriangles;

  if (g->computeMesh(t, m, time))
  {
    Material mat(m.k[0], m.k[1], m.k[2], m.k[3], m.k[4], m.k[MAT_MS], m.k[5], m.k[6]);

    for (auto it = t->triangles.begin(); it != t->triangles.end(); ++it)
    {
      Triangle * tri = new Triangle(
        t->vertices[ (**it).ind[0] ]->pos,
        t->vertices[ (**it).ind[1] ]->pos,
        t->vertices[ (**it).ind[2] ]->pos,
        m.color, mat, localToWorld, smooth_normals);
      world->addPrimitive(tri);

      if (smooth_normals)
      {
        // map vertex to which triangles this verttex belongs to
        for (int i = 0; i < 3; ++i)
        {
          if(vertexToTriangles.find(t->vertices[(**it).ind[i]]) == vertexToTriangles.end())
            vertexToTriangles[t->vertices[(**it).ind[i]]] = {make_pair(tri, i)};
          else
            vertexToTriangles[t->vertices[(**it).ind[i]]].push_back(make_pair(tri, i));
        }
      }
    }

    if (smooth_normals)
    {
      // calculate average normal at each vertex, and place them at norms
      // in each of the respective triangles
      for (auto it : vertexToTriangles)
      { 
          Vec3 res(0, 0, 0);

          for (auto tripair : it.second)
            res += tripair.first->calculateFaceNormal();
          res.normalize();
          for (auto tripair : it.second)
              tripair.first->norms[tripair.second] = res;
      }
    }
  }

  std::cout << "Imported scene file" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x700, %rsp            # imm = 0x700
movq %rsi, -0x5a8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x41a39
jmp 0x428d6
leaq -0x98(%rbp), %rdi
callq 0x3ddf0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq -0x98(%rbp), %rsi
callq 0x9c80
movq -0x5a8(%rbp), %rsi
leaq -0x118(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xa1a0
movq -0x5a8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0xa020
movq -0x8(%rbp), %rdi
callq 0x9b80
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
jne 0x41ac6
movq 0x1a522(%rip), %rdi     # 0x5bfc8
leaq 0x7333(%rip), %rsi      # 0x48de0
callq 0x53e0
movq %rax, %rdi
movq 0x1a4f4(%rip), %rsi     # 0x5bfb0
callq 0x5440
jmp 0x428d6
movq -0x120(%rbp), %rdi
callq 0x8870
movl %eax, -0x124(%rbp)
movl $0x0, -0x128(%rbp)
movl -0x128(%rbp), %eax
cmpl -0x124(%rbp), %eax
jge 0x41b42
movq -0x120(%rbp), %rdi
movl -0x128(%rbp), %esi
callq 0x8890
movq -0x5a8(%rbp), %rsi
movq %rax, -0x5b0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x3eb50
movq -0x5b0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
xorl %edx, %edx
callq 0x41a10
movl -0x128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0x41ae2
leaq -0x1e0(%rbp), %rdi
callq 0x435d0
movq -0x120(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq -0x1e0(%rbp), %rsi
callq 0x8a50
testb $0x1, %al
jne 0x41b6d
jmp 0x41d39
movq -0x5a8(%rbp), %rsi
leaq 0x1b28d(%rip), %rdi     # 0x5ce08
callq 0xa020
cmpq $0x0, 0x1b278(%rip)     # 0x5ce00
je 0x41bad
movq 0x1b26f(%rip), %rax     # 0x5ce00
movq %rax, -0x5b8(%rbp)
cmpq $0x0, %rax
je 0x41bab
movq -0x5b8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x41bad
leaq -0x1f8(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x147b0
movsd -0x1d8(%rbp), %xmm0
movsd -0x1c8(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
movapd 0x5f17(%rip), %xmm3     # 0x47b00
movaps %xmm3, -0x600(%rbp)
pxor %xmm3, %xmm2
leaq -0x210(%rbp), %rdi
movq %rdi, -0x5e0(%rbp)
callq 0x147b0
movaps -0x600(%rbp), %xmm3
movsd -0x1d8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
pxor %xmm3, %xmm2
leaq -0x228(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0x147b0
movaps -0x600(%rbp), %xmm3
movsd -0x1d0(%rbp), %xmm0
movsd -0x1c8(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
pxor %xmm3, %xmm2
leaq -0x240(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x147b0
movaps -0x600(%rbp), %xmm3
movsd -0x1d0(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
pxor %xmm3, %xmm2
leaq -0x258(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x147b0
movl $0x90, %edi
callq 0x5400
movq -0x5e8(%rbp), %rsi
movq -0x5e0(%rbp), %rdx
movq -0x5d8(%rbp), %rcx
movq -0x5d0(%rbp), %r8
movq -0x5c8(%rbp), %r9
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x5c0(%rbp)
movq %rsp, %rax
movl $0x2, 0x10(%rax)
movl $0x200, 0x8(%rax)       # imm = 0x200
movl $0x200, (%rax)          # imm = 0x200
callq 0x3ef50
jmp 0x41d01
movq -0x5c0(%rbp), %rax
movq %rax, 0x1b0f1(%rip)     # 0x5ce00
jmp 0x41d39
movq -0x5c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x90, %esi
callq 0x5410
jmp 0x428eb
leaq -0x2a8(%rbp), %rdi
callq 0x435e0
movq -0x120(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq -0x2a8(%rbp), %rsi
callq 0x89f0
testb $0x1, %al
jne 0x41d64
jmp 0x42098
cmpl $0x0, -0x2a8(%rbp)
jne 0x41dc4
movq 0x1b084(%rip), %rsi     # 0x5cdf8
leaq -0x2c0(%rbp), %rdi
callq 0x3f6d0
movq 0x1b071(%rip), %rax     # 0x5cdf8
movq %rax, -0x608(%rbp)
leaq -0x2a8(%rbp), %rdx
addq $0x8, %rdx
leaq -0x2d8(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0x43010
movq -0x608(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3f6a0
jmp 0x42096
cmpl $0x1, -0x2a8(%rbp)
jne 0x41e99
movl $0x50, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x610(%rbp)
leaq -0x2a0(%rbp), %rsi
callq 0x3bad0
jmp 0x41df6
movq -0x610(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq -0x2f8(%rbp), %rdi
xorps %xmm1, %xmm1
movsd 0x539a(%rip), %xmm2     # 0x471b0
movaps %xmm1, %xmm0
callq 0x147b0
movq -0x5a8(%rbp), %rsi
movq -0x2e0(%rbp), %rax
movq %rax, -0x618(%rbp)
leaq -0x310(%rbp), %rdi
leaq -0x2f8(%rbp), %rdx
callq 0x3e350
movq -0x618(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x3bb30
movq 0x1af98(%rip), %rdi     # 0x5cdf8
movq -0x2e0(%rbp), %rsi
callq 0x3f670
jmp 0x42094
movq -0x610(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x50, %esi
callq 0x5410
jmp 0x428eb
cmpl $0x2, -0x2a8(%rbp)
jne 0x41f79
movl $0x50, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x620(%rbp)
leaq -0x2a0(%rbp), %rsi
movsd -0x288(%rbp), %xmm0
movsd -0x278(%rbp), %xmm1
callq 0x3b430
jmp 0x41edb
movq -0x620(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x330(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x147b0
movq -0x5a8(%rbp), %rsi
movq -0x318(%rbp), %rax
movq %rax, -0x628(%rbp)
leaq -0x348(%rbp), %rdi
leaq -0x330(%rbp), %rdx
callq 0x3e350
movq -0x628(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x3b530
movq 0x1aeb8(%rip), %rdi     # 0x5cdf8
movq -0x318(%rbp), %rsi
callq 0x3f670
jmp 0x42092
movq -0x620(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x50, %esi
callq 0x5410
jmp 0x428eb
cmpl $0x3, -0x2a8(%rbp)
jne 0x4205e
movl $0x58, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x630(%rbp)
leaq -0x2a0(%rbp), %rsi
movsd -0x288(%rbp), %xmm0
movsd -0x278(%rbp), %xmm1
movsd -0x270(%rbp), %xmm2
callq 0x3b740
jmp 0x41fc3
movq -0x630(%rbp), %rax
movq %rax, -0x350(%rbp)
leaq -0x368(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x147b0
movq -0x5a8(%rbp), %rsi
movq -0x350(%rbp), %rax
movq %rax, -0x638(%rbp)
leaq -0x380(%rbp), %rdi
leaq -0x368(%rbp), %rdx
callq 0x3e350
movq -0x638(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3b850
movq 0x1add0(%rip), %rdi     # 0x5cdf8
movq -0x350(%rbp), %rsi
callq 0x3f670
jmp 0x42090
movq -0x630(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x58, %esi
callq 0x5410
jmp 0x428eb
cmpl $0x4, -0x2a8(%rbp)
jne 0x4208e
movl $0x8, %edi
callq 0x5210
movq %rax, %rdi
leaq 0x6d96(%rip), %rax      # 0x48e11
movq %rax, (%rdi)
movq 0x19f33(%rip), %rsi     # 0x5bfb8
xorl %eax, %eax
movl %eax, %edx
callq 0x56d0
jmp 0x42090
jmp 0x42092
jmp 0x42094
jmp 0x42096
jmp 0x42098
leaq -0x3d8(%rbp), %rdi
callq 0x43600
movq -0x120(%rbp), %rdi
movl -0x14(%rbp), %ecx
leaq -0x388(%rbp), %rsi
leaq -0x3d8(%rbp), %rdx
callq 0x8970
testb $0x1, %al
jne 0x420ca
jmp 0x421ba
movsd -0x3d8(%rbp), %xmm0
movsd -0x3d0(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm1
movsd -0x3c8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm5
movsd -0x3c0(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm3
movsd -0x3b8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm4
movsd -0x3b0(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm6
movsd -0x3a8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm7
leaq -0x3f8(%rbp), %rdi
movq %rdi, -0x648(%rbp)
movaps %xmm5, %xmm2
callq 0x43620
movl $0x148, %edi            # imm = 0x148
callq 0x5400
movq -0x648(%rbp), %rdx
movq -0x5a8(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x640(%rbp)
movsd -0x388(%rbp), %xmm0
leaq -0x3a0(%rbp), %rsi
callq 0x3d2e0
jmp 0x4216f
movq -0x640(%rbp), %rax
movq %rax, -0x400(%rbp)
movq 0x1ac74(%rip), %rdi     # 0x5cdf8
movq -0x400(%rbp), %rsi
callq 0x3f640
jmp 0x421ba
movq -0x640(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x148, %esi            # imm = 0x148
callq 0x5410
jmp 0x428eb
leaq -0x440(%rbp), %rdi
callq 0x436b0
movq -0x120(%rbp), %rdi
movl -0x14(%rbp), %ecx
leaq -0x408(%rbp), %rsi
leaq -0x3d8(%rbp), %rdx
callq 0x88f0
movb %al, -0x649(%rbp)
jmp 0x421eb
movb -0x649(%rbp), %al
testb $0x1, %al
jne 0x421fa
jmp 0x42899
movsd -0x3d8(%rbp), %xmm0
movsd -0x3d0(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm1
movsd -0x3c8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm5
movsd -0x3c0(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm3
movsd -0x3b8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm4
movsd -0x3b0(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm6
movsd -0x3a8(%rbp), %xmm2
cvtsd2ss %xmm2, %xmm7
leaq -0x460(%rbp), %rdi
movaps %xmm5, %xmm2
callq 0x43620
jmp 0x4225f
movq -0x408(%rbp), %rdi
addq $0x18, %rdi
callq 0x6e00
movq %rax, -0x468(%rbp)
movq -0x408(%rbp), %rdi
addq $0x18, %rdi
callq 0x6e70
movq %rax, -0x470(%rbp)
leaq -0x468(%rbp), %rdi
leaq -0x470(%rbp), %rsi
callq 0x6e30
testb $0x1, %al
jne 0x422a9
jmp 0x42676
movl $0x1d8, %edi            # imm = 0x1D8
callq 0x5400
movq %rax, -0x658(%rbp)
jmp 0x422bc
movq -0x408(%rbp), %rax
movq %rax, -0x688(%rbp)
leaq -0x468(%rbp), %rdi
movq %rdi, -0x678(%rbp)
callq 0x6ea0
movq -0x688(%rbp), %rdi
movq (%rax), %rax
movslq (%rax), %rsi
callq 0x436d0
movq -0x678(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x668(%rbp)
movq -0x408(%rbp), %rax
movq %rax, -0x680(%rbp)
callq 0x6ea0
movq -0x680(%rbp), %rdi
movq (%rax), %rax
movslq 0x4(%rax), %rsi
callq 0x436d0
movq -0x678(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x660(%rbp)
movq -0x408(%rbp), %rax
movq %rax, -0x670(%rbp)
callq 0x6ea0
movq -0x670(%rbp), %rdi
movq (%rax), %rax
movslq 0x8(%rax), %rsi
callq 0x436d0
movq -0x5a8(%rbp), %r9
movq -0x658(%rbp), %rdi
movq -0x668(%rbp), %rsi
movq -0x660(%rbp), %rdx
movq (%rax), %rcx
leaq -0x3a0(%rbp), %r8
movzbl 0x1ab05(%rip), %r10d    # 0x5ce90
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, 0x8(%rax)
movq %r9, (%rax)
leaq -0x460(%rbp), %r9
callq 0x3d670
jmp 0x423a7
movq -0x658(%rbp), %rax
movq %rax, -0x478(%rbp)
movq 0x1aa3c(%rip), %rdi     # 0x5cdf8
movq -0x478(%rbp), %rsi
callq 0x3f640
jmp 0x423ca
testb $0x1, 0x1aabf(%rip)     # 0x5ce90
je 0x42663
movl $0x0, -0x47c(%rbp)
cmpl $0x3, -0x47c(%rbp)
jge 0x42661
movq -0x408(%rbp), %rax
movq %rax, -0x698(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x6ea0
movq -0x698(%rbp), %rdi
movq (%rax), %rax
movslq -0x47c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
callq 0x436d0
movq %rax, %rsi
leaq -0x440(%rbp), %rdi
callq 0x43720
movq %rax, -0x690(%rbp)
jmp 0x4243a
movq -0x690(%rbp), %rax
movq %rax, -0x488(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x43750
movq %rax, -0x490(%rbp)
leaq -0x488(%rbp), %rdi
leaq -0x490(%rbp), %rsi
callq 0x436f0
testb $0x1, %al
jne 0x42477
jmp 0x42592
leaq -0x478(%rbp), %rdi
leaq -0x47c(%rbp), %rsi
callq 0x43780
movl %edx, -0x6a4(%rbp)
movq %rax, -0x6a0(%rbp)
jmp 0x42499
movl -0x6a4(%rbp), %eax
movq -0x6a0(%rbp), %rcx
movq %rcx, -0x4c0(%rbp)
movl %eax, -0x4b8(%rbp)
movl -0x4b8(%rbp), %eax
movl %eax, -0x4a8(%rbp)
movq -0x4c0(%rbp), %rax
movq %rax, -0x4b0(%rbp)
leaq -0x4b0(%rbp), %rax
movq %rax, -0x4a0(%rbp)
movq $0x1, -0x498(%rbp)
movq -0x408(%rbp), %rax
movq %rax, -0x6b8(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x6ea0
movq -0x6b8(%rbp), %rdi
movq (%rax), %rax
movslq -0x47c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
callq 0x436d0
movq %rax, %rsi
leaq -0x440(%rbp), %rdi
callq 0x437b0
movq %rax, -0x6b0(%rbp)
jmp 0x42532
movq -0x6b0(%rbp), %rdi
movq -0x4a0(%rbp), %rsi
movq -0x498(%rbp), %rdx
callq 0x437e0
jmp 0x4254e
jmp 0x4264b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x428df
movq -0x658(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
movl $0x1d8, %esi            # imm = 0x1D8
callq 0x5410
jmp 0x428df
movq -0x408(%rbp), %rax
movq %rax, -0x6c8(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x6ea0
movq -0x6c8(%rbp), %rdi
movq (%rax), %rax
movslq -0x47c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
callq 0x436d0
movq %rax, %rsi
leaq -0x440(%rbp), %rdi
callq 0x437b0
movq %rax, -0x6c0(%rbp)
jmp 0x425de
leaq -0x478(%rbp), %rdi
leaq -0x47c(%rbp), %rsi
callq 0x43780
movl %edx, -0x6d4(%rbp)
movq %rax, -0x6d0(%rbp)
jmp 0x42600
movq -0x6c0(%rbp), %rdi
movl -0x6d4(%rbp), %eax
movq -0x6d0(%rbp), %rcx
movq %rcx, -0x4e0(%rbp)
movl %eax, -0x4d8(%rbp)
movl -0x4d8(%rbp), %eax
movl %eax, -0x4c8(%rbp)
movq -0x4e0(%rbp), %rax
movq %rax, -0x4d0(%rbp)
leaq -0x4d0(%rbp), %rsi
callq 0x43830
jmp 0x42649
jmp 0x4264b
jmp 0x4264d
movl -0x47c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x47c(%rbp)
jmp 0x423e1
jmp 0x42663
jmp 0x42665
leaq -0x468(%rbp), %rdi
callq 0x6ec0
jmp 0x42276
testb $0x1, 0x1a813(%rip)     # 0x5ce90
je 0x42897
leaq -0x440(%rbp), %rax
movq %rax, -0x4e8(%rbp)
movq -0x4e8(%rbp), %rdi
callq 0x43860
movq %rax, -0x4f0(%rbp)
movq -0x4e8(%rbp), %rdi
callq 0x43750
movq %rax, -0x4f8(%rbp)
leaq -0x4f0(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0x43890
testb $0x1, %al
jne 0x426d3
jmp 0x42895
leaq -0x4f0(%rbp), %rdi
callq 0x438c0
movq %rax, %rsi
leaq -0x518(%rbp), %rdi
callq 0x438f0
jmp 0x426f0
leaq -0x530(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x147b0
jmp 0x42707
leaq -0x518(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x538(%rbp)
movq -0x538(%rbp), %rdi
callq 0x43930
movq %rax, -0x540(%rbp)
movq -0x538(%rbp), %rdi
callq 0x43960
movq %rax, -0x548(%rbp)
leaq -0x540(%rbp), %rdi
leaq -0x548(%rbp), %rsi
callq 0x43990
testb $0x1, %al
jne 0x42758
jmp 0x427cb
leaq -0x540(%rbp), %rdi
callq 0x439d0
movups (%rax), %xmm0
movaps %xmm0, -0x560(%rbp)
movq -0x560(%rbp), %rsi
leaq -0x578(%rbp), %rdi
callq 0x3dd50
jmp 0x42783
leaq -0x530(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x3ea60
jmp 0x42798
jmp 0x4279a
leaq -0x540(%rbp), %rdi
callq 0x439f0
jmp 0x4273f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x518(%rbp), %rdi
callq 0x43a10
jmp 0x428df
leaq -0x530(%rbp), %rdi
callq 0x14e00
jmp 0x427d9
leaq -0x518(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x580(%rbp)
movq -0x580(%rbp), %rdi
callq 0x43930
movq %rax, -0x588(%rbp)
movq -0x580(%rbp), %rdi
callq 0x43960
movq %rax, -0x590(%rbp)
leaq -0x588(%rbp), %rdi
leaq -0x590(%rbp), %rsi
callq 0x43990
testb $0x1, %al
jne 0x4282a
jmp 0x42878
leaq -0x588(%rbp), %rdi
callq 0x439d0
movups (%rax), %xmm0
movaps %xmm0, -0x5a0(%rbp)
movq -0x5a0(%rbp), %rax
movslq -0x598(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x140(%rax,%rcx,8), %rdi
leaq -0x530(%rbp), %rsi
callq 0x72d0
jmp 0x42868
jmp 0x4286a
leaq -0x588(%rbp), %rdi
callq 0x439f0
jmp 0x42811
leaq -0x518(%rbp), %rdi
callq 0x43a10
leaq -0x4f0(%rbp), %rdi
callq 0x43a30
jmp 0x426b7
jmp 0x42897
jmp 0x42899
movq 0x19728(%rip), %rdi     # 0x5bfc8
leaq 0x6570(%rip), %rsi      # 0x48e17
callq 0x53e0
movq %rax, -0x6e0(%rbp)
jmp 0x428b5
movq -0x6e0(%rbp), %rdi
movq 0x196ed(%rip), %rsi     # 0x5bfb0
callq 0x5440
jmp 0x428ca
leaq -0x440(%rbp), %rdi
callq 0x43a60
addq $0x700, %rsp            # imm = 0x700
popq %rbp
retq
leaq -0x440(%rbp), %rdi
callq 0x43a60
movq -0x260(%rbp), %rdi
callq 0x5720
nopw (%rax,%rax)