// File: 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
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x5730
movq -0x100(%rbp), %rdx
leaq 0x37761(%rip), %rsi     # 0x4746c
leaq -0x40(%rbp), %rdi
callq 0x13590
jmp 0xfd16
movq -0x108(%rbp), %rsi
movq -0x110(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdx
callq 0xec60
movb %al, -0x111(%rbp)
jmp 0xfd39
movb -0x111(%rbp), %al
xorb $-0x1, %al
movb %al, -0x112(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5290
leaq -0x41(%rbp), %rdi
callq 0x5460
movb -0x112(%rbp), %al
testb $0x1, %al
jne 0xfd65
jmp 0xfd9f
movb $0x0, -0x1(%rbp)
jmp 0x10385
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xfd91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5290
leaq -0x41(%rbp), %rdi
callq 0x5460
jmp 0x10393
movl $0x68, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x120(%rbp)
callq 0x86a0
jmp 0xfdbd
movq -0x110(%rbp), %rdi
movq -0x120(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
callq 0x12fe0
movq -0x130(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rsi
movq -0x60(%rbp), %rdi
addq $0x8, %rdi
callq 0x5070
movq -0x110(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0xcc90
movl $0x30, %edi
callq 0x5400
movq %rax, -0x128(%rbp)
jmp 0xfe29
movq -0x128(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13820
jmp 0xfe3b
movq -0x128(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd050
movl %eax, -0x134(%rbp)
jmp 0xfe62
movl -0x134(%rbp), %eax
movl %eax, -0x84(%rbp)
cmpl $0x2, -0x84(%rbp)
jne 0xff5c
movq -0x60(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0xff49
movl $0x40, %edi
callq 0x5400
movq %rax, -0x140(%rbp)
jmp 0xfe9d
movq -0x140(%rbp), %rdi
callq 0x13640
jmp 0xfeab
movq -0x110(%rbp), %rdi
movq -0x140(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x60(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0xeda0
jmp 0xfed0
jmp 0xff49
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x68, %esi
callq 0x5410
jmp 0x10393
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1037a
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x30, %esi
callq 0x5410
jmp 0x1037a
movq -0x140(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x40, %esi
callq 0x5410
jmp 0x1037a
movb $0x0, -0x1(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x1036f
cmpl $0x1, -0x84(%rbp)
jne 0xfff1
movq -0x60(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0xffde
movl $0x40, %edi
callq 0x5400
movq %rax, -0x148(%rbp)
jmp 0xff87
movq -0x148(%rbp), %rdi
callq 0x13640
jmp 0xff95
movq -0x110(%rbp), %rdi
movq -0x148(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x60(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0xeda0
jmp 0xffba
jmp 0xffde
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x40, %esi
callq 0x5410
jmp 0x1037a
movb $0x1, -0x1(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0x1036f
cmpl $0x0, -0x84(%rbp)
jne 0x1035b
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x55a0
movq -0x110(%rbp), %rdi
movq -0x158(%rbp), %rdx
movq -0x18(%rbp), %rsi
callq 0xcdc0
movb %al, -0x149(%rbp)
jmp 0x10030
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x1003f
jmp 0x1033f
leaq 0x3742e(%rip), %rsi     # 0x47474
leaq -0xa8(%rbp), %rdi
callq 0x64f0
movb %al, -0x159(%rbp)
jmp 0x1005a
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x10069
jmp 0x10274
movq -0x110(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xc8(%rbp), %rdi
callq 0xcaa0
jmp 0x10082
leaq -0xc8(%rbp), %rdi
callq 0x5690
testb $0x1, %al
jne 0x10097
jmp 0x10147
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x373d1(%rip), %rsi     # 0x4747d
callq 0x53e0
jmp 0x100b3
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x170(%rbp)
movq %rax, -0x168(%rbp)
jmp 0x100cc
movq -0x170(%rbp), %rax
movq -0x168(%rbp), %rcx
movq %rcx, -0xd8(%rbp)
movq %rax, -0xd0(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x178(%rbp)
jmp 0x100fd
movq -0x110(%rbp), %rdi
movq -0x178(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x10114
jmp 0x10263
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1034d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5290
jmp 0x1034d
movq -0x110(%rbp), %rdi
addq $0x48, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x133b0
movq %rax, -0x180(%rbp)
jmp 0x10167
movq -0x180(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1022f
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x3731c(%rip), %rsi     # 0x474a9
callq 0x53e0
movq %rax, -0x188(%rbp)
jmp 0x1019b
movq -0x188(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x53c0
movq %rax, -0x190(%rbp)
jmp 0x101b7
movq -0x190(%rbp), %rdi
leaq 0x372f6(%rip), %rsi     # 0x474bb
callq 0x53e0
jmp 0x101cc
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x1a0(%rbp)
movq %rax, -0x198(%rbp)
jmp 0x101e5
movq -0x1a0(%rbp), %rax
movq -0x198(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x1a8(%rbp)
jmp 0x10216
movq -0x110(%rbp), %rdi
movq -0x1a8(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x1022d
jmp 0x10261
movq -0x110(%rbp), %rdi
addq $0x48, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x133b0
movq %rax, -0x1b0(%rbp)
jmp 0x1024f
movq -0x1b0(%rbp), %rax
movq (%rax), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x60(%rax)
jmp 0x10263
leaq -0xc8(%rbp), %rdi
callq 0x5290
jmp 0x1032b
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x37139(%rip), %rsi     # 0x473c2
callq 0x53e0
movq %rax, -0x1b8(%rbp)
jmp 0x10297
movq -0x1b8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x53c0
movq %rax, -0x1c0(%rbp)
jmp 0x102b3
movq -0x1c0(%rbp), %rdi
leaq 0x37111(%rip), %rsi     # 0x473d2
callq 0x53e0
jmp 0x102c8
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x1d0(%rbp)
movq %rax, -0x1c8(%rbp)
jmp 0x102e1
movq -0x1d0(%rbp), %rax
movq -0x1c8(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x1d8(%rbp)
jmp 0x10312
movq -0x110(%rbp), %rdi
movq -0x1d8(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x10329
jmp 0x1032b
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd240
jmp 0x1033d
jmp 0x1033f
leaq -0xa8(%rbp), %rdi
callq 0x5290
jmp 0x1035b
leaq -0xa8(%rbp), %rdi
callq 0x5290
jmp 0x1037a
jmp 0x1035d
jmp 0x1035f
jmp 0x10361
movb $0x1, %al
testb $0x1, %al
jne 0xfe4a
jmp 0x1036d
ud2
leaq -0x80(%rbp), %rdi
callq 0x5290
jmp 0x10385
leaq -0x80(%rbp), %rdi
callq 0x5290
jmp 0x10393
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5720
nopl (%rax)