// File: /workspace/github_cpp_makefile_star2_O1/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 0x7820
movq %r12, %rdi
movq %r15, %rsi
callq 0x43a0
movq (%r15), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x9209
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x4320
cmpq $0x0, 0x8(%r12)
je 0x9263
leaq 0x48(%rbx), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xb51c
cmpq $0x0, (%rax)
je 0x9294
movq 0x90(%rbx), %r15
leaq 0x23151(%rip), %rsi     # 0x2c385
movl $0x18, %edx
movq %r15, %rdi
callq 0x4370
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x4370
leaq 0x22f30(%rip), %rsi     # 0x2c189
movl $0x5, %edx
movq %rax, %rdi
jmp 0x9276
movq 0x90(%rbx), %rdi
leaq 0x2312d(%rip), %rsi     # 0x2c39e
movl $0x1f, %edx
callq 0x4370
movq %r14, %rdi
callq 0x4590
movq %rbx, %rdi
movl %eax, %esi
callq 0x8418
xorl %ebp, %ebp
jmp 0x97ce
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 0x230fd(%rip), %rsi     # 0x2c3be
leaq 0x230f8(%rip), %rdx     # 0x2c3c0
movq %rsp, %rdi
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x0, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x92fe
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x230b1(%rip), %rsi     # 0x2c3c1
leaq 0x230ac(%rip), %rdx     # 0x2c3c3
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x1, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x934a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x23068(%rip), %rsi     # 0x2c3c4
leaq 0x23063(%rip), %rdx     # 0x2c3c6
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x2, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9396
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x2301f(%rip), %rsi     # 0x2c3c7
leaq 0x2301b(%rip), %rdx     # 0x2c3ca
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x3, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x93e2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22fd7(%rip), %rsi     # 0x2c3cb
leaq 0x22fd3(%rip), %rdx     # 0x2c3ce
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x4, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x942e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22f8f(%rip), %rsi     # 0x2c3cf
leaq 0x22f8a(%rip), %rdx     # 0x2c3d1
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x5, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x947a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x22f46(%rip), %rsi     # 0x2c3d2
leaq 0x22f42(%rip), %rdx     # 0x2c3d5
callq 0xc09a
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb598
movl $0x6, (%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x94c6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movl $0x40, %edi
callq 0x4310
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %r13, %rdi
movq %r12, %rsi
callq 0xb51c
movq %r15, (%rax)
movq %rsp, %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7d48
testl %eax, %eax
je 0x951e
cmpl $0x1, %eax
jne 0x9611
movq %r15, %rsi
callq 0x9104
movb $0x1, %bpl
jmp 0x961b
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %r12
movq %r13, %rdx
callq 0x7b10
testb %al, %al
je 0x9785
movq %r12, %r13
movq %r12, %rdi
leaq 0x22da5(%rip), %rsi     # 0x2c30b
callq 0x4110
testl %eax, %eax
je 0x9622
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0xd01a
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rax
je 0x966a
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x7fb2
testl %eax, %eax
jle 0x9742
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x95ef
movl $0x1, %ecx
movl $0x2, %r13d
movq (%rax,%rcx,8), %rdi
testq %rdi, %rdi
je 0x95d3
movq (%rdi), %rax
callq *0x20(%rax)
movl %r13d, %ecx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r13d
cmpq %rcx, %rdx
ja 0x95c4
movq 0x20(%rsp), %rax
movq (%rax), %r13
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xb652
movslq (%rax), %rax
movq %r13, 0x8(%r15,%rax,8)
jmp 0x977d
movq %r15, %rsi
callq 0x9104
xorl %ebp, %ebp
xorl %eax, %eax
jmp 0x97bc
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x7fb2
cmpl $0x2, %eax
jg 0x96c1
movq 0x90(%rbx), %rdi
movl $0x25, %edx
leaq 0x22d88(%rip), %rsi     # 0x2c3d6
callq 0x4370
movq %r14, %rdi
callq 0x4590
movq %rbx, %rdi
movl %eax, %esi
callq 0x8418
jmp 0x977d
movq 0x90(%rbx), %r13
movl $0xf, %edx
movq %r13, %rdi
leaq 0x22cd2(%rip), %rsi     # 0x2c352
callq 0x4370
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x4370
movl $0x13, %edx
movq %rax, %rdi
leaq 0x22cbd(%rip), %rsi     # 0x2c362
callq 0x4370
movq %r14, %rdi
callq 0x4590
movq %rbx, %rdi
movl %eax, %esi
callq 0x8418
jmp 0x977d
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
cmpq $0x19, %rcx
jb 0x970a
movl $0x3, %ecx
movl $0x4, %r13d
movq (%rax,%rcx,8), %rdi
testq %rdi, %rdi
je 0x96ee
movq (%rdi), %rax
callq *0x20(%rax)
movl %r13d, %ecx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r13d
cmpq %rcx, %rdx
ja 0x96df
movl $0x18, %edi
callq 0x4310
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 0x9727
jmp 0x977d
movq 0x90(%rbx), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x4370
movl $0x17, %edx
movq %rax, %rdi
leaq 0x22bd4(%rip), %rsi     # 0x2c33a
callq 0x4370
movq %r14, %rdi
callq 0x4590
movq %rbx, %rdi
movl %eax, %esi
callq 0x8418
movq %r14, %rsi
callq 0x7ed0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x979c
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4320
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
movq %r12, %r13
je 0x97ba
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
movb $0x1, %al
testb %al, %al
jne 0x94f6
leaq 0x38(%rsp), %rdi
callq 0xc022
andb $0x1, %bpl
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x97fb
jmp 0x9843
jmp 0x97fb
jmp 0x9843
jmp 0x97fb
jmp 0x9843
jmp 0x97fb
jmp 0x9843
jmp 0x97fb
jmp 0x9843
jmp 0x97fb
jmp 0x9843
movq %rax, %rbx
jmp 0x9826
jmp 0x9843
jmp 0x980c
jmp 0x980c
jmp 0x9843
jmp 0x980c
jmp 0x980c
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9826
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4320
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x9846
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4320
jmp 0x9846
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xc022
movq %rbx, %rdi
callq 0x45c0