// File: /workspace/github_cpp_makefile_star2_O2/srajangarg[P]raytracer/src/core/SceneLoader.cpp
// Function: SceneLoader::buildScene(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool SceneLoader::buildScene(string filename)
{
  buildEndlineTable(filename);
  ifstream file(filename.c_str());
  string line;

  while (findOpenParen(file))
  {
    file.tellg();

    if (readCommand(file, line))
    {
      if (line == "Include")
      {
        string instName;

        if (doInclude(file, instName))
        {
          cout << "included " << instName << endl;
        }
        else
        {
          cout << "mangled include at ";
          curPos(cout, file.tellg());
          cout << endl;
        }
      }
      else if (line == "Sphere")
      {
        string gname;

        if (doSphere(file, gname))
        {
          cout << "read sphere " << gname << endl;
        }
        else
        {
          *err << "mangled sphere command at ";
          errLine(file.tellg());
        }
      }
      else if (line == "Material")
      {
        string gname;

        if (doMaterial(file, gname))
        {
          cout << "read material " << gname << endl;
        }
        else
        {
          *err << "mangled material command at ";
          errLine(file.tellg());
        }
      }
      else if (line == "Light")
      {
        string gname;

        if (doLight(file, gname))
        {
          cout << "read light " << gname << endl;
        }
        else
        {
          *err << "mangled light command at ";
          errLine(file.tellg());
        }
      }
      else if (line == "Camera")
      {
        string gname;

        if (doCamera(file, gname))
        {
          cout << "read camera " << gname << endl;
        }
        else
        {
          *err << "mangled camera command at ";
          errLine(file.tellg());
        }
      }
      else if (line == "I")
      {
        *err << "Error: Instance commands must belong to a group, but I found in global scope at ";
        errLine(file.tellg());
        /*string iname; // code to handle I at global scope (doesn't make much sense now that instance names skip the names table)
        if (doI(file, iname))
        {
            cout << "got an instance named " << iname << endl;
        }*/
      }
      else if (line == "G")
      {
        string iname;

        if (doG(file, iname))
        {
          cout << "got a group named " << iname << endl;
        }
      }
      else if (line == "Render")
      {
        string iname;

        if (doRender(file, iname))
        {
          cout << "did render " << iname << endl;
        }
      }
      else
      {
        *err << "command not recognized: " << line << endl;
      }

      findCloseParen(file);
    }
    else
    {
    }
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x4450
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6c96
leaq 0x40(%rsp), %rdi
callq 0x4170
movq (%r14), %rsi
leaq 0x60(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x45f0
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x20(%rsp), %r15
leaq 0x1af27(%rip), %r12     # 0x21646
movq %rsp, %r13
movq 0x288a7(%rip), %rbp     # 0x2efd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x70e0
testb %al, %al
je 0x6b54
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x7050
testb %al, %al
je 0x6729
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d52
testb %al, %al
je 0x67ae
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x8564
testb %al, %al
je 0x687a
movq %rbp, %rdi
leaq 0x1aeb5(%rip), %rsi     # 0x2164e
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
jmp 0x68a1
movq %r15, %rdi
leaq 0x1aeb4(%rip), %rsi     # 0x2166c
callq 0x4d52
testb %al, %al
je 0x6812
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x886c
testb %al, %al
je 0x6912
movq %rbp, %rdi
leaq 0x1ae7e(%rip), %rsi     # 0x21673
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq %r15, %rdi
leaq 0x1ae7f(%rip), %rsi     # 0x2169b
callq 0x4d52
testb %al, %al
je 0x68ae
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x8066
testb %al, %al
je 0x69a0
movq %rbp, %rdi
leaq 0x1ae47(%rip), %rsi     # 0x216a4
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq %rbp, %rdi
leaq 0x1add4(%rip), %rsi     # 0x21658
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x6d66
movq %rbp, %rax
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq %r15, %rdi
leaq 0x1ae18(%rip), %rsi     # 0x216d0
callq 0x4d52
testb %al, %al
je 0x693c
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x8ce0
testb %al, %al
je 0x6a07
movq %rbp, %rdi
leaq 0x1ade1(%rip), %rsi     # 0x216d6
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq 0x90(%rbx), %rdi
leaq 0x1ad60(%rip), %rsi     # 0x21680
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x6ab7
movq %r15, %rdi
leaq 0x1adb6(%rip), %rsi     # 0x216fc
callq 0x4d52
testb %al, %al
je 0x69ca
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x92c2
testb %al, %al
je 0x6a92
movq %rbp, %rdi
leaq 0x1ad80(%rip), %rsi     # 0x21703
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq 0x90(%rbx), %rdi
leaq 0x1ad05(%rip), %rsi     # 0x216b3
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x6ab7
movq %r15, %rdi
leaq 0x1b723(%rip), %rsi     # 0x220f7
callq 0x4d52
testb %al, %al
je 0x6a31
movq 0x90(%rbx), %rdi
leaq 0x1ad40(%rip), %rsi     # 0x2172b
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x6abf
movq 0x90(%rbx), %rdi
leaq 0x1accd(%rip), %rsi     # 0x216e2
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x6ab7
movq %r15, %rdi
leaq 0x1b092(%rip), %rsi     # 0x21acd
callq 0x4d52
testb %al, %al
je 0x6acc
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x95bc
testb %al, %al
je 0x6ab7
movq %rbp, %rdi
leaq 0x1ad04(%rip), %rsi     # 0x2177c
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq 0x90(%rbx), %rdi
leaq 0x1ac70(%rip), %rsi     # 0x21710
callq 0x4300
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
movl %eax, %esi
callq 0x76b4
movq %r13, %rdi
callq 0x4170
movq %r14, %rsi
callq 0x72de
jmp 0x6729
movq %r15, %rdi
leaq 0x1acb9(%rip), %rsi     # 0x2178f
callq 0x4d52
testb %al, %al
je 0x6b29
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x9820
testb %al, %al
je 0x6ab7
movq %rbp, %rdi
leaq 0x1ac87(%rip), %rsi     # 0x21796
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6ab7
movq 0x90(%rbx), %rdi
leaq 0x1ac6b(%rip), %rsi     # 0x217a2
callq 0x4300
movq %rax, %rdi
movq %r15, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x6abf
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x60(%rsp), %rdi
callq 0x40e0
movb $0x1, %al
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6bb0
jmp 0x6ba3
jmp 0x6ba3
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4170
jmp 0x6bc7
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6ba3
jmp 0x6ba3
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4170
jmp 0x6bb3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x60(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45c0
nop