// File: /workspace/github_cpp_makefile_star2_O3/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 0x5084
movq (%rbx), %rsi
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x45e0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0xa0(%rsp,%rax), %ecx
movl %ecx, 0x14(%rsp)
testb $0x5, %cl
je 0x526f
movq 0x31dd4(%rip), %rdi     # 0x36ff0
leaq 0x25e8b(%rip), %rsi     # 0x2b0ae
movl $0x19, %edx
callq 0x4360
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x31db5(%rip), %rdi     # 0x36ff0
callq 0x4360
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4050
movq %rax, %rdi
callq 0x4220
jmp 0x544d
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0x28(%rsp), %r12
movq %r15, 0x38(%rsp)
addq $0x18, %r15
leaq 0x40(%rsp), %r13
leaq 0x288(%rsp), %rbp
leaq 0x18(%rsp), %r14
leaq 0x60(%rsp), %rbx
leaq (%rsp,%rax), %rdi
addq $0x80, %rdi
movl $0xa, %esi
callq 0x42e0
movsbl %al, %edx
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x45f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5431
movq %rbp, %rdi
movq %r13, %rsi
movl $0x8, %edx
callq 0x4530
movq %r12, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x43b0
movq 0x18(%rsp), %rax
cmpb $0x23, (%rax)
je 0x53ed
movq %r14, %rdi
leaq 0x25da0(%rip), %rsi     # 0x2b0c8
callq 0x4110
testl %eax, %eax
jne 0x536d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x54f8
movl $0x18, %edi
callq 0x4300
movsd 0x70(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movups %xmm1, (%rax)
movsd %xmm0, 0x10(%rax)
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5622
movq %r14, %rdi
leaq 0x261a6(%rip), %rsi     # 0x2b51d
callq 0x4110
testl %eax, %eax
jne 0x53ed
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x50d0
testb %al, %al
je 0x53ed
movq %rbp, %rdi
leaq 0x4(%rsp), %rsi
callq 0x50d0
testb %al, %al
je 0x53ed
movq %rbp, %rdi
movq %rsp, %rsi
callq 0x50d0
testb %al, %al
je 0x53ed
movl $0xc, %edi
callq 0x4300
movl 0x8(%rsp), %ecx
decl %ecx
movl 0x4(%rsp), %edx
decl %edx
movl (%rsp), %esi
decl %esi
movl %ecx, (%rax)
movl %edx, 0x4(%rax)
movl %esi, 0x8(%rax)
movq %rax, 0x60(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5796
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x53a2
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x5404
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x4310
movq %rbp, %rdi
movq 0x31bba(%rip), %rsi     # 0x36fc8
callq 0x4450
leaq 0x300(%rsp), %rdi
callq 0x4130
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x52a8
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x544d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4310
testb $0x5, 0x14(%rsp)
sete %bl
leaq 0x80(%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 0x548c
movq %rax, %rbx
jmp 0x54e3
jmp 0x548c
jmp 0x548c
jmp 0x548c
jmp 0x5487
jmp 0x548c
movq %rax, %rbx
jmp 0x54c7
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x54a6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x4310
movq 0x31b1b(%rip), %rsi     # 0x36fc8
leaq 0x288(%rsp), %rdi
callq 0x4450
leaq 0x300(%rsp), %rdi
callq 0x4130
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x54e3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4310
leaq 0x80(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45b0