// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/grid.cc
// Function: GaussianCube::loadHistogramDataPerFrame(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void GaussianCube::loadHistogramDataPerFrame(std::string listfilename){

 fstream flist;

 flist.open(listfilename.c_str());
 if(flist.is_open()==false){
   cerr << "Error: A file with frames (" << listfilename << ") failed to open. \n" ;
   }else{
   // file with a list of frames is open. proceed.

   int nfiles=0;
   cout << "Loading filenames from " << listfilename << endl;
   while(!flist.eof())
    {
    string inputfilename;

    flist >> inputfilename;
    if(flist.eof()){
      nfiles--;
      break;
      };

    nfiles++;
 
    fstream input;
    input.open(inputfilename.c_str());
    if(input.is_open()==false){
      cerr << "Error: CSSR failed to open " << inputfilename << endl;
    }else{

    // reading in datapoints (expect points in "Liverpool format" (fractional coordinates)

    int n = 0; // number of points 
    double a,b,c;
    int code;
    string ptStatus; 
    int pocketID;
    while(!input.eof())
       {
       input >> a;

       if(input.eof())
         {
         n--;
         break;
         };

       input >> b >> c >> code >> ptStatus >> pocketID;

       n++;

       // analysis of the read-in data
       a = trans_to_origuc(a);
       b = trans_to_origuc(b);
       c = trans_to_origuc(c);    

       // projecting into a grid

       int ca, cb, cc;

       ca = floor(a * na);
       cb = floor(b * nb);
       cc = floor(c * nc);

//       cube[ca][cb][cc] += 1.0; // increase count at grid point ca, cb, cc

       if(cube[ca][cb][cc]-floor(cube[ca][cb][cc]) == 0.0) cube[ca][cb][cc] += 0.5; // adding 0.5 serves as a flag

       };

    cout << "File " << inputfilename << ":  " << n << " lines read." << "\n";

    input.close();
    };

   for(int i=0; i<na; i++)
      for(int j=0; j< nb; j++)
        for(int k=0; k<nc; k++)
           cube[i][j][k] = ceil(cube[i][j][k]);

   }; // ends while loop over a file list

  cout << nfiles << " frames loaded.\n";

  };

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
leaq 0x298(%rsp), %r15
movq %r15, %rdi
callq 0x4520
movq (%r14), %rsi
movq %r15, %rdi
movl $0x18, %edx
callq 0x43d0
leaq 0x318(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x88acc
movq 0x10c967(%rip), %rdi    # 0x194fc0
leaq 0xcd34c(%rip), %rsi     # 0x1559ac
movl $0x17, %edx
callq 0x44e0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10c948(%rip), %rdi    # 0x194fc0
callq 0x44e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0x38(%rsp), %r15
xorl %ebx, %ebx
leaq 0x88(%rsp), %r14
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x2b8(%rsp,%rax)
jne 0x88aa8
movq %r15, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
leaq 0x298(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4560
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x2b8(%rsp,%rax), %eax
movl %eax, 0x24(%rsp)
testb $0x2, %al
jne 0x88990
movq %rbx, 0x70(%rsp)
movq %r14, %rdi
callq 0x4520
movq 0x28(%rsp), %rsi
movq %r14, %rdi
movl $0x18, %edx
callq 0x43d0
leaq 0x108(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x88997
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
xorl %r13d, %r13d
testb $0x2, 0xa8(%rsp,%rax)
jne 0x888ef
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x42a0
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0xa8(%rsp,%rax)
jne 0x888ef
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x84(%rsp), %rsi
callq 0x4270
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x4270
movsd 0x18(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x10(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x48(%rsp)
movq 0x8(%rsp), %r14
movsd %xmm0, (%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x78(%r14), %xmm0
mulsd 0x18(%rsp), %xmm0
callq 0x4700
cvttsd2si %xmm0, %ebx
xorps %xmm0, %xmm0
cvtsi2sdl 0x7c(%r14), %xmm0
mulsd 0x10(%rsp), %xmm0
callq 0x4700
cvttsd2si %xmm0, %ebp
xorps %xmm0, %xmm0
cvtsi2sdl 0x80(%r14), %xmm0
mulsd (%rsp), %xmm0
callq 0x4700
cvttsd2si %xmm0, %eax
movq 0x88(%r14), %rcx
movslq %ebx, %rdx
movq (%rcx,%rdx,8), %rcx
movslq %ebp, %rdx
movq (%rcx,%rdx,8), %rbx
movslq %eax, %r14
movsd (%rbx,%r14,8), %xmm0
movsd %xmm0, (%rsp)
callq 0x4700
movsd (%rsp), %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
ucomisd 0xc8a9b(%rip), %xmm1    # 0x151350
jne 0x888c7
jp 0x888c7
addsd 0xc4777(%rip), %xmm2    # 0x14d038
movsd %xmm2, (%rbx,%r14,8)
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
incl %r13d
testb $0x2, 0xa8(%rsp,%rax)
leaq 0x88(%rsp), %r14
je 0x88783
incl %r13d
movl $0x5, %edx
movq 0x10c6c5(%rip), %rdi    # 0x194fc0
leaq 0xcd0c2(%rip), %rsi     # 0x1559c4
callq 0x44e0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x10c6a8(%rip), %rdi    # 0x194fc0
callq 0x44e0
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0xcc64e(%rip), %rsi     # 0x154f7d
callq 0x44e0
movq %r12, %rdi
movl %r13d, %esi
callq 0x4750
movq %rax, %r13
movl $0xc, %edx
movq %rax, %rdi
leaq 0xcd01e(%rip), %rsi     # 0x15596f
callq 0x44e0
movl $0x1, %edx
movq %r13, %rdi
leaq 0xcacb9(%rip), %rsi     # 0x15361e
callq 0x44e0
movq %r14, %rdi
callq 0x4090
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x889ef
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x889ef
decl %ebx
jmp 0x88a86
movl $0x1b, %edx
movq 0x10c64d(%rip), %rdi    # 0x194ff0
leaq 0xc57fd(%rip), %rsi     # 0x14e1a7
callq 0x44e0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x10c630(%rip), %rdi    # 0x194ff0
callq 0x44e0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x8(%rsp), %rax
movslq 0x78(%rax), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
jle 0x88a6a
movq 0x8(%rsp), %rax
movl 0x7c(%rax), %r13d
movl 0x80(%rax), %r14d
xorl %ebp, %ebp
testl %r13d, %r13d
jle 0x88a60
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, (%rsp)
xorl %ebx, %ebx
testl %r14d, %r14d
jle 0x88a58
movq (%rsp), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%rbx,8), %r12
xorl %r15d, %r15d
movsd (%r12,%r15,8), %xmm0
callq 0x40d0
movsd %xmm0, (%r12,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x88a3f
incq %rbx
cmpq %r13, %rbx
jne 0x88a2b
incq %rbp
cmpq 0x78(%rsp), %rbp
jne 0x88a14
movq 0x70(%rsp), %rbx
incl %ebx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x4110
leaq 0x38(%rsp), %r15
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x88a9d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
testb $0x2, 0x24(%rsp)
je 0x886b6
movq 0x10c511(%rip), %rdi    # 0x194fc0
movl %ebx, %esi
callq 0x4750
leaq 0xccf0d(%rip), %rsi     # 0x1559ca
movl $0x10, %edx
movq %rax, %rdi
callq 0x44e0
jmp 0x88b0b
movq 0x10c51d(%rip), %rdi    # 0x194ff0
leaq 0xccea2(%rip), %rsi     # 0x15597c
movl $0x1b, %edx
callq 0x44e0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10c4fe(%rip), %rdi    # 0x194ff0
callq 0x44e0
leaq 0xcce9a(%rip), %rsi     # 0x155998
movl $0x13, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x298(%rsp), %rdi
callq 0x4110
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x88b2c
movq %rax, %rbx
jmp 0x88b82
jmp 0x88b33
movq %rax, %rbx
jmp 0x88b6b
jmp 0x88b3f
movq %rax, %rbx
jmp 0x88b5e
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x88b5e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x88(%rsp), %rdi
callq 0x4110
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x88b82
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x298(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780
nop