// File: /workspace/github_cpp_makefile_star2_O2/WolfgangLechner[P]StructureAnalysis/molecular_system.cpp
// Function: CMolecularSystem::readParticleFile()
void CMolecularSystem::readParticleFile()
{
  double posx,posy,posz;
  int nop;
  string line;
  ifstream confFile;
  confFile.open(this->parameter->xyzFile.c_str(),ifstream::in);
  if (confFile.is_open())
  {
    //the first line contains the number of particles
    getline(confFile,line);
    nop = atoi(line.c_str());
    this->parameter->nop = nop;
    this->initializeMolecules(nop);

    //Followed by boxx,boxy,boxz
    getline(confFile,line);
    this->parameter->boxx = atof(line.c_str());
    getline(confFile,line);
    this->parameter->boxy = atof(line.c_str());
    getline(confFile,line);
    this->parameter->boxz = atof(line.c_str());

    //so lets read the particles positions
    for (int ti = 0;ti<nop;ti++)
    {
      getline(confFile,line);
      string::size_type pos  = line.find(' ');
      if (pos == string::npos) break;
      posx = strtod(line.substr(0, pos ).c_str(),NULL);

      string::size_type lpos = pos + 1;
      pos  = line.find(' ', lpos);
      if (pos == string::npos) break;
      posy = strtod(line.substr(lpos, pos - lpos).c_str(),NULL);
      lpos = pos+1;

      posz = strtod(line.substr(lpos, line.length() - lpos).c_str(),NULL);

      this->molecules[ti].posx = posx;
      this->molecules[ti].posy = posy;
      this->molecules[ti].posz = posz;
    }
  }
  else
  {
    cerr << "Fatal Error : cannot open the file " <<  this->parameter->xyzFile << "\n";
  }
  setNumberOfCells();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x298(%rbp), %rdi
callq 0x2200
movq %rbx, -0x30(%rbp)
movq 0xb4e8c0(%rbx), %rax
movq 0x3230(%rax), %rsi
leaq -0x298(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2130
leaq -0x220(%rbp), %rdi
callq 0x20a0
testb %al, %al
je 0x3a92
leaq -0x298(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2080
movq -0x50(%rbp), %rdi
callq 0x22c0
movl %eax, %r15d
movq -0x30(%rbp), %rdi
movq 0xb4e8c0(%rdi), %rax
movl %r15d, 0x3208(%rax)
movl %r15d, %esi
callq 0x2faa
leaq -0x298(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2080
leaq -0x50(%rbp), %rbx
movq (%rbx), %rdi
callq 0x2230
movq -0x30(%rbp), %rax
movq 0xb4e8c0(%rax), %rax
movsd %xmm0, 0x3218(%rax)
leaq -0x298(%rbp), %rdi
movq %rbx, %rsi
callq 0x2080
movq (%rbx), %rdi
callq 0x2230
movq -0x30(%rbp), %rax
movq 0xb4e8c0(%rax), %rax
movsd %xmm0, 0x3220(%rax)
leaq -0x298(%rbp), %rdi
movq %rbx, %rsi
callq 0x2080
leaq -0x50(%rbp), %r14
movq (%r14), %rdi
callq 0x2230
movq -0x30(%rbp), %rax
movq 0xb4e8c0(%rax), %rax
movsd %xmm0, 0x3228(%rax)
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
imulq $0x870, %r15, %rax      # imm = 0x870
movq %rax, -0x58(%rbp)
leaq -0x90(%rbp), %r13
cmpq %r12, -0x58(%rbp)
je 0x3acc
leaq -0x298(%rbp), %rdi
movq %r14, %rsi
callq 0x2080
movq %r14, %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0x2260
cmpq $-0x1, %rax
je 0x3acc
movq %rax, %r15
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21f0
movq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x2150
movsd %xmm0, -0x70(%rbp)
movq %r13, %rdi
callq 0x23a8
incq %r15
movq %r14, %rdi
pushq $0x20
popq %rsi
movq %r15, %rdx
callq 0x2260
cmpq $-0x1, %rax
je 0x3acc
movq %rax, %rbx
movq %rax, %rcx
subq %r15, %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21f0
movq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x2150
movsd %xmm0, -0x68(%rbp)
movq %r13, %rdi
callq 0x23a8
incq %rbx
movq -0x48(%rbp), %rcx
subq %rbx, %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x21f0
movq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x2150
movsd %xmm0, -0x60(%rbp)
movq %r13, %rdi
callq 0x23a8
movq -0x30(%rbp), %rax
movq 0xb4e8b8(%rax), %rax
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x8(%rax,%r12)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, 0x10(%rax,%r12)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x18(%rax,%r12)
addq $0x870, %r12            # imm = 0x870
jmp 0x3979
movq 0x6557(%rip), %rdi      # 0x9ff0
leaq 0x36a5(%rip), %rsi      # 0x7145
callq 0x21b0
movl $0x3230, %esi           # imm = 0x3230
movq -0x30(%rbp), %rcx
addq 0xb4e8c0(%rcx), %rsi
movq %rax, %rdi
callq 0x2190
leaq 0x38b6(%rip), %rsi      # 0x737a
movq %rax, %rdi
callq 0x21b0
movq -0x30(%rbp), %rdi
callq 0x3b2a
leaq -0x298(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x23a8
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3b18
jmp 0x3b09
jmp 0x3b09
jmp 0x3b09
jmp 0x3b09
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x23a8
movq %rbx, %rdi
callq 0x2350
nop