// File: /workspace/github_cpp_makefile_star2_O2/ingowald[P]closestSurfacePointQueries/examples/benchmark.cpp
// Function: loadTriangles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void loadTriangles(const std::string &fileName)
{
  FILE *file = fopen(fileName.c_str(),"r");
  if (!file) throw std::runtime_error("could not open "+fileName);

  char line[1000];

  if (fscanf(file,"NSURFPTS=%12li NTRI=%12li\n",&numVertices,&numTriangles)!=2) 
    throw std::runtime_error("could not parse num vertices/num trianlges from "+fileName);
  std::cout << "num vertices " << numVertices << std::endl;
  std::cout << "num triangles " << numTriangles << std::endl;
  fgets(line,1000,file);

  double x,y,z;
  int ID,i,j,k;

  // parse vertices
  for (int vtxID=0;vtxID<numVertices;vtxID++) {
    if (fscanf(file,"%i %lf %lf %lf\n",&ID,&x,&y,&z)!=4) 
      throw std::runtime_error("couldn't read vertex no "+std::to_string(vtxID));
    if (ID != vtxID+1)
      throw std::runtime_error("invalid vertex line "+std::to_string(vtxID));
    // printf(" vtx %i -> %f %f %f\n",ID,x,y,z);
    vertex_x.push_back(x);
    vertex_y.push_back(y);
    vertex_z.push_back(z);
  }
  std::cout << "loaded " << vertex_x.size() << " vertices" << std::endl;

  // parse indices
  for (int idxID=0;idxID<numTriangles;idxID++) {
    if (fscanf(file,"%i %i %i %i\n",&ID,&i,&j,&k)!=4) 
      throw std::runtime_error("couldn't read triangles indices for tri no "+std::to_string(idxID)
                               +" in "+fileName);
    if (ID != idxID+1)
      throw std::runtime_error("invalid vertex line "+std::to_string(idxID));
    // printf(" idx %i -> %i %i %i\n",idxID,i,j,k);
    index_x.push_back(i-1);
    index_y.push_back(j-1);
    index_z.push_back(k-1);
  }
  std::cout << "loaded " << index_x.size() << " triangles" << std::endl;

  fclose(file);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rdi, %r14
movq (%rdi), %rdi
leaq 0x58a6(%rip), %rsi      # 0x8050
callq 0x2210
testq %rax, %rax
je 0x2bc8
movq %rax, %rbx
movq %r14, 0x40(%rsp)
leaq 0x589b(%rip), %rsi      # 0x8062
leaq 0x9bd2(%rip), %rdx      # 0xc3a0
leaq 0x9bc3(%rip), %rcx      # 0xc398
movq %rax, %rdi
xorl %eax, %eax
callq 0x2340
cmpl $0x2, %eax
jne 0x2c17
movq 0x97e1(%rip), %r14      # 0xbfd0
leaq 0x58b8(%rip), %rsi      # 0x80ae
movq %r14, %rdi
callq 0x21c0
movq 0x9b9b(%rip), %rsi      # 0xc3a0
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
callq 0x20f0
leaq 0x58a0(%rip), %rsi      # 0x80bc
movq %r14, %rdi
callq 0x21c0
movq 0x9b6d(%rip), %rsi      # 0xc398
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
callq 0x20f0
leaq 0xc0(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %rbx, %rdx
callq 0x22b0
leaq 0x78(%rsp), %r13
leaq 0x70(%rsp), %rbp
leaq 0x68(%rsp), %r15
xorl %r12d, %r12d
cmpq %r12, 0x9b37(%rip)      # 0xc3a0
jbe 0x28d7
movq %rbx, %rdi
leaq 0x5856(%rip), %rsi      # 0x80cb
leaq 0xc(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x2340
cmpl $0x4, %eax
jne 0x2a26
movl 0xc(%rsp), %eax
leaq 0x1(%r12), %r14
cmpq %rax, %r14
jne 0x2a81
leaq 0x9984(%rip), %rdi      # 0xc230
movq %r13, %rsi
callq 0x3ce4
leaq 0x998d(%rip), %rdi      # 0xc248
movq %rbp, %rsi
callq 0x3ce4
leaq 0x9996(%rip), %rdi      # 0xc260
movq %r15, %rsi
callq 0x3ce4
movq %r14, %r12
jmp 0x2862
movq 0x96f2(%rip), %rdi      # 0xbfd0
leaq 0x5824(%rip), %rsi      # 0x8109
callq 0x21c0
movq 0x9947(%rip), %rsi      # 0xc238
subq 0x9938(%rip), %rsi      # 0xc230
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x2130
leaq 0x5806(%rip), %rsi      # 0x8111
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20f0
leaq 0x10(%rsp), %r12
leaq 0x9969(%rip), %r13      # 0xc290
leaq 0x997a(%rip), %rbp      # 0xc2a8
xorl %r15d, %r15d
cmpq %r15, 0x9a60(%rip)      # 0xc398
jbe 0x29c8
movq %rbx, %rdi
leaq 0x57d3(%rip), %rsi      # 0x811b
leaq 0xc(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
leaq 0x38(%rsp), %r8
leaq 0x34(%rsp), %r9
xorl %eax, %eax
callq 0x2340
cmpl $0x4, %eax
jne 0x2adc
movl 0xc(%rsp), %eax
leaq 0x1(%r15), %r14
cmpq %rax, %r14
jne 0x2b6d
movl 0x3c(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
leaq 0x98ea(%rip), %rdi      # 0xc278
movq %r12, %rsi
callq 0x403a
movl 0x38(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x403a
movl 0x34(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x403a
movq %r14, %r15
jmp 0x2931
movq 0x9601(%rip), %rdi      # 0xbfd0
leaq 0x5733(%rip), %rsi      # 0x8109
callq 0x21c0
movq 0x989e(%rip), %rsi      # 0xc280
subq 0x988f(%rip), %rsi      # 0xc278
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x2130
leaq 0x575d(%rip), %rsi      # 0x8159
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x21d0
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
movl %r12d, %esi
callq 0x3c8b
leaq 0x5696(%rip), %rsi      # 0x80db
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3c67
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x9583(%rip), %rsi      # 0xbff0
movq 0x9554(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
jmp 0x2c60
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
movl %r12d, %esi
callq 0x3c8b
leaq 0x5654(%rip), %rsi      # 0x80f4
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3c67
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x9528(%rip), %rsi      # 0xbff0
movq 0x94f9(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
jmp 0x2c60
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
movl %r15d, %esi
callq 0x3c8b
leaq 0x562a(%rip), %rsi      # 0x8128
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x3c67
leaq 0x563a(%rip), %rdx      # 0x8154
leaq 0x48(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3d25
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x3d06
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x9497(%rip), %rsi      # 0xbff0
movq 0x9468(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
jmp 0x2c60
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
movl %r15d, %esi
callq 0x3c8b
leaq 0x5568(%rip), %rsi      # 0x80f4
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3c67
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x943c(%rip), %rsi      # 0xbff0
movq 0x940d(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
jmp 0x2c60
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x5478(%rip), %rsi      # 0x8052
leaq 0xc0(%rsp), %rdi
movq %r14, %rdx
callq 0x3bf1
movb $0x1, %bpl
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x93ea(%rip), %rsi      # 0xbff0
movq 0x93bb(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
jmp 0x2c60
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x5454(%rip), %rsi      # 0x807d
leaq 0x10(%rsp), %rdi
movq 0x40(%rsp), %rdx
callq 0x3bf1
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22d0
xorl %ebp, %ebp
movq 0x939f(%rip), %rsi      # 0xbff0
movq 0x9370(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x2300
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x2ce6
jmp 0x2cf8
movq %rax, %r14
leaq 0xc0(%rsp), %rdi
jmp 0x2ce6
jmp 0x2cf8
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x20e0
jmp 0x2c93
movq %rax, %r14
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x20e0
jmp 0x2ca5
movq %rax, %r14
movb $0x1, %bpl
leaq 0xa0(%rsp), %rdi
callq 0x20e0
jmp 0x2cbe
jmp 0x2cca
jmp 0x2cdb
movq %rax, %r14
movb $0x1, %bpl
leaq 0x80(%rsp), %rdi
jmp 0x2ce6
jmp 0x2cca
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x20e0
jmp 0x2ce1
jmp 0x2cdb
movq %rax, %r14
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x20e0
testb %bpl, %bpl
jne 0x2cfb
jmp 0x2d03
jmp 0x2cf8
jmp 0x2cf8
jmp 0x2cf8
movq %rax, %r14
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x2310