// File: /workspace/github_cpp_makefile_star2_O2/srajangarg[P]raytracer/src/core/SceneLoader.cpp
// Function: SceneLoader::doI(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
SceneInstance * SceneLoader::doI(istream & str, string & name)
{
  name = getString(str);

  if (name.empty())
  {
    *err << "Couldn't read instance name at ";
    errLine(str.tellg());
    return NULL;
  }

  string var = getString(str);

  if (groups[var] == NULL)
  {
    *err << "Instancing node " << var << " which doesn't exist yet at ";
    curPos(*err, str.tellg());
    *err << endl;
    return NULL;
  }

  SceneInstance * n = new SceneInstance();
  instances.push_back(n); //nodes[name] = n;
  n->name_ = name;
  n->child_ = groups[var];

  do
  {
    int state = findOpenOrClosedParen(str);

    if (state == ERROR)
      return NULL;
    else if (state == CLOSED)
      return n;
    else if (state == OPEN)
    {
      string cmd;
      vector<ParametricValue *> values;

      if (readCommand(str, cmd))
      {
        if (cmd == "R") // load rotations
        {
          int numv = getValues(str, values);
          Rotate * r = NULL;

          if (numv < 1)
          {
            *err << "R with no args at ";
            errLine(str.tellg());
          }
          else if (numv < 4)
          {
            cleanAfter(values, 1);
            r = new Rotate();
            r->angle = values[0];
          }
          else
          {
            cleanAfter(values, 4);
            r = new Rotate();
            r->angle = values[0];

            for (int i = 0; i < 3; i++)
              r->axis[i] = values[i + 1];
          }

          if (r != NULL)
            n->transforms_.push_back(r);
        }
        else if (cmd == "Xform")
        {
          int numv = getValues(str, values);
          GeneralTransform * g = NULL;

          if (numv < 9)
          {
            *err << "Xform with too few parameters at ";
            errLine(str.tellg());
          }
          else if (numv < 16)     // 2d
          {
            cleanAfter(values, 9);
            g = new GeneralTransform();

            for (int i = 0; i < 9; i++)
              g->matrix.push_back(values[i]);
          }
          else
          {
            cleanAfter(values, 16);
            g = new GeneralTransform();

            for (int i = 0; i < 16; i++)
              g->matrix.push_back(values[i]);
          }

          if (g != NULL)
            n->transforms_.push_back(g);
        }
        else if (cmd == "T")
        {
          int numv = getValues(str, values);
          Translate * t = NULL;

          if (numv < 2)
          {
            *err << "T with too few parameters at ";
            errLine(str.tellg());
          }
          else if (numv == 2)
          {
            t = new Translate();

            for (int i = 0; i < 2; i++)
              t->translate[i] = values[i];
          }
          else
          {
            cleanAfter(values, 3);
            t = new Translate();

            for (int i = 0; i < 3; i++)
              t->translate[i] = values[i];
          }

          if (t != NULL)
            n->transforms_.push_back(t);
        }
        else if (cmd == "S")
        {
          int numv = getValues(str, values);
          Scale * s = NULL;

          if (numv < 2)
          {
            *err << "S with too few parameters at ";
            errLine(str.tellg());
          }
          else if (numv == 2)
          {
            s = new Scale();

            for (int i = 0; i < 2; i++)
              s->scale[i] = values[i];
          }
          else
          {
            s = new Scale();

            for (int i = 0; i < 3; i++)
              s->scale[i] = values[i];
          }

          if (s != NULL)
            n->transforms_.push_back(s);
        }
        else if (cmd == "color")
        {
          int numv = getValues(str, values);
          ParametricColor * c = NULL;

          if (numv < 3)
          {
            *err << "color with too few parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 3);
            c = new ParametricColor();

            for (int i = 0; i < 3; i++)
              c->color_[i] = values[i];
          }

          if (c != NULL)
            n->color_ = c;
        }
        else if (cmd == "lod")
        {
          int numv = getValues(str, values);
          LOD * l = NULL;

          if (numv < 1)
          {
            *err << "lod with no parameters at ";
            errLine(str.tellg());
          }
          else
          {
            //cout << "got lod" << endl;
            cleanAfter(values, 1);
            l = new LOD();
            l->level_ = values[0];
          }

          if (l != NULL)
            n->lod_ = l;
        }
        else
        {
          *err << "Error: command " << cmd << " not recognized at ";
          curPos(*err, str.tellg());
          *err << endl;
        }

        findCloseParen(str);
      }
    }
  }
  while (true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6e00
movq %r15, %rdi
movq %r12, %rsi
callq 0x43b0
movq %r12, %rdi
callq 0x4170
cmpq $0x0, 0x8(%r15)
je 0x7de3
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6e00
leaq 0x18(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x9a8c
cmpq $0x0, (%rax)
je 0x7e0c
pushq $0x58
popq %rdi
callq 0x4320
movq %rax, %r13
movq %rax, %rdi
callq 0x5edc
leaq 0x8(%rsp), %rsi
movq %r13, (%rsi)
leaq 0x78(%rbx), %rdi
callq 0x9af2
movq 0x8(%rsp), %rdi
addq $0x8, %rdi
movq %r15, %rsi
callq 0x41c0
leaq 0x58(%rsp), %rsi
movq %r12, %rdi
callq 0x9a8c
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
leaq 0x48(%rsp), %r13
leaq 0x38(%rsp), %r15
leaq 0x1afd0(%rip), %r12     # 0x227b1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71d2
testl %eax, %eax
jne 0x7dd0
movq %r13, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movb $0x0, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x7050
testb %al, %al
je 0x7d84
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d52
testb %al, %al
je 0x78a1
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
testl %eax, %eax
jle 0x7958
leaq 0x10(%rsp), %rsi
cmpl $0x3, %eax
ja 0x7982
pushq $0x1
popq %rdx
callq 0x76d4
pushq $0x28
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b10
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rbp)
movq 0x8(%rsp), %rdi
addq $0x28, %rdi
movq %rbp, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
callq 0xb010
jmp 0x7d7c
movq %r15, %rdi
leaq 0x199dc(%rip), %rsi     # 0x21287
callq 0x4d52
testb %al, %al
je 0x78fe
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
cmpl $0x8, %eax
jg 0x7a1f
movq 0x90(%rbx), %rdi
leaq 0x199b2(%rip), %rsi     # 0x2128d
callq 0x4300
movq %r14, %rdi
callq 0x45a0
leaq 0x1aec2(%rip), %r12     # 0x227b1
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
movq %r15, %rdi
leaq 0x1ab5c(%rip), %rsi     # 0x22464
callq 0x4d52
testb %al, %al
je 0x79c5
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
cmpl $0x1, %eax
jg 0x7ae5
movq 0x90(%rbx), %rdi
leaq 0x19973(%rip), %rsi     # 0x212af
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
movq 0x90(%rbx), %rdi
leaq 0x1990e(%rip), %rsi     # 0x21274
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
pushq $0x4
popq %rdx
callq 0x76d4
pushq $0x28
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b10
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x8(%rbp)
pushq $0x2
popq %rcx
cmpq $0x5, %rcx
je 0x7884
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x79ac
movq %r15, %rdi
leaq 0x1a865(%rip), %rsi     # 0x22234
callq 0x4d52
testb %al, %al
je 0x7a84
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
cmpl $0x1, %eax
jg 0x7c02
movq 0x90(%rbx), %rdi
leaq 0x198ca(%rip), %rsi     # 0x212cd
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
leaq 0x10(%rsp), %rsi
cmpl $0xf, %eax
ja 0x7b22
pushq $0x9
popq %rdx
callq 0x76d4
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %r12
leaq 0x26fa1(%rip), %rax     # 0x2e9e8
movq %rax, (%r12)
movq %r12, %rbp
addq $0x8, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r12)
andq $0x0, 0x18(%r12)
xorl %r13d, %r13d
cmpq $0x48, %r13
je 0x7b78
movq 0x10(%rsp), %rsi
addq %r13, %rsi
movq %rbp, %rdi
callq 0x994e
addq $0x8, %r13
jmp 0x7a64
movq %r15, %rdi
leaq 0x1985d(%rip), %rsi     # 0x212eb
callq 0x4d52
testb %al, %al
je 0x7ba1
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
cmpl $0x2, %eax
jg 0x7cfa
movq 0x90(%rbx), %rdi
leaq 0x1982f(%rip), %rsi     # 0x212f1
callq 0x4300
movq %r14, %rdi
callq 0x45a0
leaq 0x1acdb(%rip), %r12     # 0x227b1
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
cmpl $0x2, %eax
jne 0x7c3f
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b34
movq 0x10(%rsp), %rax
pushq $0x1
popq %rcx
cmpq $0x3, %rcx
je 0x7c7c
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x7b09
pushq $0x10
popq %rdx
callq 0x76d4
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %r12
leaq 0x26eac(%rip), %rax     # 0x2e9e8
movq %rax, (%r12)
movq %r12, %rbp
addq $0x8, %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r12)
andq $0x0, 0x18(%r12)
xorl %r13d, %r13d
cmpq $0x80, %r13
je 0x7b78
movq 0x10(%rsp), %rsi
addq %r13, %rsi
movq %rbp, %rdi
callq 0x994e
addq $0x8, %r13
jmp 0x7b59
movq 0x8(%rsp), %rdi
addq $0x28, %rdi
movq %r12, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
callq 0xb010
leaq 0x48(%rsp), %r13
leaq 0x1ac15(%rip), %r12     # 0x227b1
jmp 0x7d7c
movq %r15, %rdi
leaq 0x19768(%rip), %rsi     # 0x21313
callq 0x4d52
testb %al, %al
je 0x7c99
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
callq 0x7388
testl %eax, %eax
jle 0x7da9
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x76d4
pushq $0x8
popq %rdi
callq 0x4320
andq $0x0, (%rax)
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
jmp 0x7d7c
cmpl $0x2, %eax
jne 0x7d34
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b52
movq 0x10(%rsp), %rax
pushq $0x1
popq %rcx
cmpq $0x3, %rcx
je 0x7d64
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x7c26
leaq 0x10(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x76d4
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b34
movq 0x10(%rsp), %rax
pushq $0x1
popq %rcx
cmpq $0x4, %rcx
je 0x7c7c
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x7c67
movq 0x8(%rsp), %rdi
addq $0x28, %rdi
movq %rbp, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
callq 0xb010
jmp 0x7d7c
movq 0x90(%rbx), %rdi
leaq 0x1968b(%rip), %rsi     # 0x21332
callq 0x4300
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x19681(%rip), %rsi     # 0x21342
callq 0x4300
movq 0x90(%rbx), %r12
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x6d66
movq 0x90(%rbx), %rdi
callq 0x4190
leaq 0x1aabc(%rip), %r12     # 0x227b1
jmp 0x7d7c
leaq 0x10(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x76d4
pushq $0x18
popq %rdi
callq 0x4320
movq %rax, %r12
movq %rax, %rdi
callq 0x9b70
movq 0x10(%rsp), %rax
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0x7d9b
movq (%rax,%rcx,8), %rdx
movq %rdx, (%r12,%rcx,8)
incq %rcx
jmp 0x7d21
pushq $0x20
popq %rdi
callq 0x4320
movq %rax, %rbp
movq %rax, %rdi
callq 0x9b52
movq 0x10(%rsp), %rax
pushq $0x1
popq %rcx
cmpq $0x4, %rcx
je 0x7d64
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x7d4f
movq 0x8(%rsp), %rdi
addq $0x28, %rdi
movq %rbp, 0x30(%rsp)
leaq 0x30(%rsp), %rsi
callq 0xb010
movq %r14, %rsi
callq 0x72de
leaq 0x10(%rsp), %rdi
callq 0xa7f0
movq %r15, %rdi
callq 0x4170
jmp 0x77e1
movq 0x8(%rsp), %rax
movq %r12, 0x40(%rax)
jmp 0x7b95
movq 0x90(%rbx), %rdi
leaq 0x19560(%rip), %rsi     # 0x21317
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x7d7c
cmpl $0x1, %eax
jne 0x7e63
movq 0x8(%rsp), %rbx
jmp 0x7e65
movq 0x90(%rbx), %rdi
leaq 0x19435(%rip), %rsi     # 0x21226
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
xorl %ebx, %ebx
jmp 0x7e6f
movq 0x90(%rbx), %rdi
leaq 0x1942c(%rip), %rsi     # 0x21246
callq 0x4300
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
leaq 0x19424(%rip), %rsi     # 0x21257
movq %rax, %rdi
callq 0x4300
movq 0x90(%rbx), %r15
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x6d66
movq 0x90(%rbx), %rdi
callq 0x4190
xorl %ebx, %ebx
leaq 0x58(%rsp), %rdi
callq 0x4170
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
movq %rax, %rbx
pushq $0x58
popq %rsi
movq %r13, %rdi
callq 0x4330
jmp 0x7ee5
jmp 0x7ec9
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ece
jmp 0x7ec9
jmp 0x7ec9
jmp 0x7ece
jmp 0x7ece
movq %rax, %rbx
jmp 0x7ee5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xa7f0
leaq 0x38(%rsp), %rdi
callq 0x4170
leaq 0x58(%rsp), %rdi
callq 0x4170
movq %rbx, %rdi
callq 0x45c0
nop