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

  SceneGroup * n = new SceneGroup();
  groups[name] = n;
  n->name_ = name;
  n->camera_ = new ParametricCamera();

  do
  {
    int state = findOpenOrClosedParen(str);

    if (state == ERROR)
    {
      setCameraDefaults(n);
      return false;
    }
    else if (state == CLOSED)
    {
      setCameraDefaults(n);
      return true;
    }
    else if (state == OPEN)
    {
      string cmd;
      vector<ParametricValue *> values;
      string sides = "lrbtnf";
      int side = 0;

      if (readCommand(str, cmd))
      {
        if (cmd == "perspective")
        {
          if (getValues(str, values) < 1)
          {
            *err << "Perspective with no parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 1);
            n->camera_->perspective_ = values[0];
          }
        }
        else if (cmd.size() == 1 && (side = (int)sides.find(cmd)) != string::npos)
        {
          if (getValues(str, values) < 1)
          {
            *err << "l with no parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 1);
            n->camera_->frustum_[side] = values[0];
          }
        }
        else
        {
          *err << "Error: command " << cmd << " not recognized at ";
          errLine(str.tellg());
        }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
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 0x35a31(%rip), %rsi     # 0x475cc
leaq -0x40(%rbp), %rdi
callq 0x13590
jmp 0x11ba6
movq -0x108(%rbp), %rsi
movq -0x110(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdx
callq 0xec60
movb %al, -0x111(%rbp)
jmp 0x11bc9
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 0x11bf5
jmp 0x11c2f
movb $0x0, -0x1(%rbp)
jmp 0x12182
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x11c21
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 0x12190
movl $0x68, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x120(%rbp)
callq 0x86a0
jmp 0x11c4d
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
movl $0x38, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x128(%rbp)
callq 0x13930
jmp 0x11cb0
movq -0x128(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd050
movl %eax, -0x64(%rbp)
cmpl $0x2, -0x64(%rbp)
jne 0x11d35
movq -0x110(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x11880
movb $0x0, -0x1(%rbp)
jmp 0x12182
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x68, %esi
callq 0x5410
jmp 0x12190
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x38, %esi
callq 0x5410
jmp 0x12190
cmpl $0x1, -0x64(%rbp)
jne 0x11d54
movq -0x110(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x11880
movb $0x1, -0x1(%rbp)
jmp 0x12182
cmpl $0x0, -0x64(%rbp)
jne 0x1216e
leaq -0x88(%rbp), %rdi
callq 0x55a0
leaq -0xa0(%rbp), %rdi
callq 0x13130
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x5730
movq -0x138(%rbp), %rdx
leaq 0x3583c(%rip), %rsi     # 0x475d3
leaq -0xc0(%rbp), %rdi
callq 0x13590
jmp 0x11da5
leaq -0xc1(%rbp), %rdi
callq 0x5460
movq -0x110(%rbp), %rdi
movl $0x0, -0xc8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0xcdc0
movb %al, -0x139(%rbp)
jmp 0x11dda
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x11de9
jmp 0x1212e
leaq 0x357ea(%rip), %rsi     # 0x475da
leaq -0x88(%rbp), %rdi
callq 0x64f0
movb %al, -0x13a(%rbp)
jmp 0x11e04
movb -0x13a(%rbp), %al
testb $0x1, %al
jne 0x11e13
jmp 0x11f35
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0xd330
movl %eax, -0x140(%rbp)
jmp 0x11e32
movl -0x140(%rbp), %eax
cmpl $0x1, %eax
jge 0x11efa
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x35790(%rip), %rsi     # 0x475e6
callq 0x53e0
jmp 0x11e5d
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x150(%rbp)
movq %rax, -0x148(%rbp)
jmp 0x11e76
movq -0x150(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, -0xd8(%rbp)
movq %rax, -0xd0(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x158(%rbp)
jmp 0x11ea7
movq -0x110(%rbp), %rdi
movq -0x158(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x11ebe
jmp 0x11f30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x5460
jmp 0x12154
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x5290
jmp 0x12154
movq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x1, %edx
callq 0xd930
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12fc0
movq (%rax), %rcx
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, (%rax)
jmp 0x1211a
leaq -0x88(%rbp), %rdi
callq 0x52f0
cmpq $0x1, %rax
jne 0x12061
leaq -0xc0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x57e0
movl %eax, -0xc8(%rbp)
cltq
cmpq $-0x1, %rax
je 0x12061
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0xd330
movl %eax, -0x15c(%rbp)
jmp 0x11f93
movl -0x15c(%rbp), %eax
cmpl $0x1, %eax
jge 0x1201d
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x35656(%rip), %rsi     # 0x47609
callq 0x53e0
jmp 0x11fba
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x170(%rbp)
movq %rax, -0x168(%rbp)
jmp 0x11fd3
movq -0x170(%rbp), %rax
movq -0x168(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x178(%rbp)
jmp 0x12004
movq -0x110(%rbp), %rdi
movq -0x178(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x1201b
jmp 0x1205c
movq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x1, %edx
callq 0xd930
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12fc0
movq (%rax), %rdx
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0xc8(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
jmp 0x12118
movq -0x110(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x3534c(%rip), %rsi     # 0x473c2
callq 0x53e0
movq %rax, -0x180(%rbp)
jmp 0x12084
movq -0x180(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x53c0
movq %rax, -0x188(%rbp)
jmp 0x120a0
movq -0x188(%rbp), %rdi
leaq 0x35324(%rip), %rsi     # 0x473d2
callq 0x53e0
jmp 0x120b5
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x198(%rbp)
movq %rax, -0x190(%rbp)
jmp 0x120ce
movq -0x198(%rbp), %rax
movq -0x190(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movq %rax, -0xf0(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x1a0(%rbp)
jmp 0x120ff
movq -0x110(%rbp), %rdi
movq -0x1a0(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x12116
jmp 0x12118
jmp 0x1211a
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd240
jmp 0x1212c
jmp 0x1212e
leaq -0xc0(%rbp), %rdi
callq 0x5290
leaq -0xa0(%rbp), %rdi
callq 0x13350
leaq -0x88(%rbp), %rdi
callq 0x5290
jmp 0x1216e
leaq -0xa0(%rbp), %rdi
callq 0x13350
leaq -0x88(%rbp), %rdi
callq 0x5290
jmp 0x12190
jmp 0x12170
jmp 0x12172
jmp 0x12174
movb $0x1, %al
testb $0x1, %al
jne 0x11cbf
jmp 0x12180
ud2
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5720
nopl (%rax)