// File: /workspace/github_cpp_makefile_star2_O1/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 0x7876(%rip), %rsi      # 0xa050
callq 0x2220
testq %rax, %rax
je 0x2dd6
movq %rax, %rbx
movq %r14, 0x60(%rsp)
leaq 0x786b(%rip), %rsi      # 0xa062
leaq 0xab8a(%rip), %rdx      # 0xd388
leaq 0xab7b(%rip), %rcx      # 0xd380
movq %rax, %rdi
xorl %eax, %eax
callq 0x2320
cmpl $0x2, %eax
jne 0x2e27
movq 0xa7b1(%rip), %r14      # 0xcfd0
leaq 0x7888(%rip), %rsi      # 0xa0ae
movl $0xd, %edx
movq %r14, %rdi
callq 0x2200
movq 0xab4e(%rip), %rsi      # 0xd388
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 0x7849(%rip), %rsi      # 0xa0bc
movl $0xe, %edx
movq %r14, %rdi
callq 0x2200
movq 0xaaf9(%rip), %rsi      # 0xd380
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, 0xaab2(%rip)      # 0xd388
je 0x29d9
leaq 0x78(%rsp), %r12
leaq 0x70(%rsp), %r13
leaq 0x68(%rsp), %rbp
xorl %r15d, %r15d
movq %rbx, %rdi
leaq 0x77d3(%rip), %rsi      # 0xa0cb
leaq 0xc(%rsp), %rdx
movq %r12, %rcx
movq %r13, %r8
movq %rbp, %r9
xorl %eax, %eax
callq 0x2320
cmpl $0x4, %eax
jne 0x2c49
movl 0xc(%rsp), %eax
leaq 0x1(%r15), %r14
cmpq %rax, %r14
jne 0x2bec
movq 0xa8f2(%rip), %rsi      # 0xd220
cmpq 0xa8f3(%rip), %rsi      # 0xd228
je 0x294e
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xa8d4(%rip)      # 0xd220
jmp 0x295d
leaq 0xa8c3(%rip), %rdi      # 0xd218
movq %r12, %rdx
callq 0x469c
movq 0xa8d4(%rip), %rsi      # 0xd238
cmpq 0xa8d5(%rip), %rsi      # 0xd240
je 0x2984
movsd 0x70(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xa8b6(%rip)      # 0xd238
jmp 0x2993
leaq 0xa8a5(%rip), %rdi      # 0xd230
movq %r13, %rdx
callq 0x469c
movq 0xa8b6(%rip), %rsi      # 0xd250
cmpq 0xa8b7(%rip), %rsi      # 0xd258
je 0x29ba
movsd 0x68(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xa898(%rip)      # 0xd250
jmp 0x29c9
leaq 0xa887(%rip), %rdi      # 0xd248
movq %rbp, %rdx
callq 0x469c
movq %r14, %r15
cmpq %r14, 0xa9b5(%rip)      # 0xd388
ja 0x28ee
movq 0xa5f0(%rip), %r14      # 0xcfd0
leaq 0x7722(%rip), %rsi      # 0xa109
movl $0x7, %edx
movq %r14, %rdi
callq 0x2200
movq 0xa825(%rip), %rsi      # 0xd220
subq 0xa816(%rip), %rsi      # 0xd218
sarq $0x3, %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
leaq 0x76f9(%rip), %rsi      # 0xa111
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, 0xa92c(%rip)      # 0xd380
je 0x2b5f
leaq 0x58(%rsp), %rbp
leaq 0x54(%rsp), %r14
leaq 0x10(%rsp), %r15
xorl %r13d, %r13d
movq %rbx, %rdi
leaq 0x76a5(%rip), %rsi      # 0xa11b
leaq 0xc(%rsp), %rdx
leaq 0x5c(%rsp), %rcx
movq %rbp, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2320
cmpl $0x4, %eax
jne 0x2d03
movl 0xc(%rsp), %eax
leaq 0x1(%r13), %r12
cmpq %rax, %r12
jne 0x2ca6
movl 0x5c(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
movq 0xa7b0(%rip), %rsi      # 0xd268
cmpq 0xa7b1(%rip), %rsi      # 0xd270
je 0x2ad0
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa79a(%rip)      # 0xd268
jmp 0x2adf
leaq 0xa789(%rip), %rdi      # 0xd260
movq %r15, %rdx
callq 0x47dc
movl 0x58(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
movq 0xa790(%rip), %rsi      # 0xd280
cmpq 0xa791(%rip), %rsi      # 0xd288
je 0x2b08
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa77a(%rip)      # 0xd280
jmp 0x2b17
leaq 0xa769(%rip), %rdi      # 0xd278
movq %r15, %rdx
callq 0x47dc
movl 0x54(%rsp), %eax
decl %eax
movl %eax, 0x10(%rsp)
movq 0xa770(%rip), %rsi      # 0xd298
cmpq 0xa771(%rip), %rsi      # 0xd2a0
je 0x2b40
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa75a(%rip)      # 0xd298
jmp 0x2b4f
leaq 0xa749(%rip), %rdi      # 0xd290
movq %r15, %rdx
callq 0x47dc
movq %r12, %r13
cmpq %r12, 0xa827(%rip)      # 0xd380
ja 0x2a6c
movq 0xa46a(%rip), %r14      # 0xcfd0
leaq 0x759c(%rip), %rsi      # 0xa109
movl $0x7, %edx
movq %r14, %rdi
callq 0x2200
movq 0xa6e7(%rip), %rsi      # 0xd268
subq 0xa6d8(%rip), %rsi      # 0xd260
sarq $0x2, %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
leaq 0x75bb(%rip), %rsi      # 0xa159
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 0x30(%rsp), %rdi
movl %r15d, %esi
callq 0x4434
leaq 0x74e7(%rip), %rsi      # 0xa0f4
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x43c4
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa3bb(%rip), %rsi      # 0xcff0
movq 0xa38c(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e72
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
movl %r15d, %esi
callq 0x4434
leaq 0x7471(%rip), %rsi      # 0xa0db
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x43c4
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa35e(%rip), %rsi      # 0xcff0
movq 0xa32f(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e72
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
movl %r13d, %esi
callq 0x4434
leaq 0x742d(%rip), %rsi      # 0xa0f4
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x43c4
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa301(%rip), %rsi      # 0xcff0
movq 0xa2d2(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e72
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
movl %r13d, %esi
callq 0x4434
leaq 0x7401(%rip), %rsi      # 0xa128
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x43c4
leaq 0x7411(%rip), %rsi      # 0xa154
leaq 0xa0(%rsp), %rdi
callq 0x2330
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x2d71
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x2d7e
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x10(%rsp), %rdi
movq 0x60(%rsp), %rdx
callq 0x44d6
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa22e(%rip), %rsi      # 0xcff0
movq 0xa1ff(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e72
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x7268(%rip), %rsi      # 0xa052
leaq 0xc0(%rsp), %rdi
movq %r14, %rdx
callq 0x433c
movb $0x1, %bpl
leaq 0xc0(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa1da(%rip), %rsi      # 0xcff0
movq 0xa1ab(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
jmp 0x2e72
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x7242(%rip), %rsi      # 0xa07d
leaq 0x10(%rsp), %rdi
movq 0x60(%rsp), %rdx
callq 0x433c
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x22b0
xorl %ebp, %ebp
movq 0xa18d(%rip), %rsi      # 0xcff0
movq 0xa15e(%rip), %rdx      # 0xcfc8
movq %rbx, %rdi
callq 0x22e0
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fa0
movq 0x20(%rsp), %rsi
jmp 0x2f8a
jmp 0x2f9a
movq %rax, %r14
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fa0
movq 0xd0(%rsp), %rsi
jmp 0x2f8a
jmp 0x2f9a
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ee6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2ee6
movq %rax, %r14
movb $0x1, %bpl
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2f05
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2f05
movq %rax, %r14
movb $0x1, %bpl
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f2e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2f2e
movq %rax, %r14
movb $0x1, %bpl
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fa0
movq 0x90(%rsp), %rsi
jmp 0x2f8a
jmp 0x2f51
jmp 0x2f71
jmp 0x2f51
jmp 0x2f71
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f77
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2f77
movq %rax, %r14
movb $0x1, %bpl
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fa0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x2fa0
jmp 0x2f9a
jmp 0x2f9a
jmp 0x2f9a
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x2fad
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x22f0