// File: /workspace/github_cpp_makefile_star2_O3/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 0x6886(%rip), %rsi      # 0x9050
callq 0x2220
testq %rax, %rax
je 0x2dc6
movq %rax, %rbx
movq %r14, 0x60(%rsp)
leaq 0x687b(%rip), %rsi      # 0x9062
leaq 0x9b92(%rip), %rdx      # 0xc380
leaq 0x9b83(%rip), %rcx      # 0xc378
movq %rax, %rdi
xorl %eax, %eax
callq 0x2310
cmpl $0x2, %eax
jne 0x2e17
movq 0x97c1(%rip), %r14      # 0xbfd0
leaq 0x6898(%rip), %rsi      # 0x90ae
movl $0xd, %edx
movq %r14, %rdi
callq 0x2200
movq 0x9b56(%rip), %rsi      # 0xc380
movq %r14, %rdi
callq 0x2120
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x6859(%rip), %rsi      # 0x90bc
movl $0xe, %edx
movq %r14, %rdi
callq 0x2200
movq 0x9b01(%rip), %rsi      # 0xc378
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0xc0(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %rbx, %rdx
callq 0x2290
cmpq $0x0, 0x9aba(%rip)      # 0xc380
je 0x29c9
leaq 0x78(%rsp), %r12
leaq 0x70(%rsp), %r13
leaq 0x68(%rsp), %rbp
xorl %r15d, %r15d
movq %rbx, %rdi
leaq 0x67e3(%rip), %rsi      # 0x90cb
leaq 0xc(%rsp), %rdx
movq %r12, %rcx
movq %r13, %r8
movq %rbp, %r9
xorl %eax, %eax
callq 0x2310
cmpl $0x4, %eax
jne 0x2c39
movl 0xc(%rsp), %eax
leaq 0x1(%r15), %r14
cmpq %rax, %r14
jne 0x2bdc
movq 0x98fa(%rip), %rsi      # 0xc218
cmpq 0x98fb(%rip), %rsi      # 0xc220
je 0x293e
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98dc(%rip)      # 0xc218
jmp 0x294d
leaq 0x98cb(%rip), %rdi      # 0xc210
movq %r12, %rdx
callq 0x469c
movq 0x98dc(%rip), %rsi      # 0xc230
cmpq 0x98dd(%rip), %rsi      # 0xc238
je 0x2974
movsd 0x70(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98be(%rip)      # 0xc230
jmp 0x2983
leaq 0x98ad(%rip), %rdi      # 0xc228
movq %r13, %rdx
callq 0x469c
movq 0x98be(%rip), %rsi      # 0xc248
cmpq 0x98bf(%rip), %rsi      # 0xc250
je 0x29aa
movsd 0x68(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98a0(%rip)      # 0xc248
jmp 0x29b9
leaq 0x988f(%rip), %rdi      # 0xc240
movq %rbp, %rdx
callq 0x469c
movq %r14, %r15
cmpq %r14, 0x99bd(%rip)      # 0xc380
ja 0x28de
movq 0x9600(%rip), %r14      # 0xbfd0
leaq 0x6732(%rip), %rsi      # 0x9109
movl $0x7, %edx
movq %r14, %rdi
callq 0x2200
movq 0x982d(%rip), %rsi      # 0xc218
subq 0x981e(%rip), %rsi      # 0xc210
sarq $0x3, %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
leaq 0x6709(%rip), %rsi      # 0x9111
movl $0x9, %edx
movq %rax, %rdi
callq 0x2200
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
cmpq $0x0, 0x9934(%rip)      # 0xc378
je 0x2b4f
leaq 0x58(%rsp), %rbp
leaq 0x54(%rsp), %r14
leaq 0x30(%rsp), %r15
xorl %r13d, %r13d
movq %rbx, %rdi
leaq 0x66b5(%rip), %rsi      # 0x911b
leaq 0xc(%rsp), %rdx
leaq 0x5c(%rsp), %rcx
movq %rbp, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2310
cmpl $0x4, %eax
jne 0x2cf3
movl 0xc(%rsp), %eax
leaq 0x1(%r13), %r12
cmpq %rax, %r12
jne 0x2c96
movl 0x5c(%rsp), %eax
decl %eax
movl %eax, 0x30(%rsp)
movq 0x97b8(%rip), %rsi      # 0xc260
cmpq 0x97b9(%rip), %rsi      # 0xc268
je 0x2ac0
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x97a2(%rip)      # 0xc260
jmp 0x2acf
leaq 0x9791(%rip), %rdi      # 0xc258
movq %r15, %rdx
callq 0x47dc
movl 0x58(%rsp), %eax
decl %eax
movl %eax, 0x30(%rsp)
movq 0x9798(%rip), %rsi      # 0xc278
cmpq 0x9799(%rip), %rsi      # 0xc280
je 0x2af8
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x9782(%rip)      # 0xc278
jmp 0x2b07
leaq 0x9771(%rip), %rdi      # 0xc270
movq %r15, %rdx
callq 0x47dc
movl 0x54(%rsp), %eax
decl %eax
movl %eax, 0x30(%rsp)
movq 0x9778(%rip), %rsi      # 0xc290
cmpq 0x9779(%rip), %rsi      # 0xc298
je 0x2b30
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x9762(%rip)      # 0xc290
jmp 0x2b3f
leaq 0x9751(%rip), %rdi      # 0xc288
movq %r15, %rdx
callq 0x47dc
movq %r12, %r13
cmpq %r12, 0x982f(%rip)      # 0xc378
ja 0x2a5c
movq 0x947a(%rip), %r14      # 0xbfd0
leaq 0x65ac(%rip), %rsi      # 0x9109
movl $0x7, %edx
movq %r14, %rdi
callq 0x2200
movq 0x96ef(%rip), %rsi      # 0xc260
subq 0x96e0(%rip), %rsi      # 0xc258
sarq $0x2, %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
leaq 0x65cb(%rip), %rsi      # 0x9159
movl $0xa, %edx
movq %rax, %rdi
callq 0x2200
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %rbx, %rdi
callq 0x21c0
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x442e
leaq 0x64f7(%rip), %rsi      # 0x90f4
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x43be
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x93cb(%rip), %rsi      # 0xbff0
movq 0x939c(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e62
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
movl %r15d, %esi
callq 0x442e
leaq 0x6481(%rip), %rsi      # 0x90db
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x43be
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x936e(%rip), %rsi      # 0xbff0
movq 0x933f(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e62
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
callq 0x442e
leaq 0x643d(%rip), %rsi      # 0x90f4
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x43be
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x9311(%rip), %rsi      # 0xbff0
movq 0x92e2(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e62
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
movl %r13d, %esi
callq 0x442e
leaq 0x6411(%rip), %rsi      # 0x9128
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x43be
leaq 0x6421(%rip), %rsi      # 0x9154
leaq 0xa0(%rsp), %rdi
callq 0x2320
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x2d61
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x2d6e
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rax), %rdx
leaq 0x10(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rdi
movq 0x60(%rsp), %rdx
callq 0x44d0
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x923e(%rip), %rsi      # 0xbff0
movq 0x920f(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e62
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x6278(%rip), %rsi      # 0x9052
leaq 0xc0(%rsp), %rdi
movq %r14, %rdx
callq 0x4336
movb $0x1, %bpl
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x91ea(%rip), %rsi      # 0xbff0
movq 0x91bb(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e62
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x6252(%rip), %rsi      # 0x907d
leaq 0x30(%rsp), %rdi
movq 0x60(%rsp), %rdx
callq 0x4336
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0x919d(%rip), %rsi      # 0xbff0
movq 0x916e(%rip), %rdx      # 0xbfc8
movq %rbx, %rdi
callq 0x22e0
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f90
movq 0x40(%rsp), %rsi
jmp 0x2f88
jmp 0x2fbd
movq %rax, %r14
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f90
movq 0xd0(%rsp), %rsi
jmp 0x2f88
jmp 0x2fbd
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ed6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2ed6
movq %rax, %r14
movb $0x1, %bpl
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ef5
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2ef5
movq %rax, %r14
movb $0x1, %bpl
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f16
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f90
movq 0x90(%rsp), %rsi
jmp 0x2f88
movq %rax, %r14
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fc0
movq 0x90(%rsp), %rsi
jmp 0x2fad
jmp 0x2f57
jmp 0x2f97
jmp 0x2f57
jmp 0x2f97
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f75
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f90
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
testb %bpl, %bpl
jne 0x2fc0
jmp 0x2fc8
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fc0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2fc0
jmp 0x2fbd
jmp 0x2fbd
jmp 0x2fbd
movq %rax, %r14
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x22f0