// File: /workspace/github_cpp_makefile_star2_O2/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 0x4d60
movq (%rbx), %rsi
leaq 0x80(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x45f0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0xa0(%rsp,%rax), %eax
movl %eax, 0x14(%rsp)
testb $0x5, %al
je 0x4ec5
movq 0x2a14f(%rip), %rdi     # 0x2eff0
leaq 0x1c1dc(%rip), %rsi     # 0x21084
callq 0x4300
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x4190
jmp 0x5044
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %r15, 0x18(%rsp)
leaq 0x18(%r15), %r14
leaq 0x288(%rsp), %r13
leaq 0x20(%rsp), %rbx
leaq 0x40(%rsp), %rbp
movq %rsp, %r15
pushq $0xc
popq %r12
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x40b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x503a
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x4550
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43d0
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
je 0x5025
movq %rbx, %rdi
leaq 0x1c13a(%rip), %rsi     # 0x2109e
callq 0x4d52
testb %al, %al
je 0x4fa7
movq %r13, %rdi
movq %rbp, %rsi
callq 0x50bc
pushq $0x18
popq %rdi
callq 0x4320
movsd 0x50(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, (%rax)
movsd %xmm0, 0x10(%rax)
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x51d4
movq %rbx, %rdi
leaq 0x1c53c(%rip), %rsi     # 0x214ed
callq 0x4d52
testb %al, %al
je 0x5025
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x4dab
testb %al, %al
je 0x5025
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x4dab
testb %al, %al
je 0x5025
movq %r13, %rdi
movq %r15, %rsi
callq 0x4dab
testb %al, %al
je 0x5025
movq %r12, %rdi
callq 0x4320
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, 0x40(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x5366
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x4fdc
movq %rbx, %rdi
callq 0x4170
movq %r13, %rdi
callq 0x4180
jmp 0x4ef8
leaq 0x60(%rsp), %rdi
callq 0x4170
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
movq %rax, %rbx
jmp 0x50a7
jmp 0x5083
jmp 0x5083
jmp 0x5083
jmp 0x507c
jmp 0x5083
movq %rax, %rbx
jmp 0x509d
jmp 0x5083
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x288(%rsp), %rdi
callq 0x4180
leaq 0x60(%rsp), %rdi
callq 0x4170
leaq 0x80(%rsp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x45c0