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

  SceneGroup * n = new SceneGroup();
  groups[name] = n;
  n->name_ = name;
  n->sphere_ = new ParametricSphere();

  do
  {
    int state = findOpenOrClosedParen(str);

    if (state == ERROR)
    {
      setSphereDefaults(n);
      return false;
    }
    else if (state == CLOSED)
    {
      setSphereDefaults(n);
      return true;
    }
    else if (state == OPEN)
    {
      string cmd;
      vector<ParametricValue *> values;

      if (readCommand(str, cmd))
      {
        if (cmd == "radius")
        {
          if (getValues(str, values) < 1)
          {
            *err << "Type with no parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 1);
            n->sphere_->radius_ = values[0];
          }
        }
        else 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->sphere_->material_ = materials[matName];
          }
        }
        else
        {
          *err << "Error: command " << cmd << " not recognized at ";
          errLine(str.tellg());
        }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x5730
movq -0x108(%rbp), %rdx
leaq 0x370e0(%rip), %rsi     # 0x474cb
leaq -0x40(%rbp), %rdi
callq 0x13590
jmp 0x103f6
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdx
callq 0xec60
movb %al, -0x119(%rbp)
jmp 0x10419
movb -0x119(%rbp), %al
xorb $-0x1, %al
movb %al, -0x11a(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5290
leaq -0x41(%rbp), %rdi
callq 0x5460
movb -0x11a(%rbp), %al
testb $0x1, %al
jne 0x10445
jmp 0x1047f
movb $0x0, -0x1(%rbp)
jmp 0x10a5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10471
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 0x10a69
movl $0x68, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x128(%rbp)
callq 0x86a0
jmp 0x1049d
movq -0x118(%rbp), %rdi
movq -0x128(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x138(%rbp)
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
callq 0x12fe0
movq -0x138(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rsi
movq -0x60(%rbp), %rdi
addq $0x8, %rdi
callq 0x5070
movl $0x10, %edi
callq 0x5400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x130(%rbp)
callq 0x138d0
jmp 0x10500
movq -0x130(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x118(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd050
movl %eax, -0x64(%rbp)
cmpl $0x2, -0x64(%rbp)
jne 0x10585
movq -0x118(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0xfbc0
movb $0x0, -0x1(%rbp)
jmp 0x10a5b
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x68, %esi
callq 0x5410
jmp 0x10a69
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x10, %esi
callq 0x5410
jmp 0x10a69
cmpl $0x1, -0x64(%rbp)
jne 0x105a4
movq -0x118(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0xfbc0
movb $0x1, -0x1(%rbp)
jmp 0x10a5b
cmpl $0x0, -0x64(%rbp)
jne 0x10a47
leaq -0x88(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x55a0
leaq -0xa0(%rbp), %rdi
callq 0x13130
movq -0x118(%rbp), %rdi
movq -0x148(%rbp), %rdx
movq -0x18(%rbp), %rsi
callq 0xcdc0
movb %al, -0x139(%rbp)
jmp 0x105ec
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x105fb
jmp 0x10a13
leaq 0x36ed0(%rip), %rsi     # 0x474d2
leaq -0x88(%rbp), %rdi
callq 0x64f0
movb %al, -0x149(%rbp)
jmp 0x10616
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x10625
jmp 0x1071e
movq -0x118(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0xd330
movl %eax, -0x150(%rbp)
jmp 0x10644
movl -0x150(%rbp), %eax
cmpl $0x1, %eax
jge 0x106e3
movq -0x118(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x36e71(%rip), %rsi     # 0x474d9
callq 0x53e0
jmp 0x1066f
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x160(%rbp)
movq %rax, -0x158(%rbp)
jmp 0x10688
movq -0x160(%rbp), %rax
movq -0x158(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x168(%rbp)
jmp 0x106b9
movq -0x118(%rbp), %rdi
movq -0x168(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x106d0
jmp 0x10719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10a2d
movq -0x118(%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 0x40(%rax), %rax
movq %rcx, (%rax)
jmp 0x109ff
leaq 0x36d4f(%rip), %rsi     # 0x47474
leaq -0x88(%rbp), %rdi
callq 0x64f0
movb %al, -0x169(%rbp)
jmp 0x10739
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x10748
jmp 0x10946
movq -0x118(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0xcaa0
jmp 0x10761
leaq -0xd0(%rbp), %rdi
callq 0x5690
testb $0x1, %al
jne 0x10776
jmp 0x10815
movq -0x118(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x36cf2(%rip), %rsi     # 0x4747d
callq 0x53e0
jmp 0x10792
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x180(%rbp)
movq %rax, -0x178(%rbp)
jmp 0x107ab
movq -0x180(%rbp), %rax
movq -0x178(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x188(%rbp)
jmp 0x107dc
movq -0x118(%rbp), %rdi
movq -0x188(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x107f3
jmp 0x10935
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5290
jmp 0x10a2d
movq -0x118(%rbp), %rdi
addq $0x48, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x133b0
movq %rax, -0x190(%rbp)
jmp 0x10835
movq -0x190(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x108fd
movq -0x118(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x36c4e(%rip), %rsi     # 0x474a9
callq 0x53e0
movq %rax, -0x198(%rbp)
jmp 0x10869
movq -0x198(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x53c0
movq %rax, -0x1a0(%rbp)
jmp 0x10885
movq -0x1a0(%rbp), %rdi
leaq 0x36c28(%rip), %rsi     # 0x474bb
callq 0x53e0
jmp 0x1089a
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x1b0(%rbp)
movq %rax, -0x1a8(%rbp)
jmp 0x108b3
movq -0x1b0(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x1b8(%rbp)
jmp 0x108e4
movq -0x118(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x108fb
jmp 0x10933
movq -0x118(%rbp), %rdi
addq $0x48, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x133b0
movq %rax, -0x1c0(%rbp)
jmp 0x1091d
movq -0x1c0(%rbp), %rax
movq (%rax), %rcx
movq -0x60(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x10935
leaq -0xd0(%rbp), %rdi
callq 0x5290
jmp 0x109fd
movq -0x118(%rbp), %rax
movq 0x90(%rax), %rdi
leaq 0x36a67(%rip), %rsi     # 0x473c2
callq 0x53e0
movq %rax, -0x1c8(%rbp)
jmp 0x10969
movq -0x1c8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x53c0
movq %rax, -0x1d0(%rbp)
jmp 0x10985
movq -0x1d0(%rbp), %rdi
leaq 0x36a3f(%rip), %rsi     # 0x473d2
callq 0x53e0
jmp 0x1099a
movq -0x18(%rbp), %rdi
callq 0x5700
movq %rdx, -0x1e0(%rbp)
movq %rax, -0x1d8(%rbp)
jmp 0x109b3
movq -0x1e0(%rbp), %rax
movq -0x1d8(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x12bc0
movq %rax, -0x1e8(%rbp)
jmp 0x109e4
movq -0x118(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movl %eax, %esi
callq 0xd8e0
jmp 0x109fb
jmp 0x109fd
jmp 0x109ff
movq -0x118(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd240
jmp 0x10a11
jmp 0x10a13
leaq -0xa0(%rbp), %rdi
callq 0x13350
leaq -0x88(%rbp), %rdi
callq 0x5290
jmp 0x10a47
leaq -0xa0(%rbp), %rdi
callq 0x13350
leaq -0x88(%rbp), %rdi
callq 0x5290
jmp 0x10a69
jmp 0x10a49
jmp 0x10a4b
jmp 0x10a4d
movb $0x1, %al
testb $0x1, %al
jne 0x1050f
jmp 0x10a59
ud2
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5720
nopw %cs:(%rax,%rax)