// File: /workspace/github_cpp_makefile_star2_O3/srajangarg[P]raytracer/src/core/SceneLoader.cpp
// Function: SceneLoader::doMaterial(std::istream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool SceneLoader::doMaterial(istream & str, string & name)
{
  name = getString(str);

  if (name.empty())
  {
    *err << "Couldn't read material name at ";
    errLine(str.tellg());
    return false;
  }

  if (materials[name] != NULL)
  {
    *err << "Illegal re-use of name \"" << name << "\" at ";
    errLine(str.tellg());
    return false;
  }

  map<string, int> indices;
  indices["ma"] = MAT_MA;
  indices["ml"] = MAT_MD;
  indices["ms"] = MAT_MS;
  indices["msp"] = MAT_MSP;
  indices["msm"] = MAT_MSM;
  indices["mt"] = MAT_MT;
  indices["mtn"] = MAT_MTN;
  ParametricMaterial * n = new ParametricMaterial();
  materials[name] = n;

  do
  {
    int state = findOpenOrClosedParen(str);

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

      if (readCommand(str, cmd))
      {
        if (cmd == "color")
        {
          if (getValues(str, values) < 3)
          {
            *err << "Color with insufficent parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 3);
            n->RGB_ = new ParametricColor();

            for (int ci = 0; ci < 3; ci++)
              n->RGB_->color_[ci] = values[ci];
          }
        }
        else if (indices.find(cmd) != indices.end())
        {
          if (getValues(str, values) < 1)
          {
            *err << cmd << " with no parameters at ";
            errLine(str.tellg());
          }
          else
          {
            cleanAfter(values, 1);
            n->coefficients_[indices[cmd]] = values[0];
          }
        }
        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 $0x68, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x75a0
movq %r12, %rdi
movq %r15, %rsi
callq 0x4390
movq (%r15), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x8eeb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4310
cmpq $0x0, 0x8(%r12)
je 0x8f45
leaq 0x48(%rbx), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xb19a
cmpq $0x0, (%rax)
je 0x8f76
movq 0x90(%rbx), %r15
leaq 0x2247f(%rip), %rsi     # 0x2b395
movl $0x18, %edx
movq %r15, %rdi
callq 0x4360
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x4360
leaq 0x2225e(%rip), %rsi     # 0x2b199
movl $0x5, %edx
movq %rax, %rdi
jmp 0x8f58
movq 0x90(%rbx), %rdi
leaq 0x2245b(%rip), %rsi     # 0x2b3ae
movl $0x1f, %edx
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
xorl %ebx, %ebx
jmp 0x949d
leaq 0x40(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2242b(%rip), %rsi     # 0x2b3ce
leaq 0x22426(%rip), %rdx     # 0x2b3d0
movq %rsp, %rdi
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x0, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x8fe0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x223df(%rip), %rsi     # 0x2b3d1
leaq 0x223da(%rip), %rdx     # 0x2b3d3
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x1, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x902c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22396(%rip), %rsi     # 0x2b3d4
leaq 0x22391(%rip), %rdx     # 0x2b3d6
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x2, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9078
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x2234d(%rip), %rsi     # 0x2b3d7
leaq 0x22349(%rip), %rdx     # 0x2b3da
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x3, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x90c4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22305(%rip), %rsi     # 0x2b3db
leaq 0x22301(%rip), %rdx     # 0x2b3de
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x4, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9110
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x222bd(%rip), %rsi     # 0x2b3df
leaq 0x222b8(%rip), %rdx     # 0x2b3e1
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x5, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x915c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22274(%rip), %rsi     # 0x2b3e2
leaq 0x22270(%rip), %rdx     # 0x2b3e5
callq 0xbcb6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb216
movl $0x6, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x91a8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
movl $0x40, %edi
callq 0x4300
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rbp, %rdi
movq %r12, %rsi
callq 0xb19a
movq %r15, (%rax)
xorl %r13d, %r13d
movq %rsp, %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7aaa
testl %eax, %eax
jne 0x9478
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r13, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %r13, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x7872
testb %al, %al
je 0x943d
movq %r12, %rdi
leaq 0x220ed(%rip), %rsi     # 0x2b31b
callq 0x4110
testl %eax, %eax
je 0x92d7
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xcc44
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rax
je 0x931f
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x7d18
testl %eax, %eax
jle 0x93fa
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x9, %rdx
jb 0x92ba
movl $0x1, %edx
movl $0x2, %ebp
movq (%rax,%rdx,8), %rdi
testq %rdi, %rdi
je 0x92a7
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movl %ebp, %edx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
incl %ebp
cmpq %rdx, %rsi
ja 0x928e
movq (%rax), %rbp
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xb2d0
movslq (%rax), %rax
movq %rbp, 0x8(%r15,%rax,8)
jmp 0x9435
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x7d18
cmpl $0x2, %eax
jg 0x9376
movq 0x90(%rbx), %rdi
movl $0x25, %edx
leaq 0x220e3(%rip), %rsi     # 0x2b3e6
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x9435
movq 0x90(%rbx), %rbp
movl $0xf, %edx
movq %rbp, %rdi
leaq 0x2202d(%rip), %rsi     # 0x2b362
callq 0x4360
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x4360
movl $0x13, %edx
movq %rax, %rdi
leaq 0x22018(%rip), %rsi     # 0x2b372
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
jmp 0x9435
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x19, %rdx
jb 0x93c2
movl $0x3, %edx
movl $0x4, %ebp
movq (%rax,%rdx,8), %rdi
testq %rdi, %rdi
je 0x93af
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movl %ebp, %edx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
incl %ebp
cmpq %rdx, %rsi
ja 0x9396
movl $0x18, %edi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, (%r15)
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq (%r15), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x93df
jmp 0x9435
movq 0x90(%rbx), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x4360
movl $0x17, %edx
movq %rax, %rdi
leaq 0x21f2c(%rip), %rsi     # 0x2b34a
callq 0x4360
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
movl %eax, %esi
callq 0x8180
movq %r14, %rsi
callq 0x7c34
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9454
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x91db
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x91db
cmpl $0x1, %eax
jne 0x9489
movb $0x1, %bl
movq %r15, %rsi
callq 0x8de6
jmp 0x9493
movq %r15, %rsi
callq 0x8de6
xorl %ebx, %ebx
leaq 0x38(%rsp), %rdi
callq 0xbc3e
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
jmp 0x94c8
jmp 0x94d9
movq %rax, %rbx
jmp 0x94f8
jmp 0x94d9
jmp 0x94d9
jmp 0x94de
jmp 0x94de
jmp 0x94de
jmp 0x94de
movq %rax, %rbx
jmp 0x9513
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x94f8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9513
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4310
leaq 0x38(%rsp), %rdi
callq 0xbc3e
movq %rbx, %rdi
callq 0x45b0
nop