// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/core/SceneLoader.cpp
// Function: SceneLoader::doInclude(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool SceneLoader::doInclude(istream & str, string & name)
{
  if (!getName(str, "include", name))
    return false;

  SceneGroup * n = new SceneGroup();
  groups[name] = n;
  n->name_ = name;
  string file = getQuoted(str);
  n->mesh_ = new TriangleMesh(file);

  do
  {
    int state = findOpenOrClosedParen(str);

    if (state == ERROR)
    {
      if (n->meshMaterial_ == NULL)
      {
        n->meshMaterial_ = new ParametricMaterial();
        setMaterialDefaults(n->meshMaterial_);
      }

      return false;
    }
    else if (state == CLOSED)
    {
      if (n->meshMaterial_ == NULL)
      {
        n->meshMaterial_ = new ParametricMaterial();
        setMaterialDefaults(n->meshMaterial_);
      }

      return true;
    }
    else if (state == OPEN)
    {
      string cmd;

      if (readCommand(str, cmd))
      {
        if (cmd == "material")
        {
          string matName = getString(str);

          if (matName.empty())
          {
            *err << "No material name after material command at ";
            errLine(str.tellg());
          }
          else if (materials[matName] == NULL)
          {
            *err << "Unknown material " << matName << " referenced at ";
            errLine(str.tellg());
          }
          else
          {
            n->meshMaterial_ = materials[matName];
          }
        }
        else
        {
          *err << "Error: command " << cmd << " not recognized at ";
          errLine(str.tellg());
        }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x21e4a(%rip), %rsi     # 0x2b40c
leaq 0x21e4a(%rip), %rdx     # 0x2b413
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcb6
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x8cda
movl %eax, %ebx
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x9600
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4310
testb %bl, %bl
je 0x9828
movl $0x68, %edi
callq 0x4300
movq %rax, %rbx
movq %rax, %rdi
callq 0x5c1c
leaq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0xb11e
movq %rbx, (%rax)
movq %rbx, %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x41b0
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x7790
movl $0x30, %edi
callq 0x4300
movq %rax, %r12
leaq 0x48(%rsp), %rsi
movq %rax, %rdi
callq 0xb34c
movq %r12, 0x58(%rbx)
leaq 0x38(%rsp), %rbp
leaq 0x48(%r15), %rax
movq %rax, (%rsp)
leaq 0x28(%rsp), %r13
movq %r15, %rdi
movq %r14, %rsi
callq 0x7aaa
testl %eax, %eax
jne 0x982f
movq %rbp, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x7872
testb %al, %al
je 0x9808
movq %r13, %rdi
leaq 0x21d53(%rip), %rsi     # 0x2b414
callq 0x4110
testl %eax, %eax
je 0x9722
movq 0x90(%r15), %r12
movl $0xf, %edx
movq %r12, %rdi
leaq 0x21c82(%rip), %rsi     # 0x2b362
callq 0x4360
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r12, %rdi
callq 0x4360
movl $0x13, %edx
movq %rax, %rdi
leaq 0x21c6c(%rip), %rsi     # 0x2b372
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %r15, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x9800
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x75a0
cmpq $0x0, 0x10(%rsp)
je 0x9765
movq (%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xb19a
cmpq $0x0, (%rax)
je 0x9791
movq (%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xb19a
movq (%rax), %rax
movq %rax, 0x60(%rbx)
jmp 0x97e4
movq 0x90(%r15), %rdi
movl $0x2b, %edx
leaq 0x21ca5(%rip), %rsi     # 0x2b41d
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %r15, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x97e4
movq 0x90(%r15), %r12
movl $0x11, %edx
movq %r12, %rdi
leaq 0x21ca2(%rip), %rsi     # 0x2b449
callq 0x4360
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r12, %rdi
callq 0x4360
movl $0xf, %edx
movq %rax, %rdi
leaq 0x21c8e(%rip), %rsi     # 0x2b45b
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %r15, %rdi
movl %eax, %esi
callq 0x8180
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9800
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4310
movq %r14, %rsi
callq 0x7c34
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x967b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x967b
xorl %ebp, %ebp
jmp 0x98b4
cmpl $0x1, %eax
jne 0x9868
movb $0x1, %bpl
cmpq $0x0, 0x60(%rbx)
jne 0x9899
movl $0x40, %edi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rax, 0x60(%rbx)
movq %rax, %rsi
callq 0x8de6
jmp 0x9899
cmpq $0x0, 0x60(%rbx)
jne 0x9897
movl $0x40, %edi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rax, 0x60(%rbx)
movq %rax, %rsi
callq 0x8de6
xorl %ebp, %ebp
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x98b4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4310
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9923
movq %rax, %r14
movl $0x30, %esi
movq %r12, %rdi
jmp 0x993d
jmp 0x9923
movq %rax, %r14
movl $0x68, %esi
movq %rbx, %rdi
jmp 0x9958
jmp 0x9900
movq %rax, %r14
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x995d
movq 0x78(%rsp), %rsi
jmp 0x9955
jmp 0x9900
jmp 0x9928
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x992b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x992b
jmp 0x9928
movq %rax, %r14
jmp 0x9942
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9942
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4310
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x995d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4310
movq %r14, %rdi
callq 0x45b0
nop