// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x18bae(%rip), %rsi     # 0x2143b
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x9c50
leaq 0x68(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rcx
callq 0x7ef8
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x4170
testb %bpl, %bpl
je 0x8b0f
pushq $0x68
popq %rdi
callq 0x4320
movq %rax, %r15
movq %rax, %rdi
callq 0x56d4
leaq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x9a8c
movq %r15, (%rax)
movq %r15, %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x41c0
pushq $0x10
popq %rdi
callq 0x4320
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x40(%r15)
leaq 0x40(%rsp), %rbp
leaq 0x48(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0x71d2
testl %eax, %eax
jne 0x8b13
movq %rbp, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x7050
testb %al, %al
je 0x8afa
movq %r13, %rdi
leaq 0x18ad2(%rip), %rsi     # 0x21442
callq 0x4d52
testb %al, %al
je 0x89ae
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x7388
testl %eax, %eax
jle 0x8a59
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0x76d4
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x40(%r15), %rcx
movq %rax, (%rcx)
jmp 0x8af2
movq %r13, %rdi
leaq 0x18a2c(%rip), %rsi     # 0x213e4
callq 0x4d52
testb %al, %al
je 0x8a15
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6e00
cmpq $0x0, 0x18(%rsp)
je 0x8a80
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9b84
cmpq $0x0, (%rax)
je 0x8aa7
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9b84
movq (%rax), %rax
movq 0x40(%r15), %rcx
movq %rax, 0x8(%rcx)
jmp 0x8ae8
movq 0x90(%r14), %rdi
leaq 0x1890f(%rip), %rsi     # 0x21332
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x18905(%rip), %rsi     # 0x21342
callq 0x4300
movq %rbx, %rdi
callq 0x45a0
movq %r14, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x8af2
movq 0x90(%r14), %rdi
leaq 0x189e2(%rip), %rsi     # 0x21449
callq 0x4300
movq %rbx, %rdi
callq 0x45a0
movq %r14, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x8af2
movq 0x90(%r14), %rdi
leaq 0x1895f(%rip), %rsi     # 0x213ed
callq 0x4300
movq %rbx, %rdi
callq 0x45a0
movq %r14, %rdi
movl %eax, %esi
callq 0x76b4
jmp 0x8ae8
movq 0x90(%r14), %rdi
leaq 0x18964(%rip), %rsi     # 0x21419
callq 0x4300
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
leaq 0x1895a(%rip), %rsi     # 0x2142b
callq 0x4300
movq %rbx, %rdi
callq 0x45a0
movq %r14, %rdi
movl %eax, %esi
callq 0x76b4
leaq 0x10(%rsp), %rdi
callq 0x4170
movq %rbx, %rsi
callq 0x72de
movq %r12, %rdi
callq 0xa7f0
movq %r13, %rdi
callq 0x4170
jmp 0x891f
xorl %ebx, %ebx
jmp 0x8b26
cmpl $0x1, %eax
jne 0x8b1c
movb $0x1, %bl
jmp 0x8b1e
xorl %ebx, %ebx
movq %r15, %rsi
callq 0x84fa
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8b63
movq %rax, %rbx
pushq $0x68
popq %rsi
movq %r15, %rdi
callq 0x4330
jmp 0x8b89
jmp 0x8b63
jmp 0x8b72
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x8b84
movq %rax, %rbx
jmp 0x8b89
jmp 0x8b72
jmp 0x8b72
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4170
jmp 0x8b75
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xa7f0
leaq 0x30(%rsp), %rdi
callq 0x4170
movq %rbx, %rdi
callq 0x45c0
nop