// File: /workspace/github_cpp_makefile_star2_O3/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 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rsi), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x4fec
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7382
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x6ba2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4310
movq (%r14), %rsi
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x45e0
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x10(%rsp), %r12
leaq 0x20(%rsp), %r15
movq 0x303f4(%rip), %r13     # 0x36fd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x793c
testb %al, %al
je 0x71c9
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x7872
testb %al, %al
je 0x6bdc
movq %r15, %rdi
leaq 0x24a63(%rip), %rsi     # 0x2b676
callq 0x4110
testl %eax, %eax
je 0x6d1d
movq %r15, %rdi
leaq 0x24a72(%rip), %rsi     # 0x2b69c
callq 0x4110
testl %eax, %eax
je 0x6d86
movq %r15, %rdi
leaq 0x24a8a(%rip), %rsi     # 0x2b6cb
callq 0x4110
testl %eax, %eax
je 0x6e5b
movq %r15, %rdi
leaq 0x24aa8(%rip), %rsi     # 0x2b700
callq 0x4110
testl %eax, %eax
je 0x6f06
movq %r15, %rdi
leaq 0x24abd(%rip), %rsi     # 0x2b72c
callq 0x4110
testl %eax, %eax
je 0x6fb1
movq %r15, %rdi
leaq 0x25571(%rip), %rsi     # 0x2c1f7
callq 0x4110
testl %eax, %eax
je 0x705c
movq %r15, %rdi
leaq 0x24dd0(%rip), %rsi     # 0x2ba6d
callq 0x4110
testl %eax, %eax
je 0x70ba
movq %r15, %rdi
leaq 0x24b0b(%rip), %rsi     # 0x2b7bf
callq 0x4110
testl %eax, %eax
je 0x7133
movq 0x90(%rbx), %rbp
movl $0x18, %edx
movq %rbp, %rdi
leaq 0x24afb(%rip), %rsi     # 0x2b7d2
callq 0x4360
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbp, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71bc
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0x9598
testb %al, %al
je 0x6e02
movl $0x9, %edx
movq %r13, %rdi
leaq 0x2492a(%rip), %rsi     # 0x2b67e
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
jmp 0x6e43
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0x9966
testb %al, %al
je 0x6ed7
movl $0xc, %edx
movq %r13, %rdi
leaq 0x248e6(%rip), %rsi     # 0x2b6a3
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movl $0x13, %edx
movq %r13, %rdi
leaq 0x24877(%rip), %rsi     # 0x2b688
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movq %r13, %rsi
movl %eax, %edx
callq 0x74be
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x42e0
movq %r13, %rbp
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0x8e9c
testb %al, %al
je 0x6f82
movl $0xe, %edx
movq %r13, %rdi
leaq 0x24842(%rip), %rsi     # 0x2b6d4
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movq 0x90(%rbx), %rdi
movl $0x1a, %edx
leaq 0x247c6(%rip), %rsi     # 0x2b6b0
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x71a6
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0x9ee0
testb %al, %al
je 0x702d
movl $0xb, %edx
movq %r13, %rdi
leaq 0x247c9(%rip), %rsi     # 0x2b706
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movq 0x90(%rbx), %rdi
movl $0x1c, %edx
leaq 0x2474e(%rip), %rsi     # 0x2b6e3
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x71a6
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0xa70e
testb %al, %al
je 0x708b
movl $0xc, %edx
movq %r13, %rdi
leaq 0x2474b(%rip), %rsi     # 0x2b733
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movq 0x90(%rbx), %rdi
movl $0x19, %edx
leaq 0x246d2(%rip), %rsi     # 0x2b712
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x71a6
movq 0x90(%rbx), %rdi
movl $0x50, %edx
leaq 0x246ec(%rip), %rsi     # 0x2b75b
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x71bc
movq 0x90(%rbx), %rdi
movl $0x1a, %edx
leaq 0x246a2(%rip), %rsi     # 0x2b740
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x71a6
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0xab3e
testb %al, %al
je 0x71a6
movl $0x12, %edx
movq %r13, %rdi
leaq 0x246bb(%rip), %rsi     # 0x2b7ac
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x71a6
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rsp, %rdx
callq 0xae6c
testb %al, %al
je 0x71a6
movl $0xb, %edx
movq %r13, %rdi
leaq 0x24660(%rip), %rsi     # 0x2b7c6
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4360
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x71bc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %r14, %rsi
callq 0x7c34
jmp 0x6bdc
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x71e5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4310
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 0x7237
jmp 0x7237
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x727b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x727b
jmp 0x7252
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
jmp 0x7237
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x7255
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x7255
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x7271
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4310
leaq 0x60(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45b0
nop