// File: /workspace/github_cpp_makefile_star2_O2/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 0x18e57(%rip), %rsi     # 0x213dc
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x9c50
leaq 0x48(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x7ef8
movl %eax, %ebx
leaq 0x48(%rsp), %rdi
callq 0x4170
testb %bl, %bl
je 0x8783
pushq $0x68
popq %rdi
callq 0x4320
movq %rax, %rbx
movq %rax, %rdi
callq 0x56d4
leaq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0x9a8c
movq %rbx, (%rax)
movq %rbx, %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x41c0
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6fae
pushq $0x30
popq %rdi
callq 0x4320
movq %rax, %r12
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0x9d0a
movq %r12, 0x58(%rbx)
leaq 0x18(%rsp), %r12
leaq 0x48(%r15), %rax
movq %rax, (%rsp)
leaq 0x8(%rsp), %r13
leaq 0x68(%rsp), %rbp
movq %r15, %rdi
movq %r14, %rsi
callq 0x71d2
testl %eax, %eax
jne 0x8787
movq %r12, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x7050
testb %al, %al
je 0x8776
movq %r13, %rdi
leaq 0x18d72(%rip), %rsi     # 0x213e4
callq 0x4d52
testb %al, %al
je 0x86bf
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6e00
cmpq $0x0, 0x70(%rsp)
je 0x8700
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0x9b84
cmpq $0x0, (%rax)
je 0x8727
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0x9b84
movq (%rax), %rax
movq %rax, 0x60(%rbx)
jmp 0x8766
movq 0x90(%r15), %rdi
leaq 0x18c65(%rip), %rsi     # 0x21332
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x18c5b(%rip), %rsi     # 0x21342
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %r15, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x876e
movq 0x90(%r15), %rdi
leaq 0x18cdf(%rip), %rsi     # 0x213ed
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %r15, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x8766
movq 0x90(%r15), %rdi
leaq 0x18ce4(%rip), %rsi     # 0x21419
callq 0x4300
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x18cdc(%rip), %rsi     # 0x2142b
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %r15, %rdi
movl %eax, %esi
callq 0x76b4
movq %rbp, %rdi
callq 0x4170
movq %r14, %rsi
callq 0x72de
movq %r13, %rdi
callq 0x4170
jmp 0x862f
xorl %ebp, %ebp
jmp 0x87e9
cmpl $0x1, %eax
jne 0x87b7
movb $0x1, %bpl
cmpq $0x0, 0x60(%rbx)
jne 0x87df
pushq $0x40
popq %rdi
callq 0x4320
movq %rax, %r14
movq %rax, %rdi
callq 0x9c8c
movq %r14, 0x60(%rbx)
movq %r14, %rsi
callq 0x7fb8
jmp 0x87df
cmpq $0x0, 0x60(%rbx)
jne 0x87dd
pushq $0x40
popq %rdi
callq 0x4320
movq %rax, %r14
movq %rax, %rdi
callq 0x9c8c
movq %r14, 0x60(%rbx)
movq %r14, %rsi
callq 0x7fb8
xorl %ebp, %ebp
leaq 0x28(%rsp), %rdi
callq 0x4170
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8847
movq %rax, %r14
pushq $0x30
popq %rsi
movq %r12, %rdi
callq 0x4330
jmp 0x8859
jmp 0x8847
movq %rax, %r14
pushq $0x68
popq %rsi
movq %rbx, %rdi
callq 0x4330
jmp 0x8863
jmp 0x8838
movq %rax, %r14
leaq 0x48(%rsp), %rdi
jmp 0x885e
movq %rax, %r14
jmp 0x8863
jmp 0x8838
jmp 0x884c
jmp 0x884c
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x4170
jmp 0x884f
movq %rax, %r14
jmp 0x8859
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x28(%rsp), %rdi
callq 0x4170
movq %r14, %rdi
callq 0x45c0
nop