// File: /workspace/github_cpp_makefile_star2_O1/srajangarg[P]raytracer/src/core/MeshInfo.cpp
// Function: TriangleMesh::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool
TriangleMesh::load(std::string const & path)
{
  clear();

  std::ifstream f(path.c_str());
  if (!f)
  {
    std::cerr << "Mesh: Couldn't load file " << path << std::endl;
    return false;
  }

  std::string line;
  // int normals = 0;

  while (std::getline(f, line))
  {
    std::istringstream linestream(line);
    std::string op;
    linestream >> op;

    if (op[0] == '#')
      continue;

    if (op == "v")
    {
      Vec3 v;
      linestream >> v;
      vertices.push_back(new MeshVertex(v));
    }

    if (op == "f")   // extract a face as a triangle fan
    {
      int first, second, third;

      if (!getFirstValue(linestream, first))
        continue;

      if (!getFirstValue(linestream, second))
        continue;

      while (getFirstValue(linestream, third))
      {
        triangles.push_back(new MeshTriangle(first - 1, second - 1, third - 1));
        second = third;
      }
    }
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movq %rdi, %r15
callq 0x50a4
movq (%rbx), %rsi
leaq 0x200(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x45f0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x220(%rsp,%rax), %eax
movl %eax, 0x1c(%rsp)
testb $0x5, %al
je 0x5298
movq 0x32dab(%rip), %rdi     # 0x37ff0
leaq 0x26e62(%rip), %rsi     # 0x2c0ae
movl $0x19, %edx
callq 0x4370
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x32d8c(%rip), %rdi     # 0x37ff0
callq 0x4370
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4230
jmp 0x546c
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x30(%rsp), %r12
movq %r15, 0x40(%rsp)
addq $0x18, %r15
leaq 0x48(%rsp), %r13
leaq 0x80(%rsp), %rbp
leaq 0x20(%rsp), %rbx
movq 0x200(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x4600
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5450
movq %rbp, %rdi
movq %r13, %rsi
movl $0x8, %edx
callq 0x4540
movq %r12, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x43c0
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
je 0x5418
movq %rbx, %rdi
leaq 0x26d7d(%rip), %rsi     # 0x2c0c8
callq 0x4110
testl %eax, %eax
jne 0x5392
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x5517
movl $0x18, %edi
callq 0x4310
movups 0x68(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movups %xmm0, (%rax)
movsd %xmm1, 0x10(%rax)
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x564c
movq %rbx, %rdi
leaq 0x27171(%rip), %rsi     # 0x2c50d
callq 0x4110
testl %eax, %eax
jne 0x5418
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x50fa
testb %al, %al
je 0x5418
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0x50fa
testb %al, %al
je 0x5418
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x50fa
testb %al, %al
je 0x5418
movl $0xc, %edi
callq 0x4310
movl 0x10(%rsp), %ecx
decl %ecx
movl 0xc(%rsp), %edx
decl %edx
movl 0x8(%rsp), %esi
decl %esi
movl %ecx, (%rax)
movl %edx, 0x4(%rax)
movl %esi, 0x8(%rax)
movq %rax, 0x68(%rsp)
movq %r15, %rdi
leaq 0x68(%rsp), %rsi
callq 0x57b8
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x53c7
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x542f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4320
movq %rbp, %rdi
movq 0x32b8f(%rip), %rsi     # 0x37fc8
callq 0x4460
leaq 0xf8(%rsp), %rdi
callq 0x4130
jmp 0x52cc
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x546c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4320
testb $0x5, 0x1c(%rsp)
sete %bl
leaq 0x200(%rsp), %rdi
callq 0x40e0
movl %ebx, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x54ab
movq %rax, %rbx
jmp 0x5502
jmp 0x54ab
jmp 0x54ab
jmp 0x54ab
jmp 0x54a6
jmp 0x54ab
movq %rax, %rbx
jmp 0x54e6
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x54c5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4320
movq 0x32afc(%rip), %rsi     # 0x37fc8
leaq 0x80(%rsp), %rdi
callq 0x4460
leaq 0xf8(%rsp), %rdi
callq 0x4130
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5502
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4320
leaq 0x200(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45c0