// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkaccessibility.cc
// Function: AccessibilityClassNINF::segmentPoresBasedOnFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool AccessibilityClassNINF::segmentPoresBasedOnFile(string filename){

  fstream input;
  input.open(filename.c_str());

  int linecount=0;
  int maxid=-1;

  if(!input.is_open()){
    cout << "\n" << "Failed to open segment file  " << filename << "\n";
    cout << "Exiting function ..." << "\n";
    return false;
  }
  else{
    cout << "Reading segment file " << filename << "\n";

    segmentMapping.resize(vornet.nodes.size(), -1);

    // Read and store information about sphere defining segments 
    while(!input.eof()){
      double a,b,c, r;
      int id;

      input >> a >> b >> c >> id >> r;

      if(input.eof()) 
        break;

      r = r*0.5;
      if(id>maxid) maxid = id;

      for(unsigned int i=0; i< vornet.nodes.size(); i++)
         {
         if(vornet.nodes.at(i).active == true)
           {
           if(orgAtomNet->calcDistanceXYZABC(vornet.nodes.at(i).x, vornet.nodes.at(i).y ,vornet.nodes.at(i).z, a,b,c) <= r) 
             {
             // node is within segment sphere
             if(segmentMapping[i] != -1 && segmentMapping[i] != id)
               {
               cerr << "Voronoi node has been assigned to more than one segment. This is wrong.\n";
               abort();

               }else{
               segmentMapping[i] = id;
               };
             };
           };
         };

      linecount++;

    }
    input.close();
  }
  cout << "Segment file: " << linecount << " lines read.";
  cout << "Max segment ID = " << maxid << "\n";

  n_segments = maxid+1; // this assumes that the segmentation file has correct IDs (from 0 to maxid)

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x4520
movq (%rbx), %rsi
movq %r15, %rdi
movl $0x18, %edx
callq 0x43d0
leaq 0xa8(%rsp), %rdi
callq 0x4120
movb %al, 0x3(%rsp)
testb %al, %al
je 0x9612e
movq 0xff038(%rip), %rdi     # 0x194fc0
leaq 0xc01dc(%rip), %rsi     # 0x15616b
movl $0x15, %edx
callq 0x44e0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xff019(%rip), %rdi     # 0x194fc0
callq 0x44e0
leaq 0xbd66b(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x68(%r14), %rsi
subq 0x60(%r14), %rsi
leaq 0x198(%r14), %r12
sarq $0x6, %rsi
leaq 0x10(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movq %r12, %rdi
callq 0x48a3e
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x48(%rsp,%rax)
jne 0x961ba
xorl %r15d, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x4270
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x42a0
movq 0x28(%rsp), %rcx
movq -0x18(%rcx), %rax
testb $0x2, 0x48(%rsp,%rax)
jne 0x961c2
movsd 0x8(%rsp), %xmm0
mulsd 0xb6fd1(%rip), %xmm0    # 0x14d038
movl 0x4(%rsp), %eax
cmpl %ebp, %eax
cmovgl %eax, %ebp
movsd %xmm0, 0x8(%rsp)
movq 0x60(%r14), %rax
cmpq %rax, 0x68(%r14)
je 0x96117
movl $0x1, %r13d
xorl %ebx, %ebx
movq %rbx, %rcx
shlq $0x6, %rcx
cmpb $0x1, 0x38(%rax,%rcx)
jne 0x960f4
addq %rcx, %rax
movq (%r14), %rdi
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x10(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
movsd 0x18(%rsp), %xmm5
callq 0x53538
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x960f4
movq (%r12), %rax
movl (%rax,%rbx,4), %edx
cmpl $-0x1, %edx
sete %sil
movl 0x4(%rsp), %ecx
cmpl %ecx, %edx
sete %dl
orb %sil, %dl
je 0x9626a
movl %ecx, (%rax,%rbx,4)
movl %r13d, %ebx
movq 0x60(%r14), %rax
movq 0x68(%r14), %rcx
subq %rax, %rcx
sarq $0x6, %rcx
incl %r13d
cmpq %rbx, %rcx
ja 0x9608c
movq 0x28(%rsp), %rcx
incl %r15d
movq -0x18(%rcx), %rax
testb $0x2, 0x48(%rsp,%rax)
je 0x96002
jmp 0x961c2
movq 0xfee8b(%rip), %rdi     # 0x194fc0
leaq 0xbd4e2(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0xfee73(%rip), %rdi     # 0x194fc0
leaq 0xbffe4(%rip), %rsi     # 0x156138
movl $0x1d, %edx
callq 0x44e0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0xfee54(%rip), %rdi     # 0x194fc0
callq 0x44e0
leaq 0xbd4a6(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xfee34(%rip), %rdi     # 0x194fc0
leaq 0xbffc3(%rip), %rsi     # 0x156156
movl $0x14, %edx
callq 0x44e0
movq 0xfee1c(%rip), %rdi     # 0x194fc0
leaq 0xbd473(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
jmp 0x9624a
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
leaq 0x28(%rsp), %rdi
callq 0x4090
movq 0xfeded(%rip), %rdi     # 0x194fc0
leaq 0xbfff0(%rip), %rsi     # 0x1561ca
movl $0xe, %edx
callq 0x44e0
movq 0xfedd5(%rip), %rdi     # 0x194fc0
movl %r15d, %esi
callq 0x4750
leaq 0xbf775(%rip), %rsi     # 0x15596f
movl $0xc, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xfedb2(%rip), %rdi     # 0x194fc0
leaq 0xbffc4(%rip), %rsi     # 0x1561d9
movl $0x11, %edx
callq 0x44e0
movq 0xfed9a(%rip), %rdi     # 0x194fc0
movl %ebp, %esi
callq 0x4750
leaq 0xbd3ea(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
incl %ebp
movl %ebp, 0x190(%r14)
leaq 0x28(%rsp), %rdi
callq 0x4110
movb 0x3(%rsp), %al
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfed7f(%rip), %rdi     # 0x194ff0
leaq 0xbff09(%rip), %rsi     # 0x156181
callq 0x4440
callq 0x4260
jmp 0x9628c
jmp 0x9628c
jmp 0x9628c
jmp 0x9628c
jmp 0x9628c
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780
nop